\[\phi\]
is given by \[\phi =\frac{1}{4 \pi \epsilon_0} \frac{q}{r^2}\]
\[P\]
is given by\[\begin{equation} \begin{aligned} \phi &= \frac{1}{4 \pi \epsilon_0} \frac{q}{\sqrt{x^2 +y^2 +(z-d/2)^2}} - \frac{1}{4 \pi \epsilon_0} \frac{q}{\sqrt{x^2 +y^2 +(z+d/2)^2}} \\ &= \frac{q}{4 \pi \epsilon_0} (\frac{1}{\sqrt{x^2 +y^2 +(z-d/2)^2}} - \frac{1}{\sqrt{x^2 +y^2 +(z+d/2)^2}} ) \\ & \simeq \frac{q}{4 \pi \epsilon_0} (\frac{1}{\sqrt{x^2 +y^2 +z^2-zd}} - \frac{1}{\sqrt{x^2 +y^2 +z^2+zd}} ) \\ & \simeq \frac{q}{4 \pi \epsilon_0} (\frac{1}{r} \frac{1}{\sqrt{1-zd/r}} - \frac{1}{r} \frac{1}{\sqrt{1+zd/r}} ) \\ & \simeq \frac{q}{4 \pi \epsilon_0} (\frac{1}{r} ((1+zd/2r) - (1-zd/2r)) \\ &= \frac{1}{4 \pi \epsilon_0} \frac{q}{r} \frac{zd}{r}=\frac{qzd}{4 \pi \epsilon_0 r^2} \end{aligned} \end{equation}\]
Define the magnetic dipole
\[p=qd\]
and note that \[z=r \cos \theta\]
to give\[\begin{equation} \begin{aligned} \phi &= \frac{pr \cos \theta}{4 \pi \epsilon_0 r^2} \\ &= \frac{\mathbf{p} \cdot \mathbf{r} }{4 \pi \epsilon_0 r^2} \end{aligned} \end{equation}\]