I have a question regarding the electric field of an infinite sheet in the $x-y$-plane at $z=0$ with a constant sheet charge density $\sigma$. There are many ways to obtain the result $$\boldsymbol E=\frac{\sigma}{2\epsilon_0}\frac{z}{|z|}\boldsymbol{e_z}$$ but I can't seem to recreate this result using the divergence theorem and a cylindric volume. Maybe someone can point out an error in my thoughts: Let's assume first $\boldsymbol E=E(z)\boldsymbol{e_z}$. Then we put a cylindric volume $V$ into the sheet such that it gets cut in half and its symmetry axis is the $z$-axis. Furthermore I want this cylinder to have height $2z$ (so that the top is located at $z$ and the bottom is located at $-z$) and radius $R$. Now, by the divergence theorem we have $$\begin{equation}\int_V\text{div}\boldsymbol EdV=\int_{\partial V}\boldsymbol E\cdot\boldsymbol{dA}.\tag{1}\end{equation}$$ By the maxwell equation $\text{div}\boldsymbol E=\frac{\sigma}{\varepsilon_0}$ we easily see that the left-hand side of $(1)$ is equal to $$\frac{\sigma}{\epsilon_0}\int_VdV=\frac{\sigma}{\epsilon}V=\frac{\sigma}{\epsilon_0}\pi R^2\cdot 2z.$$ Now for the right-hand side we first need the surface elements:
- $\boldsymbol{dA}=Rd\varphi dz\boldsymbol{e_\varphi}$ for the lateral surface,
- $\boldsymbol{dA}=zrdrd\varphi\boldsymbol{e_z}$ for the top and
- $\boldsymbol{dA}=-zrdrd\varphi(\boldsymbol{-e_z})$ for the bottom.
Maybe this is already where my error is since this now means that the lateral surface cancels ($\boldsymbol{e_\varphi}\perp\boldsymbol{e_z}$) and we have $$\int_{\partial V}\boldsymbol E\cdot\boldsymbol{dA}=2zE(z)\int_0^R\int_0^{2\pi}rd\varphi dr=2\pi R^2 E(z)z$$ So here I must have lost a factor of 2 and also I don't obtain the fact that the electric field changes the direction at $z=0$. Whereas my second problem can probably be fixed by just assuming $$\boldsymbol E(z)=\begin{cases}E(z)\boldsymbol{e_z},& z> 0\\ -E(z)\boldsymbol{e_z}, &z<0\end{cases},$$ I have no idea how to fix the first problem: Where did my $2$ go?