Finding a pair of functions with properties

I need to find a pair of functions $f$, $g$ such that

  1. $f$ is not differentiable at $x = 0$

  2. $g$ is not differentiable at $f(0)$

  3. $g \circ f$ is differentiable at $x = 0$

I’ve tried a lot of functions but just can’t seem to find ones that work. Any help would be appreciated, thank you.

Solutions Collecting From Web of "Finding a pair of functions with properties"

The first condition suggests $f(x)=|x|$ as a relatively simple example. Then $g(x)=x-|x|$ is also not differentiable at $x=f(0)=0$, and $(g\circ f)(x)=|x|-|x|$ is identically zero, so it is certainly differentiable at $x=0$.

Borrowing from this answer:

$$f(x)=\begin{cases} x+1 & x\in\mathbb Q\\ x& x\notin\mathbb Q\end{cases}$$

$$g(x)=\begin{cases} x-1 & x\in\mathbb Q\\ x& x\notin\mathbb Q\end{cases}$$

These functions are inverses of each other and nowhere continuous, ergo nowhere differentiable.

Their composition is the identity which is differentiable everywhere.

$$ f(x) = g(x) = \begin{cases} \frac{1}{x} & x \neq 0 \\ 0 & x=0 \end{cases}, $$
if you don’t mind lack of continuity.