Two functions $f:A\rightarrow B$ and $g:B\rightarrow A$. Can someone give me an example where $g\circ f=id_A$ but $f\circ g\neq id_B$?
2026-04-08 04:14:20.1775621660
On
On
Example $g\circ f=id_A$ but $f\circ g\neq id_B$
178 Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
5
There are 5 best solutions below
0
On
Take $A=B=l^2$ (this is the set of infinite sequences such that the sum of the squares of the elements is finite).
Let $x=(x_1,x_2,\dots)$, $f(x)=(0,x_1,x_2,\dots)$ and $g(x)=(x_2,x_3,x_4,\dots)$. Then we have $g(f(x))=x$, but $f(g(x))=(0,x_2,x_3,\dots)$.
0
On
Let $A \subset B$, $f$ be inclusion, and $g$ be the identity on $A$ and act in any way on $B \setminus A$. Then $g \circ f$ is the identity but $f \circ g$ cannot map to $B \setminus A$.
A minimal example is $A = \{1\}$, $B = \{1, 2\}$, $f(1) = 1$, $g(1) = 1$, $g(2) = 1$. Then $(g \circ f)(1) = 1$, $(f \circ g)(1) = 1$, $(f \circ g)(2) = 1$.
Since $g\circ f=\mathit{id}_A$, we see that $g$ is surjective and $f$ is injective.
Since we want $f\circ g\ne\mathit{id}_B$, $f$ has not to be surjective: if it's also surjective, then it's bijective and so $g=f^{-1}$ follows from $g\circ f=\mathit{id}_A$ and then $f\circ g=\mathit{id}_B$.
Thus we can try $A=\{0\}$, $B=\{1,2\}$ and $f(0)=1$. Since we need that $g$ is surjective, we must set $g(1)=g(2)=0$.
Now $f\circ g(2)=f(0)=1$.
If you need also $A=B$, then the set must be infinite. Just consider $A=B=\mathbb{N}$ and $$ f(n)=n+1, \qquad g(n)=\begin{cases} n-1 & \text{if $n>0$}\\ 0 & \text{if $n=0$} \end{cases} $$ Then $$ g(f(n))=g(n+1)=n $$ for all $n$ and $g\circ f$ is the identity. On the other hand $$ f(g(0))=f(0)=1 $$ and so $f\circ g$ is not the identity.