Continuosly differentation on composite functions Let $f: \mathbb{R}\rightarrow\mathbb{R}$ a $C^1$ function and defined $g(x) = f(\|x\|)$.
Prove $g$ is $C^1$ on $\mathbb{R}^n\setminus\{0\}$. Give an example of $f$ such that $g$ is $C^1$ at the origin and an exemple of $f$ such that $g$ is not. Find a necessary condition in $f$ for $g$ to be differentiable at the origin. Thanks in advance!
 A: It is clear that $g$ is $C^1$ on $\mathbb{R}^n\backslash\{0\}$ as $x\mapsto \|x\|$ is also $C^1$ there. The derivative is given by
$$\nabla g(x)=\frac{x}{\|x\|} f^\prime(\|x\|)$$
for $x\not=0$.
Now let us investigate differentiability at $g$. For a real number $h\not=0$ we have
$$\frac{1}{h}(g(he_i)-g(0))=\frac{1}{h}(f(h)-f(0))\longrightarrow f^\prime(0)$$
as $h\rightarrow 0$. Therefore $\partial_i g(0)$ exists for every $i=1,\dots,n$ and is given by
$$\partial_i g(0) = f^\prime(0)$$
In other words, $g$ is differentiable at $0$. But to be $C^1$ at $0$ we still need continuity. That is, if $x^{(n)}\rightarrow 0$ for a sequence $(x^{(n)})_n$ in $\mathbb{R}^n$ (let us assume that $x^{(n)}\not=0$), we want
$$\frac{x_i^{(n)}}{\|x^{(n)}\|}f^\prime(\|x^{(n)}\|)\longrightarrow f^\prime(0)$$
as $n\rightarrow\infty$ for all $i=1,\dots,n$. This can only be true if $f^\prime(0)=0$. To see that, look for example at the sequence $x^{(n)}_i=-\frac{1}{n}$.
Therefore your necessary condition is 
$$f^\prime(0)=0$$
Clearly, it is also sufficient.
