Find the inverse of an integer function

112 Views Asked by At

Find the inverse of the following function. $$f:\mathbb Z\rightarrow\mathbb Z$$ $$f(n)=\begin{cases}n+2&\text{if }n\text{ is even}\\ n-6&\text{if }n\text{ is odd}. \end{cases}$$

Hello everyone. I am having a little trouble finding an inverse for this one because I don't know how to include $x$ is even or $x$ is odd. Here is what I'm thinking:

$g(n)=\begin{cases}n-2&&n\text{ even}\\ n+6&&n\text{ odd.} \end{cases}$

Then,

$f\circ g=f(g(n))=\begin{cases}(n-2)+2\\ (n+6)-6 \end{cases}=\begin{cases}n\\ n \end{cases}=\text{id}_{\mathbb{Z}}(n)$

and

$g\circ f=g(f(n))=\begin{cases}(n+2)-2\\ (n-6)+6 \end{cases}=\begin{cases}n\\ n \end{cases}=\text{id}_{\mathbb{Z}}(n)$

Then since $f\circ g=\text{id}_{\mathbb{Z}}(n)$ and $g\circ f=\text{id}_{\mathbb{Z}}(n)$, we know that $g(n)=f^{-1}(n)$.

The problem is that this does not involve that $n$ is even/odd. Any pointers would be appreciated. Thanks

1

There are 1 best solutions below

0
On

Let us rewrite functions $f$ and $g$ under the respective forms :

$$f(x)=y \ \ \iff \ \ y=x+2-8*(x \ \text{mod}\ 2)\tag{1}$$

$$g(y)=x \ \ \iff \ \ x=y-2+8*(y \ \text{mod}\ 2)\tag{2}$$

Plugging (1) into (2), we have :

$$x=[(x+2-8*(x \ \text{mod}\ 2)-2]+8*\{[(x+2) - 8*(x \ \text{mod}\ 2)] \ \text{mod}\ 2\}$$

$$x=\require{cancel}[(x+\cancel{2}-8*(x \ \text{mod}\ 2)-\cancel{2}]+8*\{[x+\cancel{2} - \cancel{8}*(x \ \text{mod}\ 2)] \ \text{mod}\ 2\}$$

$$x=\require{cancel}x-\cancel{8*(x \ \text{mod}\ 2)}+\cancel{8*(x \ \text{mod}\ 2)}$$

establishing the identity relationship $x=g(f(x))$.