I've been perusing the internet looking for interesting problems to solve. I found the following problem and have been going at it for the past 30 minutes with no success:
Find a function $f: \mathbb{R} \to \mathbb{R}$ satisfying $f(f(x)) = -x$ for all $x \in \mathbb{R}$.
I am also wondering, can we find $f$ so that is continuous?
I was thinking of letting $f$ be a periodic function, and adding half the period to x each time. I had no success with this, and am now thinking that such a function does not exist.
Source: http://www.halfaya.org/Casti/CalculusTheory2/challenge.pdf


An important piece of information is:
Theorem: $f$ is not continuous.
Proof: Observe that $f$ is invertible, because
$$f(f(f(f(x)))) = f(f(-x)) = x$$
and so $f \circ f \circ f = f^{-1}$. Any continuous invertible function on $\mathbb{R}$ is either strictly increasing or strictly decreasing.
If $f$ is strictly increasing, then:
contradiction! Similarly, if $f$ is strictly decreasing, then:
contradiction! Therefore, we conclude $f$ is not continuous. $\square$
For the sake of completeness, the entire solution space for $f$ consists of functions defined as follows:
To see that every solution is of this form, let $f$ be a solution. Then we must have $f(0) = 0$ because:
If $a \neq 0$, then let $f(a) = b$. We have:
From here it's easy to see the set $\{ (a,f(a)) \mid a>0, f(a)>0 \}$ partitions the positive real numbers and so is of the form I describe above.
One particular solution is
$$ f(x) = \begin{cases} 0 & x = 0 \\ x+1 & x > 0 \wedge \lceil x \rceil \text{ is odd} \\ 1-x & x > 0 \wedge \lceil x \rceil \text{ is even} \\ x-1 & x < 0 \wedge \lfloor x \rfloor \text{ is odd} \\ -1-x & x < 0 \wedge \lfloor x \rfloor \text{ is even} \end{cases}$$
e.g. $f(1/2) = 3/2$, $f(3/2) = -1/2$, $f(-1/2) = -3/2$, and $f(-3/2) = 1/2$.
(This works out to be Jyrki Lahtonen's example)