# A continuous function composed with itself [duplicate]

Is there a continuous function $f\colon \mathbb{R}\to \mathbb{R}$ such that $f(f(a)) = -a$ for every $a \in \mathbb{R}$?

• Yes, $f(x) = -a$ for all $x$. – mathworker21 Apr 1 '17 at 18:52
• I'm afraid you are wrong, this is not a good example. Let $a=1$, so $f(x)=-1$ for all $x$. Then, of course, $f\bigl(f(x)\bigr)=-1$, but, for instance, $f\bigl(f(1)\bigr)\ne -2$. – szw1710 Apr 1 '17 at 19:22
• @JannanLim: does not an acceptable practice here, please do not change a question after it has an answer. Ask a new new question instead. I have reverted the edit. – Martin Argerami Apr 2 '17 at 14:17
• That duplicate target has a more general question, but this is covered there as a special case. – Jyrki Lahtonen Nov 19 at 18:28

If $$f(a)=f(b)$$, then $$a=-f(f(a))=-f(f(b))=b$$. So $$f$$ is injective. Being continuous, it is then either increasing or decreasing.
Note that the function $$g(x)=-x$$ is decreasing. Now,
• if $$f$$ is increasing, then $$f(f(x))$$ is also increasing, so $$f(f(x))$$ cannot equal $$g$$;
• if $$f$$ is decreasing, the composition of two decreasing functions is increasing, so $$f(f(x))$$ cannot equal $$g$$.
• If we modified the domain/range of $f$ would it be possible? – Kitter Catter Nov 6 at 18:58
• If you let the domain be $\{0\}$, then $f(x)=0$ satisfies the property. Otherwise, you need the domain to be of the form $[-b,b]$ (because you need $a$ in the domain, $-a$ in the range, and the range inside the domain for the composition to make sense) and the same answer applies. – Martin Argerami Nov 6 at 19:05