If the magnet be rotated from an initial orientation θ1=0∘ to final orientation θ2=180∘ the total work done W=θ1∫θ2MBsindθ =MB[−cosθ]θ1θ2 =MB(cosθ1−cosθ2)
where B= magnetic field induction M= magnetic moment =MB(+cos0∘−cos180∘) =MB[1+1]=2MB