compose two functions to make them differentiable

Are there two continuous functions ( $f:R^n\to R$, $g:R\to R$ ) which are not differentiable at point $0$, but if you compose them, $h=g(f(x))$ is differentiable at $0$? ($f(0)=0$)

-
f is not differentiable in 0, and g is not differentiable in 0 (and f(0) = 0, so it's actually the same :-) – Tass Apr 1 '11 at 20:56
Thank you. I'll delete my now irrelevant comments. – Jonas Meyer Apr 2 '11 at 4:18

Let $f(x)=x$ when $x \ge 0$, and $f(x)=0$ when $x<0$. Let $g(x)=x$ when $x\le 0$, and $g(x)=0$ when $x>0$.

Then $g(f(x))$ is identically 0, and indeed so is $f(g(x))$.

-

Let $f(x)=2x$ for $x\ge 0$ and $f(x)=x$ for $x\le 0$, and let $g$ be its inverse, given by $g(x)=x/2$ for $x\ge 0$ and $g(x)=x$ for $x\le 0$, so $g(f(x))=x$, but neither $g$ nor $f$ is differentiable at $0$.

-
Really good answer, but I like the one of user6312 better, due to its simplicity :-) – Tass Apr 3 '11 at 20:53

Let $f:\mathbb{R}^n\to\mathbb{R}$ be defined by $f(x)=\sqrt{x_1^2+x_2^2+\cdots+x_n^2}$, and let $g:\mathbb{R}\to\mathbb{R}$ be defined by $g(x)=x$ if $x<0$ and $g(x)=0$ if $x\geq 0$. Then $f$ and $g$ are continuous everywhere, not differentiable at $0$, $f(0)=0$, and $g(f(x))=0$ for all $x$.

For example, $f(x)=|x|$ when $n=1$. Note that $g(x)=-x^-$ is minus the "negative part" of $x$, which could also be written as $g(x)=\frac{1}{2}(x-|x|)$.

-