Divergence of inverse square vector field After trying to get the divergence of a vector field I got:
$${\nabla \cdot \Bigg(\frac{\vec r}{|r|^3}\Bigg)=\frac{\partial}{\partial r}.\frac{1}{r^2}=-\frac{2}{r^3}}$$
But in wikipedia found that this must be
$${\nabla \cdot \Bigg(\frac{\vec r}{|r|^3}\Bigg)=4\pi \delta(r)}$$
What is my mistake and where does my intuition get wrong?
 A: First, the divergence in spherical coordinates, expressed in terms of derivatives, would take the form
$$\nabla \cdot \vec A = \frac{1}{r^2} \frac{\partial}{\partial r} [r^2 A^r] + \ldots$$
where $A^r$ is the radial component of the vector field $\vec A$.  In this case, that's $1/r^2$, so we naively get 0 for this contribution.
Of course, this formula cannot be valid at the origin (there's a $1/r^2$ in it), so we resort to an alternative definition of divergence, one that is regular at the origin:
$$\nabla \cdot \vec A |_{\vec 0} = \lim_{\delta r \to 0} \frac{1}{4 \pi (\delta r)^3/3} \int_0^{2\pi} \int_0^\pi \vec A \cdot \hat r \, (\delta r)^2 \, \sin \theta \, d\theta \, d\phi$$
This basically follows from the divergence theorem and is a general alternative definition for divergence that eschews derivatives.  It also can be done with curl and gradient instead.  The limit process, of course, makes this entirely equivalent to a derivative.
Evaluating this definition for $\vec A = \hat r/r^2$ at $r = \delta r$ (as we're integrating over a sphere of this radius, and then taking the limit) gives
$$\left. \nabla \cdot \left( \frac{\hat r}{r^2} \right) \right|_{\vec 0} = \lim_{\delta r \to 0} \frac{3}{\delta r} $$
which obviously diverges (positively, as negative radii have no meaning).
So this is a vector field whose divergence is zero everywhere except the origin, where its divergence...well, diverges.  That all certainly sounds like a delta function.
Typically, one uses the divergence theorem directly to verify the stated condition of the delta function: that its integral over any region containing zero is 1.  That is, we do
$$4\pi \int_0^r \nabla \cdot \frac{\hat r}{r^2} r^2 \, dr= \int_0^{2\pi} \int_0^\pi \frac{\hat r}{r^2} \cdot \hat r r^2 \sin \theta \, d\theta \, d\phi$$
If $\nabla \cdot \hat r/r^2 = 4 \pi \delta$, then the surface integral on the left should evaluate to $4\pi$ (which it does, obviously).  This is not 100% formally sound, but you can always check this by integrating against a test function (a scalar field would do), just as you would in 1d.
A: A common way to show that $\nabla \cdot \left(\frac{\hat r}{r^2}\right)=4\pi \delta (\vec r)$ is to regularize the function $\left(\frac{\hat r}{r^2}\right)$ in terms of a parameter, say $a$.  To that end, let $\vec \psi$ be the regularized function given by 
$$\vec \psi(\vec r;a)=\frac{\vec r}{(r^2+a^2)^{3/2}} \tag 1$$
Taking the divergence of $(1)$ reveals that 
$$\nabla \cdot \vec \psi(\vec r; a)=\frac{3a^2}{(r^2+a^2)^{5/2}}$$
Now, any sufficiently smooth test function $\phi$, we have that
$$\begin{align}
\lim_{a \to 0}\int_V \nabla \cdot \vec \psi(\vec r; a)\phi(\vec r)dV&=\lim_{a \to 0}\int_V \frac{3a^2}{(r^2+a^2)^{5/2}}\phi(\vec r)dV\\\\
&=0
\end{align}$$
if $V$ does not include the origin.  
Now, suppose that $V$ does include the origin.  Then, we have
$$\begin{align}
\lim_{a \to 0}\int_V \nabla \cdot \vec \psi(\vec r; a)\phi(\vec r)dV&=\lim_{a\to 0}\int_{V-V_{\delta}} \frac{3a^2}{(r^2+a^2)^{5/2}}\phi(\vec r)dV+\lim_{a\to 0}\int_{V_{\delta}} \frac{3a^2}{(r^2+a^2)^{5/2}}\phi(\vec r)dV\\\\
&=\lim_{a\to 0}\int_{V_{\delta}} \frac{3a^2}{(r^2+a^2)^{5/2}}\phi(\vec r)dV
\end{align}$$
where $V_{\delta}$ is a spherical region centered at $\vec r=0$ with radius $\delta$.  For any $\epsilon>0$, take $\delta>0$ such that $|\phi(\vec r)-\phi(0)|\le \epsilon/(4\pi)$ whenever $0<|\vec r|< \delta$.  Then, we have
$$\begin{align}
\lim_{a \to 0}\left|\int_V \nabla \cdot \vec \psi(\vec r; a)(\phi(\vec r)-\phi(0))\,dV\right|&\le \lim_{a\to 0} \int_{V_{\delta}} \left|\phi(\vec r)-\phi(0)\right|\frac{3a^2}{(r^2+a^2)^{5/2}}dV\\\\
&\le \left(\frac{\epsilon}{4\pi}\,4\pi\right)\,\lim_{a \to 0}\int_{0}^{\infty}\frac{3a^2}{(r^2+a^2)^{5/2}}r^2\,dr\\\\
&\le \epsilon
\end{align}$$
Thus, we have for any test function $\phi$, 
$$\begin{align}
\lim_{a \to 0}\int_V \nabla \cdot \vec \psi(\vec r; a)\phi(\vec r)\,dV&=4\pi \phi(0)
\end{align}$$
and it is in this sense that 
$$\bbox[5px,border:2px solid #C0A000]{\lim_{a\to 0} \nabla \cdot \vec \psi(\vec r;a)=4\pi \delta(\vec r)}$$
