TITLE: Can $f(g(x)) = x$ if $g(f(x))$ is not equal to $x$?
QUESTION [7 upvotes]: Is it possible that there are functions $f(x)$ and $g(x)$ where $f(g(x)) = x$ and $g(f(x))$ does not equal $x$? If so, is there a pattern or general rule for them? If not, what is the proof that there is not? This originated when a math teacher said that in order for $g$ of $x$ to be the inverse of $f$ of $x$, it must be that both $f\circ g$ and $g \circ f$ equal $x$, and a student asked if one of these cases exists.

REPLY [15 votes]: There are many examples of this. In such cases, $f$ is called a left inverse of $g$, in contrast to a full (two sided) inverse. To give one example, consider $g \colon [0,\infty) \to \mathbf R$ given by $g(x) = \sqrt x$ and $f \colon \mathbf R \to [0,\infty)$ given by $f(x) = x^2$. We have 
$$ f\bigl(g(x)\bigr) = \sqrt{x}^2 = x, \qquad x \in [0,\infty) $$
and 
$$ g\bigl(f(x)\bigr) = |x|, \qquad x \in \mathbf R. $$
So $f \circ g$ is the identity, where $g \circ f$ is not.

REPLY [2 votes]: Another example is the logarithm, which has branches in the complex plane. Let $$L(x)=\log(x)+ 2 \pi Î$$ then $$\exp(L(x))=x$$ but $$L(\exp(x))=x+2 \pi Î$$