TITLE: For differentiable functions $f,g$, $\nabla f(x)=g(x)x$. Then $f$ is constant on S.
QUESTION [6 upvotes]: Problem saying that :

$f:\mathbb{R}^{n}\rightarrow\mathbb{R}$   is differentiable. Assume
  that there is a differentiable function
  $g:\mathbb{R}^{n}\rightarrow\mathbb{R}$   such that $\nabla
 f(x)=g(x)x$  . Show that $f$   is constant on
  $S=\{x\in\mathbb{R}^{n}:||x||=r\}$   where $r$   is positive constant.

For $x=(x_1,\dots ,x_n)$ and $\nabla f=(\frac{\partial f}{\partial x_{1}},\dots,\frac{\partial f}{\partial x_{n}})$, problem says $\frac{\partial f}{\partial x_{i}}=g(x)x_{i}$. It seems to me that to solve this problem, knowing the relation between norm of gradient and its value is crucial. How can I do?
Notification : This question is edited since it's about same problem and the former one is about just notation.

REPLY [4 votes]: Note that $f$ is constant on a sphere $S$ of radius $r$ iff for any curve $c :(-\epsilon,\epsilon)\rightarrow S$, $f\circ c(t)=C$ for all $t$ iff $ \frac{d}{dt} (f\circ c)(t)=0$
If $c$ is a curve on the sphere so $|c(t)|=r$ Then $$ c'(t)\cdot c(t)=0 $$
Hence \begin{align} \frac{d}{dt} f\circ c(t) &=\nabla f\cdot c' \\
 &= g(c(t))c(t)\cdot c'(t) =0 \end{align}
That is $f$ is constant on the curve. 
(And note that gradient of $f$ is radial direction That is hypersurface, which is level surface of $f$, has unit normal of radial direction. Such kind of hypersurface is a sphere.)