I am wondering what is the class of functions $f: \mathbb{R}\rightarrow\mathbb{R}$ such that $f(f(x))=f(x)$?

I think it should be:

  1. Constant Value functions
  2. the identity function
  3. absolute value function $|x|$

But I don't know if this is right or how to show it rigorously.

Any suggestions?


Solution 1:

Such functions can be described in the following way:

If $A$ is an arbitrary subset of $\mathbb{R}$ and $g:\mathbb{R} \setminus A \mapsto A$ an arbitrary funtion. Define

$$ f(x) = \left\{ \begin{array}{l l} x & \quad \forall x\in A\\ g(x) & \quad \forall x \not \in A \end{array} \right. $$

$f$ has this idempotency property.

Contrary for an $f$ with the idempotency property such an $A$ and $g$ can be found: $A:=f(\mathbb{R})$ and $g:=f \rvert _{\mathbb{R}\setminus A}$

Solution 2:

Here is a large family of such functions. Choose any function $g(x)$, defined on $(-\infty,0)$, that satisfies $g(x)\ge 0$ for all negative $x$. Then we define $$f(x)=\begin{cases} g(x) & x<0 \\ x & x\ge 0\end{cases}$$

The absolute value is an example from this family, corresponding to $g(x)=-x$. But any function with that condition will do, such as $g(x)=x^2$ or $g(x)=\sqrt{-x}$ or $g(x)=e^x$ or $g(x)=1+\sin x$.