Problem on taking the gradient of a composition of functions

Suppose $f(x,y) = g(x^2 + y^2)$ for some single-variable function $g$. Show that the gradient of $f$ at any point $(x,y)$ is always pointing toward or away from the origin.
• Solution

Recall that
To compute the partial derivatives, recall
To find $\partial_x f$ and $\partial_y f$, we can use the single-variable chain rule: \begin{align}
\partial_x f(x,y) &= g'(x^2+y^2) \ 2 x\\
\partial_y f(x,y) &= g'(x^2+y^2) \ 2 y\end{align} where $g'$ is the one-dimensional derivative of $g$.
This vector is a scalar multiple of $x \ \mathbf{i} + y \ \mathbf{j}$, which points from the origin to the point $(x,y)$. If $g' \gt 0$ then, the gradient points away from the origin. If $g' \lt 0$, then the gradient points toward the origin.