# Is there a higher-level reason why $\nabla\cdot(\hat{\bf r}/r^2) = 0$ in three dimensions but not two? [duplicate]

I am working through Griffiths, Introduction to Electrodynamics, and finding the divergence of the electric field generated by a single charge sitting at the origin.

$$\mathbf{E}(\mathbf{r}) = \frac{\hat{\bf r}}{|\mathbf{r}|^2}$$

I compute $$\nabla \cdot \mathbf{E}$$ and get 0. This seems very surprising -- I wouldn't have expected it, but the factors cancel out just so.

Sometimes, the book uses two-dimensional drawings, so I assumed that everything would be mostly the same in two dimensions. But to my surprise, it's not -- if I use only two dimensions and compute $$\nabla \cdot \mathbf{E}$$, I don't get zero.

$$\nabla \cdot \mathbf{E} = \frac{\partial}{\partial x}\left(\frac{x}{(x^2 + y^2)^{3/2}}\right) + \frac{\partial}{\partial y}\left(\frac{y}{(x^2 + y^2)^{3/2}}\right) \ne 0$$

Why is this? It seems like such a coincidence that we live in three dimensions, and three dimensions is also where this divergence works out to be zero.

Possible explanations:

• I know vaguely that the inverse square law is related to three dimensions; if I had to summarize my understanding it would be roughly "if you want conservation of energy to work out in three dimensions, you need the force to go as the inverse of the square rather than e.g. as the inverse or the inverse of the cube". Is this related?
• I don't think this relates to energy conservation, but maybe I'm missing something. Can you explain why you think energy conservation is relevant here, and why you think the inverse square law only works in 3D? Also note that for your 3D case the divergence is technically $\delta(\vec r)$. Oct 30, 2018 at 2:56
• Possible duplicates: physics.stackexchange.com/q/93/2451 , physics.stackexchange.com/q/47084/2451 and links therein. Oct 30, 2018 at 3:20