Describe all the continuous function $f:\mathbb R \to \mathbb R$ such that $f \circ f=f$. Again describe all linear maps with the same property. Can anyone describe all the continuous functions $f:\mathbb R \to \mathbb R$ such that $f \circ f=f$. I think I should search within functions whose image set is connected.
                           Also can anyone describe all linear maps with $T^2=T$ on a vector space $V$?
 A: Since $f$ is continuous, its range is an interval $I$.
Note that for all $a \in I$, there exists an $x$ such that $f(x)=a$.Then
$$a=f(x)=f(f(x))=f(a)$$
Therefore, 
$$f(x)=x\quad \forall x \in I$$
This mean that any $f$ which satisfies the solution has the form: There exists an unique interval $I$ such that 
$$f(x)=x \,\quad \forall x \in I \\
f(y) \in I\quad \forall y$$ 
In other words $f$ is a retract of $\mathbb R$.
It is easy to see that any such retract works.
Thus $f$ is an answer if and only if $f$ is a retract of $\mathbb R$.

To see the issue with describing all of them, just consider the case $I=[0, \infty)$. Then, if $g: (- \infty,0] \to [0,\infty)$ is any continuous function, such that $g(0)=0$ then
$$f(x)= x\quad \forall x \geq 0 \\
f(x)=g(x)\quad \forall x < 0$$
works. Picking $g$ any odd polynomial, or $e^x-1$ or.... works.
A: In general, the statement that $f=f\circ f$ is equivalent to saying that the restriction of $f$ to its image is the identity map - basically, if you want to describe all such maps, what you should do is prescribe its image, set $f$ to be the identity on that set, then just make sure everything else maps into that image.
So, for continuous maps $\mathbb R\rightarrow\mathbb R$, you know that the image has to be connected, since the image of a connected set is always connected. You can also work out that the image is closed since the image must equal the set of $x$ for which $f(x)=x$. To construct examples, you should choose some closed connected set $I$, set $f(x)=x$ for $x\in I$ and then just choose any function beyond that interval that sends everything into that interval. There's a lot of such maps - a non-trivial example would be the triangle wave taking $2n$ to $0$ and $2n+1$ to $1$ for each $n\in\mathbb Z$ and linearly interpolating in between.
For linear maps on a vector space $V$, much the same applies: fix the subspace $S$ you want to have as the image and set the map to be the identity on that subspace. Then, extend the map so that the image remains in that subspace - to be really explicit, you could choose a basis $V$ that contains a basis for $S$, then for each basis element of $V$ not in $S$ choose a point within $S$ to send that element to.
A: For $-\infty \le a \le b \le \infty$ let
$$[a,b] = \{ x \in \mathbb R \mid a \le x \le b \}.$$
This notation may be unusual for $a = -\infty$ or $b = \infty$. Note that it covers one-point sets $[a,a] = \{a\}$ for $a \in \mathbb R$, bounded closed intervals and the sets $[-\infty,b] = \{ x \in \mathbb R \mid x \le b \}$ for $b \in \mathbb R$ which is usually written as $(-\infty,b]$, $[a,\infty] = \{ x \in \mathbb R \mid a \le x \}$ for $a \in \mathbb R$ which is usually written as $[a,\infty)$ and $[-\infty,\infty] = \mathbb R$. 
The continuous functions are precisely those having the form $f = i \circ r$ with a retraction $r : \mathbb R \to [a,b]$ and inclusion $i : [a,b] \hookrightarrow \mathbb R$. Obviously $f(\mathbb R) = [a,b]$.
Note that a retraction is a continuous map with the property $r(x) = x$ for $x \in [a,b]$.
Let $J = f(\mathbb R)$. By the intermediate value theorem it has the property that if $x,y  \in J$ such that $x < y$, then also $[x,y] \subset J$. Hence it must be an open, half-open or closed interval between points $a, b$ with $-\infty \le a \le b \le \infty$. For $y \in J$ we have $f(y) = y$ (taking $x$ with $f(x) = y$, we see $f(y) = f(f(x)) = f(x) = y$). If $a \in \mathbb R$, then $f(a) = f(\lim_{x\to a+} x) = \lim_{x \to a+}f(x) = \lim_{x \to a+} x = a$, thus $a \in J$. Similarly we have $b \in J$ if $b \in \mathbb R$.
We conclude that $J = [a,b]$. This shows that $f(x) \in [a,b] $ for all $x$ and $f(x) = x$ for $x \in [a,b]$. The above decomposition follows.
If $f$ is linear, look at $a = f(1)$. Then $a = f(1) = f(f(1)) = f(a) = f(a \cdot 1) = a \cdot f(1) = a^2$ which implies $a=0$ or $a=1$. In the first case $f =0$, in the second case $f =id$.
An alternative argument is this. Each linear $f$ is continuous. $f(\mathbb R)$ is a linear subspace of $\mathbb R$, thus either $f(\mathbb R) = \{ 0\}$ or $f(\mathbb R) = \mathbb R$. In the first case $f = 0$, in the second case $f = id$ (apply the known result for continuous functions).
