# If we have two functions that have composition differentiable does it mean both are differentiable?

If $f : \mathbb{R}^{n} \rightarrow \mathbb{R}^m$ and $g : \mathbb{R}^m \rightarrow \mathbb{R}^p$ are functions such that $g \circ f$ differentiable does it mean both are differentiable ? I just need this for differential geometry. Suppose I know the following fact $proj : \mathbb{R}^m \rightarrow \mathbb{R}$ and $u : \mathbb{R}^n \rightarrow \mathbb{R}^m$ where $proj \circ u$ is differentiable does it mean that u is differentiable ? Here proj is the regular projection function.

• Take $f$ any function and $g=0$. Oct 2, 2016 at 0:24
• when what I said holds ?
– user111750
Oct 2, 2016 at 0:26
• As Aloizio notes, you need to impose more conditions on $f$ and $g$ to get something interesting. Oct 2, 2016 at 0:27
• @Adeek: It would be good to ask your edited question (I suspect you mean to ask whether, if the coordinate projections of $u$ are all differentiable, is $u$ itself differentiable) as a separate question rather than edit here. The difference is large enough that the existing answers don't do much to answer the amended question. Oct 2, 2016 at 6:29
• Seconding @HenningMakholm 's suggestion. I note that you have accepted an answer to your original question that does not answer the new one. Please revert this one to the way it was, leave it here since it's interesting, and ask the new one as a new question. Oct 2, 2016 at 18:52

No.

Let both $f$ and $g$ be the famous function that takes rational numbers to $1$ and irrational numbers to $0$. Then, since $g$ takes all numbers to rational numbers, $(f\circ g)(x) = f(g(x))=1$, which is certainly differentiable. But neither $f$ nor $g$ is continuous anywhere, much less differentiable.

• I have edited my question @rory Daulton.
– user111750
Oct 2, 2016 at 0:34
• I think it should be $f(g(x)) = 1$ since $g(x)$ is rational and $f$ takes rational numbers to $1$. Oct 2, 2016 at 9:27
• @frececroka: Oops, you are right, how embarrassing. I'll edit that now. Thanks for the correction. Oct 2, 2016 at 10:51

No, neither $f$ nor $g$ needs to be differentiable.

Take e.g. $f$ to be the sign function and take $g$ to be the absolute value function on $\mathbb{R}$.

Neither is differentiable at $x=0$, but the composition is constant $=1$.

The answer to the second question is also no: Composing e.g. $u(x, y)=(0, \left|x \right|)$ with the projection onto the first component gives the constant function $=0$.

• I have edited my question @damian Reding can you please check it.
– user111750
Oct 2, 2016 at 0:38
• What kind of sign function are you using? The one described in Wikipedia - and the one I know - has $sgn(0) = 0$. Oct 2, 2016 at 18:44
• True. Here you need $sgn(0)=1$. Oct 2, 2016 at 18:58

Just adding another fun example: $f(x)=|x|$ and $g(x)=x^2$. This is why it is often better to use $g$, a smooth funcition, as your notion of distance in contexts like linear regression.