I want to calculate
$\nabla\cdot(\frac{\hat{r}}{r^2})$
Naively applying the expression for divergence in spherical coordinates gives
$\nabla\cdot(\frac{\hat{r}}{r^2})=\frac{1}{r^2}\frac{\partial}{\partial r}(r^2 *\frac{1}{r^2})=\frac{1}{r^2}\frac{\partial}{\partial r}(1)=0$
However, based on the context in which this problem arose, I believe there should be a delta function. You can get this by noticing:
$\nabla^2\frac{1}{r}=\nabla\cdot(\nabla\frac{1}{r})=-\nabla\cdot (\frac{\hat{r}}{r^2})$
Thus
$\nabla\cdot(\frac{\hat{r}}{r^2})=-\nabla^2\frac{1}{r}=4\pi\delta(\vec{r})$
Can anyone point out where the error is? I suspect there is an issue cancelling out the $r^2$ in the first method due to that covering up the zero-in-denominator issue, but I would like to understand precisely what goes wrong.