# Counterexample or proof of function such that every point is fixed implies function is identity or constant

I've been trying to prove the following for a while, out of curiosity. For any (possibly discontinuous, etc) function $f:A\to A$ such that $$f^n(x) = f(x),\quad \forall x\in A, n\in \mathbb{N}$$ where $f^n$ is the $n$-repeated application of the function $f$ on its argument, then $f$ is either the identity mapping or constant everywhere.

Is this statement true? It feels like it might be, at a first glance, but I have little intuition for these types of statements, so it's unclear if there exists a weird counterexample from adding Choice into the mix.

For now, we can say, for example, that $A = \mathbb{R}$ (though I'm quite curious about the general case as well).

• Take $f(1) = 1$ and $f(x) = 0$ for $x \neq 1$ for example. Aug 17, 2017 at 15:33
• Note that $f^n(x) = f(x)$ for all $x \in A, n \in \Bbb N$ is equivalent to simply saying that $f(f(x)) = f(x)$ for all $x \in A$. Aug 17, 2017 at 15:43

The answer is no. Take $A = \Bbb R$ and $f(x) = |x|$.
In general, we can say that if $f(f(x)) = f(x)$, then $f$ is equal to the identity over the image of $f$. In particular: consider any $y$ in the image of $f$. Then $y = f(x)$ for some $x \in A$, and we have $$f(y) = f(f(x)) = f(x) = y$$ If $f$ is surjective, then the image of $f$ is $A$, and so $f$ must be the identity map over $A$.
Note that if $f$ is injective, then there exists a function $g(x)$ such that $g(f(x)) = x$, and we have $$f(f(x)) = f(x) \quad \text{for all }x \in A \implies \\ g(f(f(x)) = g(f(x)) \quad \text{for all }x \in A\implies \\ f(x) = x \quad \text{for all }x \in A$$
• Ah, thank you! Much easier than expected. I do wonder, are there any additional conditions we can add on $f$ for which this would imply that it is either constant or the identity? It's unclear to me that this would be the case. Aug 17, 2017 at 15:34
Just take $f$ to be a linear projection, it neither a constant nor the identity.