Are there functions f and g whose compositions are not commutative

318 Views Asked by At

Find an example of functions $f, g: \mathbb{N} \rightarrow \mathbb{N}$ whose composition $f \circ g=id_{\mathbb{N}}$ and at the same time $g \circ f \neq id_{\mathbb{N}}$.

First thing we can see is that $f$ is injective and $g$ is surjective, but I can't seem to figure out what to do next.

2

There are 2 best solutions below

0
On BEST ANSWER

Yes, first just to make sure we are using same notations, I assume that $0\in\mathbb{N}$.

Let $f:\mathbb{N}\rightarrow\mathbb{N}$ be $f(x)=x+1$

and $g:\mathbb{N}\rightarrow\mathbb{N}$ be $g(x)=x-1$ whenever $x\not = 0$ and $g(x)=0$ if $x=0$.

Now, $g\circ f (x) = g(x+1)=x+1-1=x$ hence $g\circ f = Id$. While $f\circ g(0)=f(0)=1$ hence $f\circ g$ is not the identity.

0
On

Consider $f(1) = 1$ and $f(n) = n-1$ for $n>1$, and $g(n)=n+1$ for all $n$.

$f: (1,2,3,4,...) \mapsto (1,1,2,3,...)$

$g: (1,2,3,4,...) \mapsto (2,3,4,5,...)$

So $f\circ g = id$ but $g \circ f \not = id$ because

$$1 \overset{f}{\mapsto} 1 \overset{g}{\mapsto} 2 = (g\circ f)(1)$$