Let $f$ and $g$ be functions $\mathbf{R}^3\to\mathbf{R}$. Assume $f$ is differentiable and $f'(\mathbf{x})=g(\mathbf{x})\mathbf{x}$. Show that $f$ is constant on spheres centered at the origin. (Different spheres with different constants.) (The opposite direction is well-known, if $f$ is constant on spheres then $f'$ is perpendicular to the surface so that $f'(\mathbf{x})\parallel \mathbf{x}$.)
What I tried: consider the sphere $||\mathbf{x}||=c$. I have to show that $f(\mathbf{x}_1)-f(\mathbf{x}_2)=0$. I tried to estimate this difference by the definition of differential with error term, or Lagrange mean value theorem, but I couldn't prove that it is zero.