Function, domain, codomain and range
A vending machine gives exactly one item for each button. The buttons are the domain, the items it can hold form the codomain, and the items it really gives out form the range.
A function f : A → B gives each element of A exactly one element of B. A is the domain, B is the codomain, and the set of values f(x) actually obtained is the range, which lies inside B.
Formula: Range = {f(x) : x in A} ⊆ B
Rule 1: Find the range from a list — Put each element of the domain into the rule.
- Easy: f(x) = 2x + 1 on A = {1, 2, 3} gives range {3, 5, 7}.
- Medium: f(x) = x² on {−2, −1, 0, 1, 2} gives range {0, 1, 4}, smaller than the codomain Z.
- Exam-type: f : R → R, f(x) = x² + 1 has range [1, ∞) because x² ≥ 0.
Rule 2: Is it a function? — Every input needs exactly one output.
- Easy: {(1, 4), (2, 5), (3, 6)} is a function from {1, 2, 3}.
- Medium: {(1, 4), (1, 5), (2, 6)} is not a function: 1 has two outputs.
- Exam-type: {(1, 4), (2, 5)} is not a function from {1, 2, 3}: the input 3 has no output.
Many inputs may share one output, but one input never has two outputs.
Writing the codomain when the question asks for the range.
Domain = Dispatch, Codomain = Cupboard, Range = what Really came out.
Practice questions
- 1Find the range of f(x) = 3x − 1 on {0, 1, 2}.
- 2Find the range of f(x) = x² on {−3, −1, 0, 1, 3}.
- 3Is {(1, 2), (2, 2), (3, 2)} a function from {1, 2, 3}?
- 4Find the range of f : R → R, f(x) = x² − 4.
- 5Is {(1, 5), (2, 6), (2, 7)} a function? Why?
- 6Find the range of f(x) = |x| on the integers from −3 to 3.
- 7f : R → R, f(x) = 5. State the range.
- 8Find the range of f : R → R, f(x) = 2x + 3.
Show answers (try them yourself first)
- 1{−1, 2, 5}
- 2{0, 1, 9}
- 3Yes, each input has exactly one output (the same output is allowed)
- 4[−4, ∞), because x² ≥ 0
- 5No, the input 2 has two outputs, 6 and 7
- 6{0, 1, 2, 3}
- 7{5}
- 8All real numbers, since every y has x = (y − 3) / 2
One-one and onto functions
A bus where every passenger has their own seat is "one-one". A bus where no seat stays empty is "onto". A good bus has both.
f : A → B is one-one if different inputs always give different outputs, i.e. f(a) = f(b) gives a = b. It is onto if every element of B is an output of some element of A. A function that is both is bijective.
Formula: One-one: f(a) = f(b) ⇒ a = b. Onto: for every y in B there is x in A with f(x) = y.
Rule 1: Test one-one — Assume f(a) = f(b) and try to prove a = b, or find two inputs with the same output.
- Easy: f(x) = 3x − 2: 3a − 2 = 3b − 2 gives a = b, so f is one-one.
- Medium: f(x) = x² on R is not one-one: f(2) = f(−2) = 4.
- Exam-type: f(x) = x³ on R: a³ = b³ gives a = b (the real cube root is unique), so f is one-one.
Rule 2: Test onto — Solve y = f(x) for x and check x lies in the domain.
- Easy: f : R → R, f(x) = 2x + 5 is onto: x = (y − 5) / 2 exists for every y.
- Medium: f : R → R, f(x) = x² is not onto: −1 has no real x.
- Exam-type: f : R → [0, ∞), f(x) = x² is onto but not one-one.
Changing the codomain can change whether a function is onto, but never whether it is one-one.
Declaring x² onto R; negative numbers are never obtained.
One-one = no two share a seat. Onto = no seat left empty.
Spot the difference
| One-one | Onto |
|---|---|
| No two inputs share an output | No codomain element is left out |
| Test: f(a) = f(b) gives a = b | Test: solve y = f(x) for x |
| Concerns the domain side | Concerns the codomain side |
Practice questions
- 1Is f(x) = 5x + 1 one-one on R?
- 2Is f : R → R, f(x) = x² − 3 one-one?
- 3Is f : R → R, f(x) = 4x − 7 onto?
- 4Show that f(x) = x³ + 2 is both one-one and onto from R to R.
- 5Is f : N → N, f(x) = x + 1 onto? Is it one-one?
- 6Is f : R → R, f(x) = |x| one-one? Onto?
- 7Is f : R → R, f(x) = x² + 1 onto R? What codomain would make it onto?
- 8Is f : Z → Z, f(x) = 2x onto? Is it one-one?
Show answers (try them yourself first)
- 1Yes: 5a + 1 = 5b + 1 gives a = b
- 2No: f(1) = f(−1) = −2
- 3Yes: x = (y + 7) / 4 for every y
- 4One-one: a³ + 2 = b³ + 2 gives a = b. Onto: x = ∛(y − 2) exists for every y
- 5One-one yes. Onto no: 1 has no x in N (x would be 0)
- 6Neither: f(2) = f(−2); negative numbers are never obtained
- 7Not onto, since y < 1 is never reached. The codomain [1, ∞) makes it onto
- 8One-one yes. Onto no: odd integers are not obtained
Counting functions
Three guests and four chairs: each guest picks a chair. How many ways can they sit, and in how many ways does no chair get two guests?
Let A have m elements and B have n elements. Each element of A can go to any of n elements of B. If every element must go to a different one, we get one-one functions.
Formula: All functions = n^m. One-one functions = n (n − 1) ... (n − m + 1) (n ≥ m). Bijections (m = n) = n!
Rule 1: Count functions — Multiply the number of choices for each element.
- Easy: From a 2-element set to a 3-element set there are 3 × 3 = 9 functions.
- Medium: One-one functions from a 2-element set to a 3-element set: 3 × 2 = 6.
- Exam-type: Bijections from a 4-element set to itself: 4! = 24.
Rule 2: Count onto functions (small cases) — Subtract the functions that miss some element.
- Easy: Onto functions from a 3-element set to a 2-element set: 2³ − 2 = 6 (remove the two constant functions).
- Medium: A one-one function between sets of the same finite size is automatically onto.
- Exam-type: A one-one function from a 4-element set to a 3-element set is impossible.
For finite sets of the same size, one-one and onto go together.
Using m^n instead of n^m (the number of choices is the size of the codomain).
Each of m inputs picks from n: n times itself m times.
Practice questions
- 1How many functions are there from a 3-element set to a 2-element set?
- 2How many functions from a 2-element set to a 5-element set?
- 3How many one-one functions from a 3-element set to a 4-element set?
- 4How many bijections from a 5-element set to itself?
- 5Can there be a one-one function from a 5-element set to a 4-element set?
- 6How many onto functions from a 3-element set to a 2-element set?
- 7A function from {1, 2, 3} to {a, b, c} is one-one. Must it be onto?
- 8How many functions from a 4-element set to a 2-element set are not onto?
Show answers (try them yourself first)
- 12³ = 8
- 25² = 25
- 34 × 3 × 2 = 24
- 45! = 120
- 5No, two elements would have to share an image
- 62³ − 2 = 6
- 7Yes: the sets have the same size, so one-one means onto
- 8Only the 2 constant functions are not onto