I ran into this little problem somewhere online:
If $g(x) = f(f(x)) = x^2 - x + 1$, what is $f(0)$?
Plugging first $x=1$ and then $x=0$ into the identity $g(f(x)) = f(g(x))$, it is not hard to see that $f(0) = f(1) = 1$.
But that made me wonder: what else can we really say about $f$. Does $f$ have to be symmetric (around $x = \dfrac{1}{2}$) as $g$ is? Does it have to be continuous?
If $f$ is assumed to be differentiable, the chain rule gives us $f'(0) = -1$ and $f'(1) = 1$, so $f$ is tangent to $g$ in those points. And it would make sense if $f(x) \sim x^\sqrt{2}$ since $g(x) \sim x^2$, as $|x| \rightarrow \infty$. But I don't know how to prove something like this.
I'm aware that if $f(f(x)) = x$, there are many different choices for $f$, including discontinuous ones (e.g. $f(x) = 1 / x$ for $x\neq 0, f(0)=0$). But I find it hard to have intuition about the constraints on $f$ given $g(x) = x^2 - x + 1$...
Edit: Perhaps we should start with a simpler example, say $g(x) = x^4$. Then obviously $f(x) = x^2$ is a solution, and so is $f(x) =\dfrac{1}{x^2}$. Are there other solutions?
Edit 2: Ok apparently this is super hard: http://reglos.de/lars/ffx.html contains large number of references, and remarks that "it remains an often extremely difficult task to find the iterative roots of even very simple functions", so I'm not really expecting any conclusive answer below..