Consider the charges q1 and q2 initially at infinity and determine the work done by an external agency to bring the charges to the given locations.
Suppose, charge q1 is brought from infinity to the point r1. There is no external field against which work needs to be done, so work done in bringing q1 from infinity to r1 is zero. This charge produces a potential in space given by
where r1P is the distance of a point P in space from the location of q1.
From the definition of potential, work done in bringing charge q2 from infinity to the point r2 is q times the potential at r2 due to q1:
where r12 is the distance between points 1 and 2.
If q1q2 > 0, Potential energy is positive. For unlike charges (q1 q2 < 0), the electrostatic force is attractive.
Potential energy of a system of three charges q1, qand q located at r1, r2, r, respectively. To bring q first from infinity to r1, no work is required. Next bring q2 from infinity to r2. As before, work done in this step is
The total work done in assembling the charges at the given locations is obtained by adding the work done in different steps,
The potential energy is characteristic of the present state of configuration, and not the way the state is achieved.