Test for an Inverse Function When I teach students about inverse functions, every textbook says that you have to test both $f(g(x))$ and $g(f(x))$ to see if they equal $x$.  However, I've never seen a case where one of those equals $x$ and the other doesn't which makes me question if you really have to look at both cases.
So my question is, are there two functions, $f$ and $g$, such that $f(g(x)) = x$ but $g(f(x)) \ne x$?
 A: $g:[0,1]\rightarrow [0,2]$, $g(x)=x$ and $f:[0,2]\rightarrow [0,1]$, $f(x)=min(x,1)$.
A: Sure. Let $f$ be the only function from $\{0,1\}$ into $\{0\}$ and define $g\colon\{0\}\longrightarrow\{0,1\}$ by $g(0)=0$. Then you always have $f(g(x))=x$, but $g(f(1))\ne1$.
A: Adding to the list... consider the sequence space of $\ell_2$, the space of infinite square summable sequences.
The right-shift operator, $R$, takes a sequence and shifts the positions of each entry to the right, appending a zero to the beginning.  That is... $R(a_1,a_2,a_3,a_4,a_5\dots) = (0,a_1,a_2,a_3,a_4,\dots)$
The left-shift operator, $L$, takes a sequence and shifts the positions of each entry to the left, the initial term having nowhere to the left to go is just forgotten.  That is... $L(a_1,a_2,a_3,a_4,a_5,\dots) = (a_2,a_3,a_4,a_5,a_6,\dots)$
One can see then that $L(R(a_1,a_2,a_3,a_4,\dots)) = (a_1,a_2,a_3,a_4,\dots)$ while on the other hand $R(L(a_1,a_2,a_3,a_4,\dots)) = (0,a_2,a_3,a_4,\dots)$ showing that $R$ is a right-inverse to $L$ but not vice versa.
A: Let $X$ be a non-empty set. If $g: X \to X$ is one-to-one, but not onto (i.e. $g(x_1) =  g(x_2) \implies x_1=x_2$, but there exists $x \in X$ such that there is no $x_0 \in X$ with $f(x_0) = x$), then we may define $f: f(X) \to X$ on the range of $g$ as $f(g(x)) := x$. Then, $f(g(x))=x$ for all $x \in X$ by definition, but the expression $g(f(x))$ does not even make sense for all $x \in X$. More generally, in such a case $g$ is a right inverse of $f$, but not a left inverse.
A: For a function $g$, it has a left inverse if you can find $f_1$ such that $f_1(g(x))=x$ and a right inverse if you can find a function $f_2$ such that $g(f_2(x))=x$; $g$ has an inverse $f$ if both $f_1$ and $f_2$ exist and $f=f_1=f_2$.
Others above have given examples of functions which only have a one-sided inverse but let me give a perhaps more familiar one. Consider as $g$ the differentiation map $\frac{d}{dx}$ on polynomials (i.e. expressions of the form $p(x)=a_nx^n+a_{n-1}x^{n-1}+\cdots+a_0$ where $a_i$ are rational numbers.
As a possible inverse, consider $f$ to be the indefinite integral map $\int$. Then $g(f(p(x)))= \frac{d}{dx}(\int p(x) dx)=p(x)$ (where $p(x)$ is an element of the polynomial space we are acting on), so $f$ is a right inverse to $g$. However $f(g(p(x)))=\int(\frac{d}{dx} p(x)) dx$ is not always $p(x)$ due to the constant of integration; i.e. both $p_1(x)=x$ and $p_2(x)=x+1$ differentiate to the same element $1$, but when integrated we don't know which one it came from, due to the constant of integration.
(Caveat: here the integration isn't well-defined as I've not created an explicit map on polynomials but this could be done by setting the constant of integration to always be $0$).
