How to find the function $f$ given $f(f(x)) = 2x$? 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.
 A: For another class of solutions, try $f(x) = -c x$ for $x \ge 0$, $-(2/c) x$ for $x < 0$, where $c > 0$ is constant.  Still more generally, let  $h(x) = x p(\log_2(x))$ for $x > 0$ where $p$ is continuous and  periodic with period 1 and $p(t) +  p'(t)/\ln(2) > 0$ everywhere.  Thus $h$ is an increasing continuous function from $(0,\infty)$ onto itself, thus invertible on $(0,\infty)$.
Let $f(x) = - h(x)$ for $x > 0$, $f(0) = 0$, $f(x) = 2 h^{-1}(-x)$ if $x < 0$.
A: Nevermind!  I became focused on solving $f(2x)=2f(x)$, which is a consequence of the original equation, but not equivalent.  I'll leave this here in case it helps with an actual solution.

As has been noted, $f(0)=0$.  Let $f(1)=a$.  
As noted in my comment,  $$f(2x)=2f(x)$$  Inductively, for all $n\in\mathbb{Z}$, $$f(2^nx)=2^nf(x)$$  In particular, $f(2^n)=2^na$.  That is, upon choosing a value $a$ for $f$ at $1$, the function's values at $\{\ldots,\frac14,\frac12,1,2,4,\ldots\}$ are immediately determined.  
Now I claim that any continuous function on $[1,2]$ with $f(1)=a$ and $f(2)=2a$ extends to a function $f$ on $(0,\infty)$, using the relation $f(2^nx)=2^nf(x)$.
Similalary,we could choose a completely different continuous function on $[-2,-1]$ with $f(-1)=b$ and $f(-2)=2b$, and extend to $(-\infty,0)$.  Combined with the observation that $f(0)=0$, this gives a very big space of solutions defined on $(-\infty,\infty)$.
As an example of how exotic these solutions could be, consider $f(x)=(\sin(2\pi\log_2(x))+5)x$.
A: There are many constructions already of continuous functions satisfying the hypothesis. Even better, I believe that Robert gives examples where the function is differentiable everywhere in $\mathbb R \setminus \{0\}$. I will show that this situation is tight.
In particular, I show that if $f$ is such that 


*

*$f(f(x))=2x$, and 

*$f$ is differentiable at $0$, 


then $f(x) = cx$ for all $x$, where $c := f'(0)$. Note that we do not require continuity anywhere but at the origin. Moreover, substituting $f(x)=cx$ in the functional equation, it is clear that the only possible values of $c$ are $\pm \sqrt{2}$. 
We have already showed that $f(0) = 0 = c \cdot 0$, so fix $t \in \mathbb R \setminus \{0\}$. Define the sequence $x_n$ by $x_n := \frac{t}{2^n}$. Then from alex.jordan's observation that $f(2x) = 2f(x)$, it is evident that the sequence
$$
\frac{f(x_n)}{x_n} = \frac{f(t)}{t}
$$
for all $n$. In particular, the limit is the above expression as well. 
On the other hand, notice that $x_n \to 0$, and by hypothesis $f'(0) = c$. Therefore, $$
\frac{f(t)}{t} = \lim_{n \to \infty} \frac{f(x_n)}{x_n} = \lim\limits_{n\to \infty} \frac{f(x_n) - f(0)}{x_n} = \lim\limits_{x\to 0} \frac{f(x) - f(0)}{x} = f'(0) = c,
$$
which gives the claim. 
A: This is not a general solution, but I think there are more continuous solution the functional equation. Consider, for e.g., 
$$
f(x) =
\begin{cases}
x \left( \frac{11}{6} - \frac{x}{3} \right), &\text{ for } x \in \left[ 1, \frac{3}{2} \right],
\\
\frac{11}{2} - \sqrt{\frac{121}{4} - 12x}, &\text{ for } x \in \left[ \frac{3}{2}, 2 \right],
\end{cases}
$$
We can extend the definition to all positive numbers by declaring:
$$
f(x) =
\begin{cases}
\frac{1}{2}f(2x), & \ 0 < x < 1,
\\ 
2f \Big(\frac{x}{2} \Big), & \ x > 2,
\end{cases}
$$
Finally, we extend the function to negative numbers and zero, by declaring the function to be odd. So $f(0) = 0$ and $f(-x) = -f(x)$ for all $x > 0$. 
If I haven't done any mistakes, then this function is continuous and satisfied $f(f(x)) = 2x$. 

We should check that the function is continuous, and it satisfies $f(f(x)) =  2x$. I am not spelling out the details here now, because it is quite tedious :-). I will think whether is a direct way to verify our requirements. Meanwhile, if there's any demand to show specific properties, I can certainly do so. 
A: More generally, suppose we want to find a "composition square root" of $ax^b$, where $a$ and $b$ are positive real numbers. Let's assume there is a solution of the form $f(x)=cx^d$ for some real numbers $c$ and $d$ and see where that takes us. From $f\left(f(x)\right) = ax^b,$ we get
$$c \cdot \left(cx^{d} \right)^{d} \; = \; ax^{b}$$
Therefore, $c^{d+1}=a$ and $d^{2}=b$, which we can easily solve for $c$ and $d$ in terms of $a$ and $b$ to get
$$f(x) \; = \; a^{\frac{1}{{\sqrt b}\; +\; 1}} \cdot x^{\sqrt b}$$
A: $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.
A: If $f$ has a power series, you could try composing the power series.  Since $f(0)=0$, we don't need to translate:
$$
f(x) = a_1x+a_2x^2+a_3x^3+\dots
$$
Therefore,
$$
\begin{align}
f(f(x)) &= a_1(a_1x+a_2x^2+a_3x^3+\dots)\\
&+a_2(a_1x+a_2x^2+a_3x^3+\dots)^2\\
&+a_3(a_1x+a_2x^2+a_3x^3+\dots)^3\\
&+\dots\\
&=a_1^2x+a_1a_2(1+a_1)x^2+a_1(2a_2^2+a_3+a_1^2a_3)x^3+\dots\tag{1}
\end{align}
$$
Using $(1)$, we get that $a_1=\sqrt{2}$ or $a_1=-\sqrt{2}$, then $a_2=0$, and $a_3=0$.  Checking, we see that both $f(x)=\sqrt{2}\;x$ and $f(x)=-\sqrt{2}\;x$ work.
Addition: Using alex.jordan's comment that $f(2x)=2f(x)$, if $f^{\;\prime}\in\operatorname{Lip}(\alpha)$ for some $\alpha>0$, i.e. $f\in\operatorname{Lip}(1+\alpha)$, then these two solutions are the only solutions.
