TITLE: How to solve $f(f(x)) = \cos(x)$?
QUESTION [116 upvotes]: I found the following equation on some web page I cannot remember, and found it interesting:
$$f(f(x))=\cos(x)$$
Out of curiosity I tried to solve it, but realized that I do not have a clue how to approach such an iterative equation except for trial and error. I also realized that the solution might not be unique, from the solution of a simpler problem
$$f(f(x)) = x$$
which has, for example, solutions $f(x) = x$ and $f(x) = \frac{x+1}{x-1}$.
Is there a general solution strategy to equations of this kind? Can you perhaps point me to some literature about these kind of equations? And what is the solution for $f(f(x))=\cos(x)$ ?

REPLY [7 votes]: This does not directly answer the question, which concerned iterative roots on the real axis. However, I have also seen complex solutions mentioned in some of the discussions, so it seems relevant to mention the following.
Baker (in "The iteration of entire transcendental functions and the solution of the functional equation f{f(z)} = F(z)") proves the following.
Theorem 1. If $F(z)$ is an entire function of finite order bounded on some continuous curve $\Gamma$ which extends to infinity, then the functional equation $f\{f(z)\} = F(z)$ has no entire solution.
Recall that finite order means that $\log_+ \log_+ |F(z)| = O(\log|z|)$ as $z\to\infty$. Of course, $\cos$ has order $1$, and is bounded on the real axis. So the equation $f(f(z)) = \cos(z)$ has no analytic solution defined on the entire complex plane. 
Baker's argument is beautifully simple: Firstly, it is well-known that the composition of two functions of positive order cannot have finite order, so any such solution $f$ would have order zero. Now, either $f$ is itself bounded on $\Gamma$, or $f(\Gamma)$ is unbounded and $f$ is bounded on $f(\Gamma)$. In either case, $f$ is bounded on an unbounded connected set. But it is well-known that this is impossible for functions of order less than $1/2$.