Find all differentiable functions $f$ such that $f\circ f=f$ I want to find all differentiable functions $f:\mathbb R \to \mathbb R$ such that $f\circ f=f$, 
My attempt since $f$ is differentiable, $f'(f(x))f'(x)=f'(x)$ Now if $f'(x)\neq0$($f'=0$ means constant and they satisfy) then $f'(f(x))=1$, so we are looking for functions which satisfy $f'(f(x))=1$, How to proceed in this case? ($f(x)=x$ is also an obvious solution)

The only solutions are constants and $f(x)=x$.
Suppose $f$ isn't a constant. Let $X = f(\mathbb{R})$. $f$ is continuous, therefore $X$ is connected. Also, it is easy to see that $f(y)=y$ for all $y \in X$.
Let $x_0 = \inf X$. Suppose that $x_0 \neq - \infty$. From the above it is clear that $f(x_0 + \varepsilon) = x_0 + \varepsilon$ for all sufficiently small positive $\varepsilon$. From continuity we also have $f(x_0)=x_0$, so $x_0$ is in fact the minimum of $f$.
Now, on the one hand we see that $f'(x_0)=1$, and on the other hand $f'(x_0)=0$ by Fermat's theorem. This contradiction shows that $\inf X = -\infty$. In a similar fashion $\sup X = +\infty$, and therefore $X = \mathbb{R}$, which implies that $f(x)=x$ everywhere.
