Let \(\mathbf{W}=\{0,1,2,3,\dots\}\). The function \(f:\mathbf{W}\to\mathbf{W}\) is defined by
\[f(n)=\begin{cases}n-1, & n \text{ odd},\\ n+1, & n \text{ even}.\end{cases}\]
Step 1: Check that \(f\) maps \(\mathbf{W}\) into \(\mathbf{W}\).
If \(n\) is odd, then \(n\ge 1\), so \(n-1\ge 0\) and \(n-1\) is even; hence \(f(n)=n-1\in\mathbf{W}\). If \(n\) is even, then \(n+1\) is odd and positive, so \(f(n)=n+1\in\mathbf{W}\). Thus \(f\) is a well-defined function from \(\mathbf{W}\) to \(\mathbf{W}\).
Step 2: Show that \(f\) is one-one.
Suppose \(f(m)=f(n)\). We consider cases.
- If both \(m,n\) are odd, then \(m-1=n-1\), so \(m=n\).
- If both \(m,n\) are even, then \(m+1=n+1\), so \(m=n\).
- If \(m\) is odd and \(n\) is even, then \(f(m)=m-1\) is even while \(f(n)=n+1\) is odd. An even number cannot equal an odd number, so this case is impossible.
- If \(m\) is even and \(n\) is odd, the same parity argument shows \(f(m)\ne f(n)\).
Hence \(f(m)=f(n)\Rightarrow m=n\), so \(f\) is injective.
Step 3: Show that \(f\) is onto.
Let \(y\in\mathbf{W}\). We must find \(n\in\mathbf{W}\) with \(f(n)=y\).
- If \(y\) is even, take \(n=y+1\). Then \(n\) is odd and \(n\ge 1\), so \(f(n)=n-1=y\).
- If \(y\) is odd, then \(y\ge 1\), so \(y-1\ge 0\) is even. Take \(n=y-1\). Then \(n\) is even and \(f(n)=n+1=y\).
Thus every \(y\in\mathbf{W}\) has a preimage, so \(f\) is surjective.
Since \(f\) is both one-one and onto, it is bijective and therefore invertible.
Step 4: Find the inverse \(f^{-1}\).
From the preimages found above,
\[f^{-1}(y)=\begin{cases}y+1, & y \text{ even},\\ y-1, & y \text{ odd}.\end{cases}\]
Equivalently, writing the variable as \(n\),
\[f^{-1}(n)=\begin{cases}n+1, & n \text{ even},\\ n-1, & n \text{ odd}.\end{cases}\]
Notice that \(f^{-1}=f\), so \(f\) is its own inverse.
Verification:
- If \(n\) is odd, \(f(n)=n-1\) is even, so \(f^{-1}(f(n))=f^{-1}(n-1)=(n-1)+1=n\).
- If \(n\) is even, \(f(n)=n+1\) is odd, so \(f^{-1}(f(n))=f^{-1}(n+1)=(n+1)-1=n\).
Thus \(f^{-1}\circ f\) is the identity on \(\mathbf{W}\). Similarly, for any \(y\in\mathbf{W}\), checking the even and odd cases gives \(f(f^{-1}(y))=y\), so \(f\circ f^{-1}\) is also the identity. Hence the inverse is correct.