The external electric field E and the corresponding external potential V may vary from point to point.
In a uniform electric field, the dipole experiences no net force; but experiences a torque τ given by
τ = p x E
which will tend to rotate it (unless p is parallel or antiparallel to E.
The amount of work done by thee xternal torque will be given by
Taking θ0 as 90° and θ1 as θ, potential energy,
U(θ) = -p.E = - pEcosθ
Work done in bringing a charge q from infinity to the point P in the external field is qV.
This work is stored in the form of potential energy of q.
If the point P has position vector r relative to some origin, we can write:
The potential energy of q at r in an external field
where V(r) is the external potential at the point r.
Work done in bringing the charge q1 from infinity to r1 is q1 V(r1). Consider work done in bringing q2 to r2.In this step, work is done not only against the external field E but also against the field due to q1.
Work done on q2 against the external field
= q2V (r2)
Work done on q2 against the field due to q1
where r12 is the distance between q1 and q2.
By superposition principle for fields, add up the work done on q2 against the two fields. Work done in bringing q2 to r2.
Thus, the potential energy of the system
= the total work done in assembling the configuration