Example 12: Swapping neighbours on is bijective
Show that , given by is both one-one and onto.
One-one: Let .
If is odd and is even, then , so . This is impossible, since even minus odd is odd. In the same way, even and odd is impossible.
If both are odd, . If both are even, . Thus is one-one.
Onto: Let . If is odd , then is even and . If is even , then is odd and . Thus is onto.
Hence is both one-one and onto.
Want the reason behind every step, the basics and the checks?
Work out a few values: , , , , and so on. The function swaps each odd number with the even number just after it. Odd inputs go to even outputs and even inputs go to odd outputs, so an odd input and an even input can never collide; and inside each parity the rule is a plain shift, which never repeats. Every output is the partner of exactly one input, so is one-one and onto. Doing twice puts every number back where it started.
- Given
- A two-piece rule on : add 1 to odd numbers, subtract 1 from even numbers.
- To show
- (a) is one-one. (b) is onto.
- Plan
- (1) Check maps into , and note which parity each piece produces. (2) One-one: assume and go through all four parity combinations of . (3) Onto: for an arbitrary , split into odd and even and construct a preimage. (4) Conclude.
Basics you need
Every natural number is odd or even, never both. Even numbers are (); odd numbers are (). Odd is even, even is odd, and an even number minus an odd number is odd. Basics: integers, even and odd
To evaluate , first decide which piece belongs to (here: odd or even), then use only that formula. Basics: what a function is
One-one: . Onto: every in the codomain is for some in the domain. Basics: one-one and onto
When a claim is about arbitrary , and each can be odd or even, there are four combinations. Proving the claim in all four proves it outright. Basics: proving and disproving
Solution
Check the outputs lie in , and note their parity
- If is odd, is a natural number, and it is even.
- If is even, then , so is a natural number, and it is odd.
1 2 3 4 5 6 7 8 parity odd even odd even odd even odd even 2 1 4 3 6 5 8 7 Each neighbouring pair swaps places, shown in matching colours. Every output receives exactly one arrow: is one-one and onto. The check matters: subtracting 1 from a natural number can give , but only when , and 1 is odd, so it uses the other piece. The parity observation (odd goes to even, even goes to odd) is the key to the one-one proof in the next step.The smallest even natural number is 2, so for even we have .One-one, mixed case: odd , even is impossible
Suppose . First suppose is odd and is even. Then the equation reads
But is an even number minus an odd number, which is odd, and 2 is even. An odd number cannot equal 2. So this case cannot happen. The case " even, odd" is ruled out the same way: it gives , so , with again even minus odd, hence odd.
The book says only that "is impossible"; the reason is parity. A second way to see it: by Step 1, is even and is odd, and an even number cannot equal an odd number. Either way, when , the inputs must have the same parity.Even minus odd is odd: if and , then , which is odd.One-one, same-parity cases
Now the inputs have the same parity, so the same formula applies to both.
- Both odd: reads , so (subtract 1 from both sides).
- Both even: reads , so (add 1 to both sides).
All four parity combinations are covered: the two mixed ones cannot occur, and the two same-parity ones force . Hence is one-one.
Within one piece the function is just a shift ( or ), and a shift can be undone, so equal outputs give equal inputs. The danger in a piecewise function is a collision between pieces, which Step 2 excluded. Only after checking both kinds of case is the proof complete.Proof by cases: odd or even, odd or even, gives four cases that cover every pair. Basics: proving and disprovingOnto: every odd and every even has a preimage
Take an arbitrary . It is odd or even.
- odd, say with . Choose . This is an even natural number, so the second piece applies: , which is . ✓
- even, say with . Choose . This is an odd natural number (it is at least 1), so the first piece applies: , which is . ✓
Every is an image, so is onto.
Because swaps neighbours, the preimage of is simply its partner: if is odd, if is even. For each candidate we checked three things: it is in , it has the parity that selects the formula we used, and the formula really gives . The condition for even guarantees .Conclude: is a bijection, and its own inverse
is one-one (Steps 2 and 3) and onto (Step 4), so is both one-one and onto (bijective).
A bonus fact: applying twice returns every number to itself. If is odd, is even, so . If is even, is odd, so . So undoes itself, which is another way to see that it is a bijection.
If for every , then gives (one-one), and every equals , the image of (onto). This idea becomes the inverse function in Section 1.4.
swaps each odd number with the next even number . It is one-one (odd and even inputs land on outputs of opposite parity, so they cannot collide, and within each parity is a shift) and onto (an odd is , an even is ). So is a bijection, and for all .
Balloon Pop, in the chapter’s Games tab. Machine 3 is this function: every balloon is hit exactly once. Play Balloon Pop ↗
Apply to : the outputs are the numbers to , each exactly once. For single values: is odd, , so the preimage is , and . ✓ is even, so the preimage is , and . ✓
- Checking only the same-parity cases. Each piece is one-one on its own, but that does not stop an odd input and an even input from sharing an output. The mixed cases must be ruled out (Step 2). Compare Exercise 1.2 Q9, where exactly such cross-piece collisions happen.
- Calling "impossible" without a reason. On its own, is perfectly possible (for example ). It is impossible here only because is even and is odd.
- Using the wrong formula for the preimage. The preimage of an odd is the even number , which is evaluated with , not .
- For a piecewise function, prove one-one in two parts: no collisions between pieces, and no collisions within a piece.
- Parity is a quick way to rule out collisions: if the pieces produce outputs of different kinds, they cannot share an output.
- A function that is its own inverse () is automatically a bijection.
Every fact used, and where it comes from
| Fact | Used in | Source |
|---|---|---|
| Every natural number is exactly one of odd, even | Steps 1–4 | Definition of odd and even |
| Odd is even; even is odd; even − odd is odd | Steps 1, 2 | Parity arithmetic |
| Definition of one-one | Steps 2, 3 | Definition 5, Section 1.3 (Lesson: types of functions) |
| Definition of onto | Step 4 | Definition 6, Section 1.3 |
| Definition of bijective | Step 5 | Definition 7, Section 1.3 |
| and inverses | Step 5 remark | Section 1.4 (Lesson: invertible functions) |
Tell us if something on this page is wrong or unclear, or if you would like a fuller explanation, another method or a new feature. Send feedback on this problem →