Consider a dipole ($\vec{p}$) in an electric field ($\vec E$) making an angle $\theta$ with the field.
We can see that $V_1-V_2=Ed\cos\theta$
In books, the derivation for the interaction energy of the dipole is given as
Interaction energy, $U=-qV_1+qV_2$
$\implies U=-q(V_1-V_2)$
$\implies U=-qEdcos\theta$
$\implies U=-pEcos\theta$
$Hence, U=-\vec{p}.\vec{E}$
We know that interaction energy of the dipole by definition means that the work done by the external agent in assembling the dipole in the electric field.
Suppose there is a uniform electric field $\vec{E}$ in the space.
The work done in placing the charge $-q_1$ at the position where potential due to electri field is $V_!$ is $-qV_1$
The work done in placing the charge $+q$ at a distance $d$ from $-q$ charge at angle $\theta$ with electric field is $q$(potential due to electric field + potential due to -q)
Work done in placing $+q$ charge is $q(V_2-\frac{kq_1}{d}$.
So, net interaction energy, $U=$ Work done in placing $-q$ and $+q$ charge in electric field $E$.
$\implies U=-qV_1+qV_2-\frac{kq_1}{d}$
$\implies U=-q(V_1-V_2)-\frac{kq_1}{d}$
$\implies U=-\vec{p}.\vec{E}-\frac{kq_1}{d}$
I am not able to understand why I get extra $-\frac{kq_1}{d}$ term in $U$. If we go by the basic definition of interaction energy, then I get different expression as that given in books.
Why this is so? What is the mistake in my derivation.
Please clarify the doubt.