Example 1
Question: Let \( f : \mathbb{N} \to \mathbb{N} \) be defined by \[f(n) = \begin{cases} n + 3 & \text{if } n \text{ is odd} \\ n - 3 & \text{if } n \text{ is even and } n \ge 4 \\ n & \text{if } n \in \{1, 2\} \end{cases}\] Hmm — actually, consider the simpler function \( g : \mathbb{Z} \to \mathbb{Z} \) defined by \[g(n) = \begin{cases} n - 1 & \text{if } n \text{ is odd} \\ n + 1 & \text{if } n \text{ is even} \end{cases}\] Show that \( g \) is both one-one and onto.
Solution: We need to show that \( g : \mathbb{Z} \to \mathbb{Z} \) defined by \[g(n) = \begin{cases} n - 1 & \text{if } n \text{ is odd} \\ n + 1 & \text{if } n \text{ is even} \end{cases}\] is one-one and onto. Step 1 — One-one (Injectivity): Assume \( g(a) = g(b) \) for some \( a, b \in \mathbb{Z} \). We consider three cases. Case 1: Both \( a \) and \( b \) are odd. Then \( g(a) = a - 1 \) and \( g(b) = b - 1 \). So \( a - 1 = b - 1 \) which gives \( a = b \). Case 2: Both \( a \) and \( b \) are even. Then \( g(a) = a + 1 \) and \( g(b) = b + 1 \). So \( a + 1 = b + 1 \) which gives \( a = b \). Case 3: \( a \) is odd and \( b \) is even (or vice versa). Then \( g(a) = a - 1 \) (even) and \( g(b) = b + 1 \) (odd). An even number cannot equal an odd number, so \( g(a) \ne g(b) \). This case cannot produce \( g(a) = g(b) \). In all valid cases, \( g(a) = g(b) \Rightarrow a = b \). Hence \( g \) is one-one. Step 2 — Onto (Surjectivity): Let \( y \in \mathbb{Z} \) be arbitrary. We find a pre-image \( x \) such that \( g(x) = y \). If \( y \) is even: Take \( x = y + 1 \) (which is odd). Then \[g(x) = g(y+1) = (y+1) - 1 = y.\] So \( y \) has a pre-image. If \( y \) is odd: Take \( x = y - 1 \) (which is even). Then \[g(x) = g(y-1) = (y-1) + 1 = y.\] So \( y \) has a pre-image. Since every \( y \in \mathbb{Z} \) has a pre-image in \( \mathbb{Z} \), \( g \) is onto. Conclusion: \( g \) is both one-one and onto, hence a bijection.
Answer: g is both one-one and onto (bijective). Every integer y has the pre-image y+1 (if y is even) or y−1 (if y is odd), and distinct inputs always produce distinct outputs.
Example 2
Question: Let \( h : \mathbb{N} \to \mathbb{N} \) be defined by \[h(n) = \begin{cases} n + 2 & \text{if } n \text{ is odd} \\ n - 2 & \text{if } n \text{ is even and } n \ge 4 \end{cases}\] and \( h(1) = 1,\ h(2) = 2 \). Is this function one-one and onto? Actually, consider instead \( p : \mathbb{N} \to \mathbb{N} \) defined by \[p(n) = \begin{cases} n - 1 & \text{if } n \text{ is even} \\ n + 1 & \text{if } n \text{ is odd} \end{cases}\] Show that \( p \) is both one-one and onto.
Solution: We verify that \( p : \mathbb{N} \to \mathbb{N} \) defined by \[p(n) = \begin{cases} n - 1 & \text{if } n \text{ is even} \\ n + 1 & \text{if } n \text{ is odd} \end{cases}\] is well-defined, one-one, and onto. Well-defined check: If \( n \) is even, then \( n \ge 2 \) in \( \mathbb{N} \), so \( n - 1 \ge 1 \in \mathbb{N} \). If \( n \) is odd, \( n + 1 \ge 2 \in \mathbb{N} \). So \( p \) maps \( \mathbb{N} \) into \( \mathbb{N} \). Note the explicit values: \( p(1) = 2,\ p(2) = 1,\ p(3) = 4,\ p(4) = 3,\ \ldots \) Each consecutive pair \( \{2k-1,\ 2k\} \) is swapped. Step 1 — One-one: Assume \( p(a) = p(b) \). Case 1: Both \( a, b \) are odd. Then \( a + 1 = b + 1 \Rightarrow a = b \). Case 2: Both \( a, b \) are even. Then \( a - 1 = b - 1 \Rightarrow a = b \). Case 3: \( a \) is odd, \( b \) is even. Then \( p(a) = a + 1 \) is even, and \( p(b) = b - 1 \) is odd. An even number cannot equal an odd number, so \( p(a) \ne p(b) \). A contradiction — this case is impossible. Hence \( p(a) = p(b) \Rightarrow a = b \), so \( p \) is one-one. Step 2 — Onto: Let \( m \in \mathbb{N} \) be arbitrary. If \( m \) is odd: Choose \( n = m + 1 \) (even, and \( n \ge 2 \in \mathbb{N} \)). Then \[p(n) = p(m+1) = (m+1) - 1 = m.\] If \( m \) is even: Choose \( n = m - 1 \) (odd). Since \( m \ge 2 \), we have \( n = m-1 \ge 1 \in \mathbb{N} \). Then \[p(n) = p(m-1) = (m-1) + 1 = m.\] In both cases, every \( m \in \mathbb{N} \) has a pre-image in \( \mathbb{N} \), so \( p \) is onto. Conclusion: \( p \) is both one-one and onto. In fact, \( p \) is its own inverse since applying it twice gives \[p(p(n)) = n \text{ for all } n \in \mathbb{N},\] confirming \( p \) is a bijection and \( p^{-1} = p \).
Answer: p is both one-one and onto. The function swaps each consecutive pair (2k−1, 2k), so every natural number is reached exactly once, making p a bijection that is its own inverse.