Potential due to a continuous charge distribution on ring 
Derive the formula for the potential at point $P(0,0,z)$ directly above the center of a ring of charge with radius $R$ and uniform charge density $\lambda$. 

My attempt:
Since $$\lambda= \frac{Q}{R}=\frac{dq}{2\pi R}$$, I derived $$dV=\frac{1}{4\pi\epsilon}\frac{\lambda 2\pi R}r$$. But from here, I don't how to fit P into my formula, do I replace r with z?
Thank you for the help!
 A: One way of doing is parametrizating a ring. For instance, this is a ring: $\gamma(t) = R(\cos t, \sin t)$. Actually it is a circunference of radius $R$. It is charged with linear density $\lambda$.
The potential in the point $P(0, 0, z)$ is 
$$dV = \frac{kdq}{r} = \frac{k\lambda d\gamma}{r}$$
where $r$ is the distance between an element of charge $dq$ and $P$. Since $dq$ is located at the ring $\gamma$, we have: $r = |P - \lambda(t)| = |(R\sin t, R\cos t, -z)| = \sqrt{R^2 + z^2}$.
Therefore, integrating all over the ring, the potential: 
$$
V(z) = \int_\gamma \frac{k\lambda d\gamma}{|P - \lambda(t)|} = 
\int_0^{2\pi} \frac{k\lambda}{\sqrt{R^2 + z^2}}Rdt
$$
Now the problem reduces to solve this integral, which is very trivial as you can see:
$$
V(z) = \int_0^{2\pi} \frac{k\lambda R}{\sqrt{R^2 + z^2}}dt = 
\frac{k\lambda R}{\sqrt{R^2 + z^2}}\int_0^{2\pi} dt = 
\frac{k\lambda R}{\sqrt{R^2 + z^2}} 2\pi
$$
Since $2\pi R$ is the length of the ring, we have: $2\pi R\lambda = Q$. Therefore:
$$
V(z) = \frac{kQ}{\sqrt{R^2 + z^2}}
$$
A: The ring can be parameterized by ${\bf r}' = R \left(\cos \theta \ \hat{\bf x} + \sin \theta \ \hat{\bf y}\right)$. Noting that
$$
\left|d{\bf r}'\right| = R d\theta \left|\left(-\sin \theta \ \hat{\bf x} + \cos \theta \ \hat{\bf y}\right)\right| = R d\theta
$$
and
$$
{\bf r} - {\bf r'} = \left(x-R\cos\theta\right) \ \hat{\bf x} + \left(y-R\sin\theta\right) \ \hat{\bf y} + z \ \hat{\bf z},
$$
the potential at ${\bf r} = x \ \hat{\bf x} + y \ \hat{\bf y} + z \ \hat{\bf z}$ is
$$
\begin{eqnarray}
\phi\left({\bf r}\right) &=& k \int \left|d{\bf r}'\right| \frac{\lambda\left({\bf r}'\right)}{\left|{\bf r} - {\bf r'}\right|} \\
\phi\left(x,y,z\right) &=& k \lambda R \int_0^{2\pi} d\theta \frac{1}{\left[\left(x-R\cos\theta\right)^2 + \left(y-R\sin\theta\right)^2 + z^2\right]^{1/2}}
\end{eqnarray}
$$
For the specific case $x=y=0$,
$$
\begin{eqnarray}
\phi\left(0,0,z\right) &=& k \lambda R \int_0^{2\pi} d\theta \frac{1}{\left(R^2 + z^2\right)^{1/2}} \\
&=& \frac{k Q}{\left(R^2 + z^2\right)^{1/2}}
\end{eqnarray}
$$
with $Q = 2 \pi R \lambda$ the total charge.
