TITLE: How to find the function $f$ given $f(f(x)) = 2x$?
QUESTION [11 upvotes]: I was wondered how to find the function in this equality:
$f(f(x))=2x$.  Also $f$ is continuous.
I don't need the answer, how to find it is more important.

REPLY [2 votes]: $f$ is injective. Assume that $f(x) = f(y)$ for some $x \neq y$, then $2x = f(f(x)) = f(f(y)) = 2y$. As $f(\mathbb{R}) = \mathbb{R}$ by definition, $f$ is surjective and hence bijective. $f$ is also monotonous.
From here on I'd like to follow up alex.jordan's answer. 
From $f(1) = a$ we get $f(a) = 2$, another necessary condition.
For $a \geq 0$, three cases are possible:

$1 < a < 2$
$0 < a \leq 1$ ($a=0$ is not possible)
$a \geq 2$

For case 1., I claim that any continuous and bijective function $f$ with the following properties solves the assignment:

$f(0)=0, f(1)=a, f(a)=2, f(2)=2a$
For $x \in (1, a)$, $f(x) \in (a, 2)$ so that  $f(f(x)) = 2x \in (2, 2a)$.
(from alex.jordan's answer): $f(2^n x) = 2^n f(x)$.
(from alex.jordan's answer): Likewise for $x < 0$ with $f(-1) = b$ and $f(-2) = 2b$.

Informally speaking, any deviation from $f(x) = ax$ imposed by the first application of $f$ is undone by its second application. IMO, this is more restrictive than the solution provided by alex.jordan. Moreover, I believe that the above conditions are necessary as well: 1., 3. and 4. have been proven necessary by alex.jordan, 2. is necessary due to bijectivity and monotony which has been proven necessary above.
Case 2. is impossible: $a \leq 1 < 2$, but $f(a) \geq f(2) > f(1)$.
Case 3. is impossible, too: $1 < 2 \leq a$, but $f(a) \leq f(1) < f(2)$.
A similar, but much more convoluted solution is possible for the case $a < 0$, yielding $-2 < a < -1$. Here, $f((1, -a)) = (b, -2)$, and $f((b, -2)) = (2, -2a)$; likewise, $f((-a, 2)) = (-2, 2b)$ and $f((-2, 2b)) = (4, -4a)$.
$f(x) = \pm \sqrt{2} x$ are special cases of the above generic solution.
Edit: Now I see that this has been proposed by Robert Israel before.