TITLE: $f\colon\mathbb{R}\to\mathbb{R}$ such that $f(x)+f(f(x))=x^2$ for all $x$?
QUESTION [22 upvotes]: A friend came up with this problem, and we and a few others tried to solve it.  It turned out to be really hard, so one of us asked his professor.  I came with him, and it took me, him and the professor about an hour to say anything interesting about it.
We figured out that for positive $x$, assuming $f$ exists and is differentiable, $f$ is monotonically increasing.  (Differentiating both sides gives $f'(x)*[\text{positive stuff}]=2x$).  So $f$ is invertible there.  We also figured out that f becomes arbitrarily large, and we guessed that it grows faster than any linear function.  Plugging in $f{-1}(x)$ for $x$ gives $x+f(x)=[f^{-1}(x)]^2$.  Since $f(x)$ grows faster than $x$, $f^{-1}$ grows slower and therefore $f(x)=[f^{-1}(x)]^2-x\le x^2$.
Unfortunately, that's about all we know...  No one knew how to deal with the $f(f(x))$ term.  We don't even know if the equation has a solution.  How can you solve this problem, and how do you deal with repeated function applications in general?

REPLY [6 votes]: I have a strategy to prove that there is such a function $f$ from $[0,2] \to [0,2]$. Intriguingly, it visually appears that this function may be unique!
Let $S$ be the square $[0,2] \times [0,2]$. Define $\sigma : S \to S$ by $\sigma: (x,y) \mapsto (\sqrt{x+y}, x)$. 
Let $f$ be any strictly increasing function $[0,2] \to [0,2]$ and let $\Gamma$ be the graph of $f$.
Lemma: The function $f$ obeys the required recursion if and only if $\sigma(\Gamma) = \Gamma$. 
Proof: Suppose that $f$ obeys the required recursion. We first check that $\sigma(\Gamma) \subseteq \Gamma$. Let $(x,f(x)) \in \Gamma$. Since $f$ is stricty increasing, there is some $x' \in [0,2]$ with $f(x') = x$. Then $f(x') + f(f(x'))= (x')^2$ or $x+f(x)=(x')^2$, so $x' = \sqrt{x+f(x)}$ and $f(x') = x$. We see that $\sigma(x,f(x)) = (x', f(x')) \in \Gamma$ as desired. 
We now check that $\Gamma \subseteq \sigma(\Gamma)$. Again, let $(x,f(x)) \in \Gamma$. Then we similarly have $\sigma(f(x), f(f(x)) )=(x,f(x))$.
Finally, suppose that $\sigma(\Gamma) = \Gamma$ for some increasing $f$. Then, for any $x \in [0,2]$, we would have $(x,f(x)) = \sigma(y, f(y))$ for some $y$. But then $y=f(x)$ and $x = \sqrt{y+f(y)}$, or $x = \sqrt{f(x)+f(f(x))}$ as desired. $\square$
So we need to find a path $\Gamma$, which is a graph of an increasing function, and is taken to itself by $\sigma$. A clearly necessary condition is that $\Gamma \subset \sigma^k(S)$ for every $k$.
Here is a plot of $\sigma^k(S)$ for $k=0$, $1$, ..., $6$.

Each $\sigma^k(S)$ is bounded between the graphs of two piecewise smooth functions, and they even appear to by Lipshcitz with a uniform constant for $k\geq 1$. My intuition is that, in that case, there always must exist a path between them. I haven't figured out how to make this precise yet; I'm posting in case someone else knows.
The really nifty thing is that it looks like $\bigcap_k \sigma^k(S)$ might itself be a path! In which case $f$ is unique! I 'm putting up this image now, to try to excite people into proving this.