When a dipole is placed in external electric field it experiences a torque $$\vec \tau = \vec p \ \times \vec E $$ whose magnitude is $$||\vec \tau|| = ||\vec p|| \cdot ||\vec E|| \cdot sin\theta$$ On calculating the potential energy: $$W=-\Delta U$$ $$\therefore W = -\int pEsin\theta\cdot d\theta $$ Which gives: $$W = pEcos\theta$$ But its wrong and is given as $-pEcos\theta$ in many text books. Please Explain.
Let me start from the beginning
Wnet = $\Delta$K.E
Wconservative+Wnon-conser.+Wexternal = $\Delta$K.E
Wnon-conser. = Zero [No non-conservative force is acting ]
$\Delta$K.E = zero [Assumption here is that the dipole is rotated very slowly therefore change amounts to zero]
Therefore the equation reduces to
-Wconservative = Wexternal
-d(Wconservative) = $\Gamma$*d$\theta$
-$\int$d(Wconservative) = $\int$ $\Gamma$*d$\theta$
-Wconservative = $\int$ p*E sin$\theta$ d$\theta$
-Wconservative = p*E $\int$ sin$\theta$ d$\theta$
-Wconservative = p*E(-cos$\theta$)
$\Delta$U = -p*E cos$\theta$ [ Work done by conservative force is negative of change in potential energy of system.]
It would make sense to integrate having definite limits then comparing the equations on both sides to understand what the potential of the dipole at and angle would be, I haven't done that in hopes that you can carry it from here(that is if you want it as such). Either way the result would be the same.