# Give examples of functions $f\colon X\to Y$ and $g\colon Y\to X$ such that $g\circ f=id_X$ but where $f$ is not invertible.

Give examples of functions $f\colon X\to Y$ and $g\colon Y\to X$ such that $g\circ f=id_X$ but where $f$ is not invertible. At first I thought I could simply make $f(x)=x^2$ and $g(x)=\sqrt{x}$ but then I realized that their composition would yield $+x$ and $-x$, not simply $x$. I'm not sure I really understand what it's asking anymore.

-

HINT: If $g\circ f=\mathrm{id}_X$, then $f$ must be one-to-one. Thus, $f$ can fail to be invertible only by failing to map $X$ onto $Y$. Can you find an example with $X=\{0\}$ and $Y=\{0,1\}$?
@Gail: Which part? The explanation of why $f$ must be one-to-one but not onto, or the final suggestion for finding an example? I can add a bit to the latter: let $f$ be any function from $X$ to $Y$ and $g$ any function from $Y$ to $X$, and you’ll have an example. –  Brian M. Scott Nov 29 '12 at 18:36