(N/A) The potential energy of a system of two charges $q_1$ and $q_2$ at positions $\vec{r}_1$ and $\vec{r}_2$ in an external field $\vec{E}$ is given by:
$U = q_1 V(\vec{r}_1) + q_2 V(\vec{r}_2) + \frac{k q_1 q_2}{r_{12}}$
For an electric dipole,we have $q_1 = +q$ and $q_2 = -q$. Let the separation between them be $\vec{d} = 2\vec{a}$. The potential energy becomes:
$U = q V(\vec{r}_1) - q V(\vec{r}_2) - \frac{k q^2}{2a}$
The term $q[V(\vec{r}_1) - V(\vec{r}_2)]$ represents the work done in moving the dipole in the external field. Since $V(\vec{r}_1) - V(\vec{r}_2) = -\vec{E} \cdot \vec{d} = -E(2a \cos \theta)$,
$q[V(\vec{r}_1) - V(\vec{r}_2)] = -q(2a)E \cos \theta = -pE \cos \theta = -\vec{p} \cdot \vec{E}$
Thus,the potential energy is:
$U(\theta) = -\vec{p} \cdot \vec{E} - \frac{k q^2}{2a}$
The term $-\frac{k q^2}{2a}$ is the self-energy of the dipole,which is constant. By choosing the reference potential energy to be zero at $\theta = \frac{\pi}{2}$,we obtain the standard expression:
$U = -\vec{p} \cdot \vec{E}$