# For which continuous functions $f:\mathbb R\to\mathbb R$ does there exist a discontinuous function $g$ such that $f=g\circ g$?

Inspired by a bad approach to a homework problem, I'm wondering for which which continuous functions $f:\mathbb R\to\mathbb R$ does there exist a discontinuous function $g$ such that $f=g\circ g$.

Maybe I'm missing something immediate, but I'd like to show that there exists no continuous functions $f$ satisfying this.

Just kidding, it's apparently immediate.

An easy example is $f(x) = x$ and $$g(x) = \begin{cases} x & \text{for } x \neq \pm 1 \\ -x & \text{for } x = \pm 1 \end{cases}.$$

For examples of a function $f$ that has no $g$ with $f = g \circ g$ (continuous or not), consider a case where $f$ has exactly one fixed point $p$ and exactly one point $q \ne p$ such that $f(q) = p$. Since $g(p)$ would have to be a fixed point of $f$, we need $g(p) = p$, and since $f(g(q)) = g(f(q)) = p$ we need $g(q) = q$. But then $f(q) = g(g(q)) = q$, contradiction.

A simple example of this is $f(x) = x + \dfrac{1-e^x}{1-e^{-1}}$ with $p =0$ and $q=-1$.

Take the dirichlet's function:

g:$\mathbb{R} \rightarrow \mathbb{R}$

g($x$)=0 ; $x\in \mathbb{Q}$

g($x$)=1 ; $x\in \mathbb{R}- \mathbb{Q}$

Then f=g$\circ$g is the zero function.

Your wording is ambiguous. You ought to include $$f(x) = -x.$$ I cannot recall, but there is a simple argument for no continuous $g.$ However, if we include complex numbers and take $$h(x) = ix,$$ we do get $$h(h(x)) = -x.$$

• Here's a discontinuous solution for $f(x) = -x$. Let $\phi$ be a (necessarily discontinuous) one-to-one map of $(0,1]$ onto $(1,\infty)$, and take $$g(x) = \cases{0 & for x=0\cr \phi(x) & for x \in (0,1]\cr -\phi(-x) & for x \in [-1,0)\cr -\phi^{-1}(x) & for x \in (1,\infty)\cr \phi^{-1}(-x) & for x \in (-\infty,-1)\cr}$$ – Robert Israel Apr 16 '17 at 20:56
• @Robert, thanks. The argument against continuous solutions over the reals was years and years ago on MO, I think by Sergei Ivanov. This was before I learned of the extensive literature, originally I. N. Baker, emphasizing complex solutions. Sergei: mathoverflow.net/questions/17605/how-to-solve-ffx-cosx/… – Will Jagy Apr 16 '17 at 21:06