Integration problem in electric field I would like to evaluate the electrostatic field of a disk on its axis using the definition; I have no trouble in evaluating it considering the infinitesimals, but I would like to use the definition to have a better mathematical knowledge of the thing.
Suppose the superficial density $\sigma$ is constant, let $R$ be the radius of the disk and let $q$ the charge uniformly distribuited over the disk; I will use as reference system the axis of the disk as the $x$ axis.
So if $\sigma$ is the superficial density of charge (which is constant), and $\hat{u}$ is a versor oriented like $\vec{r}$ (which is the distance between a point on the axis and a point on the disk) we have that
$$\vec{E}(x,y)=\frac{1}{4\pi\varepsilon_0}\int_\Sigma \frac{\sigma }{r^2}\text{d}S \ \hat{u}$$
Now I have to parametrize the disk: let $\theta$ be the angle that $\vec{r}$ forms with the $x$ axis, I've chosen to parametrize it with polar coordinates $(\rho \sin \theta, \rho \cos \theta)$ with $\rho \in [0,R]$ and $\theta \in [0,2\pi)$; so I get
$$\vec{E}(x,y)=\frac{\sigma}{4\pi\varepsilon_0 r^2}\int_0^{2\pi} \left(\int_0^R \rho \text{d}\rho\right)\text{d}\theta \ \hat{u}=\frac{\sigma R^2}{4 \varepsilon_0 r^2}$$
Now by this (if it is correct, if not please tell me where are the mistakes) I would like to deduce that
$$E(x)=\pm \frac{q}{2\pi \varepsilon_0 R^2} \left(1-\frac{|x|}{\sqrt{x^2+R^2}}\right)\hat{u}_x$$
Thanks.
 A: I think you're being sloppy in a lot of ways. For example in the second line you are assuming that the distance $r$ from the source point to the field point doesn't change as we move around the source. This assumption leads to the far field of the disk, treating it like a point charge. Also your final expression should have been a vector. You could fix that by multiplying by $\hat r=\frac{\vec r}r$. What you need to do to get the near field is think about the source point $\vec r_s=\langle0,\rho\cos\theta,\rho\sin\theta\rangle$ and the field point $\vec r_f=\langle x,0,0\rangle$ so you can get the vector $\vec r=\vec r_f-\vec r_s=\langle x,-\rho\cos\theta,-\rho\sin\theta\rangle$ from the source point to the field point. Now you can get
$$\begin{align}\vec E(x)&=\frac1{4\pi\epsilon_0}\int_0^R\int_0^{2\pi}\frac{\sigma\hat r}{r^2}d\theta\,\rho\,d\rho=\frac1{4\pi\epsilon_0}\int_0^R\int_0^{2\pi}\frac{\sigma\vec r}{r^3}d\theta\,\rho\,d\rho\\
&=\frac1{4\pi\epsilon_0}\int_0^R\int_0^{2\pi}\frac{\sigma\langle x,-\rho\cos\theta,-\rho\sin\theta\rangle}{(\rho^2+x^2)^{3/2}}d\theta\,\rho\,d\rho\\
&=\frac1{4\pi\epsilon_0}\int_0^R\frac{\sigma\langle2\pi x,0,0\rangle}{(\rho^2+x^2)^{3/2}}\rho\,d\rho=-\left.\frac{\sigma\langle2\pi x,0,0\rangle}{4\pi\epsilon_0(\rho^2+x^2)^{1/2}}\right|_0^R\\
&=\frac{\sigma x\hat i}{2\epsilon_0}\left(\frac1{|x|}-\frac1{\sqrt{R^2+x^2}}\right)=\frac{qx}{2\pi\epsilon_0R^2}\left(\frac1{|x|}-\frac1{\sqrt{R^2+x^2}}\right)\hat i\end{align}$$
