
Potential at origin O, the potential due to two charges is given by
V0=4πϵ0(2d)4q+4πϵ0(2d)(−q)=4πϵ0d6q
Potential at P at a distance, x=d is given by
VP=4πϵ0(23d)4q+4πϵ0(2d)(−q)=6πϵ0dq
Change in potential energy due the charge motion of charge q is given by
ΔU=qΔV=q(Vf−Vi)
⇒ΔU=q(VP−VO)
ΔU=q(6πϵ0dq−2πϵ0d3q)=−3πϵ0d4q2