Solution (source code)

= Solution

For $r=\sqrt{x^2+y^2+z^2}>0$, the <multivariable chain rule> gives $\partial_xg(r)=g'(r)x/r$, with the corresponding expressions for $y,z$. Thus the <gradient of a radial function> is
$$
\boxed{\nabla g(r)=g'(r)\frac{(x,y,z)}r=g'(r)\hat{\mathbf r},\qquad r>0}.
$$
The origin needs a separate check because $\hat{\mathbf r}$ is undefined there. If the one-variable <function> has a finite right <derivative> at zero, the radial composite is differentiable at the origin exactly when $g'(0^+)=0$, in which case its <gradient> is zero. A nonzero radial slope gives incompatible opposite-direction <derivatives>.