TITLE: $f(f(f(x))) = x$. Prove or disprove that f is the identity function
QUESTION [7 upvotes]: Let $f$ be a continuous function on $\mathbb R$ satisfying the relation
$$f(f(f(x))) = x\ \text{for all}\ x \in \mathbb R$$
Prove or disprove that $f$ is the identity function.
I tried taking the derivative. From the derivative, I'm not sure about it, but I concluded it had to be of degree 1 if it is a polynomial since if it'd have been of degree 2 or higher.. there needed to be terms of $x$ in the derivative.. which are not there.

REPLY [18 votes]: You can prove that $f(x) \equiv x$ in four fairly simple steps:

Show that $f$ is one-to-one. Assume $f(x) = f(y)$ and show that this implies $x=y$ by applying $f$ two times to each side of the equation.
Show that a continuous function that is one-to-one has to be strictly increasing or decreasing. This follows for example by the mean-value theorem.
Show that $f$ cannot be strictly decreasing. If it is then $f(x) < f(y)$ for $x > y$. Now apply $f$ two times show that this gives us a contradiction ($x<y$).
Show that if $f$ is strictly increasing then $f(x) = x$. Assume 1) $f(x) > x$ and 2) $f(x) < x$ and try to derive a contradiction in both these cases (again by applying $f$ to the inequality using that $f$ is increasing).

All these points apart from the first two are covered in the answer to this question.

REPLY [3 votes]: The only solution is $f(x)=x$.  First, we note that if we have two functions $f:X\to Y$ and $g:Y\to X$ such that $f\circ g$ and $g\circ f$ are identity maps, then $f$ and $g$ must be bijective functions.  Now take $g=f\circ f$.
Further, because $f$ is continuous and bijective, it must be monotonic.  Now, you have two cases, $f$ is increasing, or $f$ is decreasing.  If $f$ is increasing and $f(x)>x$, then $x=f(f(f(x)))>f(f(x)>f(x)>x$, which is a contradiction.  The inequalities are reversed if $f(x)<x$.  If $f$ is decreasing, we have that if $x<f(x)$, then $f(x)>f(f(x))$, so $f(f(x))<f(f(f(x))=x$, and hence $x>f(x)$, which is a contradiction, and similarly if $f(x)<x$.

However, a harder and more interesting problem is asking if you can have a point with period 3.  This is impossible for polynomials with integer coefficients, but is possible for continuous functions, but when it happens, things are messy.  As shown in the paper "Period three implies chaos", if you have a point of period 3, you will have a point of every other possible order.