Take $f: \mathbb{R}^{n}\rightarrow \mathbb{R}, f\geq0 \ \forall x \in \mathbb{R}^{n}$. A statement in an exercise claims the following:
given an $x' \in \mathbb{R}^{n}$, let $\hat{x}$ be the point closest to $x'$ satisfying $f(\hat{x})=0.$ if $f$ is continuously differentiable, then the gradient $\bigtriangledown f(\hat{x})$ always points in the same direction as $x' - \hat{x}$.
This appears wrong to me as if $f \geq 0\ \forall x$, then $\bigtriangledown f(\hat{x}) = 0$. And even if we removed the condition $f \geq 0 \ \forall x$, taking $n=1, f=x$ with $x'=-1$ and $\hat{x}=0$ is a simple counter example. Am I missing something?
You are right, and your counterexamples show it. The claim in the exercise is false.