# If $f\circ f$ is smooth, is the monotonic function $f$ smooth?

Let $f:\mathbb R\to\mathbb R$ be continuous and monotonic and assume that $f\circ f$ is analytic. Is $f$ necessarily continuously differentiable/smooth/analytic?

My question arose from this: Inspired by the thread a continuous function satisfying $f(f(f(x)))=-x$ other than $f(x)=-x$ I wondered if the only continuous solution to $f(f(f(x)))=-8x$ is the trivial solution $f(x)=-2x$. I can prove this if I assume that $f$ is continuously differentiable everywhere, but is that condition necessary?

Let $g$ be any continuous strictly decreasing function on $(-\infty,0)$ such that $g(0)=0$ and $\lim\limits_{x\to -\infty}g(x)=+\infty$.
Extend to $f$ on all of $\mathbb R$ by reflecting the graph across the line $y=x$. Then $f(f(x))=x$ for all $x$, but $f$ need not be differentiable.
For an explicit example that is not differentiable at $0$, let $f(x)=x^2$ if $x\leq 0$, $f(x)=-\sqrt{x}$ if $x\geq 0$.