I am reading Modern Electrodynamics by Zangwill and cannot verify equation (1.61) [page 7]:
\begin{equation} \nabla \cdot \textbf{g}(r)=\textbf{g}^{\prime}\cdot \mathbf{\hat{r}}, \end{equation} where the vector field $\textbf{g}(r)$ is only nonzero in the radial direction.
By using the divergence formula in Spherical coordinates, I get:
\begin{align} \nabla \cdot \textbf{g}(r)&=\frac{1}{r^2} \partial_r (r^2 g_r) + \frac{1}{r \sin \theta} \partial_{\theta} (g_{\theta} \sin \theta) + \frac{1}{r \sin \theta} \partial_{\phi} g_{\phi}\\ &=\frac{2}{r}g_r + \frac{d}{dr}g_r\\ &= \frac{2}{r}\textbf{g}\cdot \mathbf{\hat{r}}+\textbf{g}^{\prime}\cdot \mathbf{\hat{r}} \end{align}
What is going wrong?
The function $\mathbf g(r)$ is not a radial vector field; it is a vector field which depends only on $r\equiv\sqrt{x^2+y^2+z^2}$. Indeed unless the vector field is the trivial $\mathbf g(r) = \vec 0$, then it cannot be radial; you can see this by noting that if $\mathbf g$ is radial, then the vectors at the north and south poles must point in opposite directions, but if $\mathbf g=\mathbf g(r)$ then the vectors at the north and south poles must be the same.