# Doubt about the relation $\nabla\cdot\mathbf{E}=\rho/\epsilon_0$

There is this simple relation that is easy to prove in electrodynamics that is: $\nabla \cdot \mathbf{E} = \frac {\sigma}{\epsilon_0}$. But when I use the divergence on an electrical field in a problem I don't get this relation, I get $\frac {Q}{\epsilon_0}$, here's an example:

The eletrical field on a point outside an eletrical charged espherical shell (with radius R, and charge density $\sigma$) is, in espherical coordinates: $\mathbf{E} = \frac {R^2 \sigma} {\epsilon_0 r^2}$. So, if you take the divergence on both sides you get: $$\nabla \cdot \mathbf{E} = 4\pi \frac { R^2 \sigma}{\epsilon_0} = \frac {Q}{\epsilon_0}$$

Where did I get it wrong? I don't understand where my error is.

• Please be so kind as to properly typeset your question. – ZeroTheHero Feb 11 '18 at 15:23
• Really sorry, I'm searching for a FAQ on how to write the equations properly. – Tandeitnik Feb 11 '18 at 15:32
• – AccidentalFourierTransform Feb 11 '18 at 15:37
• I can't see your $\vec\nabla\cdot \vec E$ being correct: the divergence of $1/r^2$ is not constant and moreover you need to include the direction of $\vec E$ in your expression for the field. – ZeroTheHero Feb 11 '18 at 16:04
• You're calculating the divergence incorrectly. See: divergence in spherical coordinates. Also, you need to pay attention to what the electric field does inside the conductor, too. – Sean E. Lake Feb 11 '18 at 16:06

If you take the divergence of the electric field outside the sphere, i.e. $r \gt R$, you will get get everywhere $$div \vec E=0$$ because the volume charge density $\rho=0$. You can also see this by expressing the divergence of $\vec E$ in cartesian coordinates $$\vec E=const \frac {\vec r}{|\vec r|^3}$$ $$\frac {\partial E_x}{\partial x}+\frac {\partial E_y}{\partial y}+\frac {\partial E_z}{\partial z}=0$$ for $r \gt R$.
PS: As @Sean E. Lake has rightly pointed out, for this Coulomb field its even easier to see this using the divergence in polar coordinates $$div \vec E =\frac {1}{r^2}\frac{\partial (r^2 E_r)}{\partial r}$$