TITLE: Must $g$ be the identity if $f = g \circ f$?
QUESTION [9 upvotes]: I am finding it hard to solve the following problem. 
Let $A$ is a set and $f : A \rightarrow A$ and $g : A \rightarrow A$. If $f = g \circ f$, must $g$ be an identity function always? Will there be any counterexamples to show that $g$ must not be a identity function?

REPLY [2 votes]: Projections give you plenty of counterexamples with $f=g$. For instance, $f:\mathbb R^2\to \mathbb R^2$ given by $f(x,y)=x$.