# Let $$f:W \to W$$ be defined as $f(n)=n$ - $1$, if $$n\;is\;odd\;and\; f(n)=n+1,\;if\;n\;is\; even.$$ Show that $$f$$ is invertible. Find the inverse of $$f$$. Here, $$W$$ is the set of all whole numbers.

Toolbox:
• To check if a function is invertible or not ,we see if the function is both one-one and onto.
• A function $f: X \rightarrow Y$ where for every $x_1, x_2 \in X, f(x_1) = f(x_2) \Rightarrow x_1 = x_2$ is called a one-one or injective function.
• A function$f : X \rightarrow Y$ is said to be onto or surjective, if every element of Y is the image of some element of X under f, i.e., for every $y \in Y$, there exists an element $x \in X$ such that $f(x) = y$.
• Given two functions $f:A \to B$ and $g:B \to C$, then composition of $f$ and $g$, $gof:A \to C$ by $gof (x)=g(f(x))\;for\; all \;x \in A$
• A function $g$ is called inverse of $f:x \to y$, then exists $g:y \to x$ such that $gof=I_x\;and\; fog=I_y$, where $I_x, I_y$ are identify functions.
Given $f(x)= \left\{ \begin{array}{1 1} n-1 & \quad if\;n\;is\;odd \\ n+1 & \quad if\;n\;is\;even \end{array} \right.$
To check if a function is invertible or not ,we see if the function is both one-one and onto.
$\textbf {Step 1: Checking one-one}$
$\textit{Case 1: Consider the case where n is odd, m is even}$
Let $f(n) = f(m) \Rightarrow n - 1 = m+1 \rightarrow n-m = 2$
Difference of an even number and odd number cannot be 2
Therefore, $n - m \neq 2$. Similarly, m being odd and n being even can also be discarded with a similar argument.
$\textit{Case 2: Consider the case where n and m are odd}$
Let $f(n) = f(m) \Rightarrow n - 1 = m -1 \rightarrow n=m$
$\textit{Case 3: Consider the case where n and m are even}$
Let $f(n) = f(m) \Rightarrow n - 1 = m -1 \rightarrow n=m$
Therefore, we see that $f$ is one-one for the case where $n=m$ for both odd and even cases.
$\textbf {Step 2: Checking onto}$
For any odd number $2r+1$ in codomain $W$ then is an image $2r$ in $W$, and similarly, for any even number $2r$ in codomain $W$ there is an image $2r+1$ in $W$ also $\rightarrow f\;$ is onto..
Given that $f$ is both one-one and onto, $f$ is invertible.
$\textbf {Step 3: To calculate}\; f^{-1}, \textbf {we must first define g(y):}$
We know that a function $g$ is called inverse of $f:x \to y$, then exists $g:y \to x$ such that $gof=I_x\;and\; fog=I_y$, where $I_x, I_y$ are identify functions.
Let us define a function $g(x)= \left\{ \begin{array}{1 1} m+1 & \quad if\;m\;is\;even \\ m-1 & \quad if\;m\;is\;odd \end{array} \right.$
$\textbf {Step 4: Calculate gof}$
If n is odd then n-1 is even number, and when n is even, n+1 is odd.
When $n$ is odd $\Rightarrow$ $gof(n)=g(f(n))=g(n-1) = n-1+1=n$
When $n$ is even $\Rightarrow$ $gof(n)=g(f(x))=g(n+1)=n+1-1=n$
Thus $gof = I_W$
$\textbf {Step 5: Calculate fog}$
If m is odd then m-1 is even number, and when m is even, m+1 is odd.
When $m$ is odd $\Rightarrow$ $fog(m) = f(g(m)) =f(m-1) = m-1+1=m$
When $m$ is even $\Rightarrow$ $fog(m)=f(g(x))=f(m+1)=f+1-1=m$
Thus $fog = I_W$
$\textbf {Step 6: Calculating} \; f^{-} \textbf{ from} \; gof = fog$:
Since $gof = I_W = fog$, the inverse $f^{-1} = g$ which is nothing but $f$ itself.
answered Feb 27, 2013 by
edited Feb 12, 2014