Set closed under composition of a continuous function Determine the sets $S=\left \{ f+C|C\in \mathbb{R} \right \}$ which are closed under composition, where $f:\mathbb{R}\rightarrow \mathbb{R}$ is a continuous function.
Sadly, I have no idea on how to solve it.
 A: Pick a function $f$ satisfying the conditions.
We can assume that $f(0)=0$.
Now notice that $f\circ f$ must also be in $S$.
We conclude $(f\circ f)(x)-(f\circ f)(0)=f(x)-f(0)$ for all $x$.
therefore $f\circ f(x) = f(x)$ for all x.
Let $A$ be the image of $f$. Clearly every element of $A$ is a fixed point, in fact the image of $A$ coincides with set of fixed points of $A$.
Because of IVT we have that $A$ is an interval. And because $A$ is the preimage of $\{0\}$ under the continuous function $f(x)-x$ we have that $A$ is closed.
We show that $A$ is either a point or all of $\mathbb R$.
Suppose that $A$ is not a point, notice there is an $a\in A$ and $\epsilon>0$ such that $a+\epsilon\in A$. We will prove that $A$ does not have a maximum element, suppose $b$ is the maximum element.
Consider the composition $f\circ(f+\epsilon)$. Notice that when evaluating it at $a$ we get $f(a+\epsilon)=a+\epsilon$. therefore $f\circ(f+\epsilon)=f+\epsilon$. But this is not true, because the image of $f+\epsilon$ is $A+\epsilon$ (this set contains $b+\epsilon$), while the image of $f\circ(f+\epsilon)$ is clearly contained in $A$ and thus does not contain $b+\epsilon$.
A similar argument shows that $A$ does not have a minimum, thus $A=\mathbb R$.
Clearly when $A$ is a point we have $A=\{0\}$ and when $A=\mathbb R$ we must have that $f(x)=x$.
Conclusion: the functions that work are $f(x)=c$ and $f(x)=x+c$
A: If $f$ is constant, then $S$ is the set of all constant functions and closed under composition.
If $f$ is of the form $f(x)=x+a$, then one also verifies that $S$ is closed under composition.
To see that there are no other solutions, let $f$ be any function with the desired property.
By picking $C=-f(0)$, we find a $g\in S$ with $g(0)=0$.
As $g\circ g\in S$, there exists $C'$ with $g(g(x))=f(x)+C'$ for all $x$. In particular $g(g(0))=f(0)+C'$ implies $C'=-f(0)=C$.
We conclude $g\circ g=g$.
Also, for any $y$, the map $x\mapsto g(g(x)+y)-g(y)$ maps $0$ to $0$, hence must be $g$. Hence 
$$ g(g(x)+y)=g(x)+g(y).$$
Thus if $A:=g(\Bbb R)=\{\,g(x)\mid x\in\Bbb R\,\}$ and $h\in A$, then $g(x+h)=g(x)+h$.
Trivially, $0\in A$, and by the Intermediate Value Theorem, $A$ must be connected, i.e., either $A=\{0\}$ or for suitable $a>0$, we have $[0,a)\subset A$ or $(-a,0]\subset A$. 


*

*In the first case, $g$ is identically zero, which corresponds to our first solution: constant functions.

*In the second case, let $B=\{\,x\in\Bbb R\mid g(x)=x\,\}$.
We know $[0,a)\subset B$.
In fact, if $0<h<a$ then $x\in B\iff x+h\in B$. We conclude that $B$ is an open set. But $B$ is also closed. Therefore $B=\Bbb R$ and $g$ is the identity function.

*The third case works similar.

