- Foundation
- About 12 min
- 5 practice questions
What a function is
Recognise a function as a special relation, use f(x) notation, and name the domain, codomain and range of a function.
If something looks wrong, please tell us.
A function is a rule that takes an input and gives back exactly one output. The idea is everywhere: the cost of n pens, the area of a square of side x, the marks given to each roll number. In mathematics a function is built from the relations of the earlier course, with one extra condition. This lesson explains that condition, the f(x) notation and the three sets attached to every function: domain, codomain and range.
A relation with one condition
Let A and B be non-empty sets. A function f from A to B, written f : A → B, is a relation from A to B in which every element of A has exactly one image in B. Two things can go wrong. If some element of A has no image, the relation is not a function. If some element of A has two or more images, it is not a function either. Two different elements of A may, however, share the same image; that is allowed.
If (a, b) belongs to f, we write f(a) = b and call b the image of a, and a a pre-image of b. The set A is the domain, the set B is the codomain, and the set of all images actually produced is the range. The range is always a subset of the codomain, and it may be smaller.
How to test a relation
- Go through every element of the domain, one at a time.
- Each must appear as a first entry exactly once.
- Second entries may repeat; that does not matter.
- Elements of the codomain may be left unused; that does not matter either.
Worked example 1: which relations are functions?
Let A = {1, 2, 3} and B = {4, 5, 6}. Consider three relations from A to B. R1 = {(1, 4), (2, 5), (3, 5)}: each of 1, 2, 3 appears once as a first entry, so R1 is a function, even though 2 and 3 share the image 5 and 6 is unused. R2 = {(1, 4), (1, 5), (2, 6), (3, 6)}: the element 1 has two images, 4 and 5, so R2 is not a function. R3 = {(1, 4), (2, 5)}: the element 3 has no image, so R3 is not a function from A to B.
The f(x) notation
Functions on numbers are usually given by a formula. If f(x) = 2x − 3, then to find f(4) you replace every x by 4: f(4) = 2(4) − 3 = 5. To find the input that gives a certain output, set the formula equal to that output and solve: f(a) = 7 means 2a − 3 = 7, so a = 5. A function whose domain and codomain are subsets of the real numbers R is called a real function. When only a formula is given, its domain is taken to be the largest set of real numbers for which the formula makes sense.
Worked example 2: finding the range
Let f : {−2, −1, 0, 1, 2} → Z be given by f(x) = x² + 1. Compute every image: f(−2) = 5, f(−1) = 2, f(0) = 1, f(1) = 2 and f(2) = 5. The range is the set of these values written once each: {1, 2, 5}. The codomain is the whole of Z, which is far bigger than the range. Notice that −2 and 2 share the image 5; this is still a function.
Worked example 3: evaluating with an expression
If f(x) = x² − 3x, find f(−2) and f(a + 1). For f(−2), use brackets: (−2)² − 3(−2) = 4 + 6 = 10. For f(a + 1), replace x by the whole bracket: (a + 1)² − 3(a + 1) = a² + 2a + 1 − 3a − 3 = a² − a − 2. The most common error is to write −2² = −4; the bracket keeps the sign inside the square.
A function gives every element of its domain exactly one image. Range = the set of images actually produced, always a subset of the codomain.
Key takeaways
To test a relation, check each domain element once: exactly one image each. Shared images and unused codomain elements are allowed. Substitute with brackets when evaluating f at a negative number or an expression. Find the range by listing the images, and do not confuse it with the codomain.
Check your understanding
-
1. Which relation from A = {1, 2, 3} to B = {a, b} is a function?
- {(1, a), (2, a), (3, b)}
- {(1, a), (2, b)}
- {(1, a), (1, b), (2, a), (3, b)}
- {(1, a), (2, b), (3, a), (3, b)}
Show answer
Answer: A. Each of 1, 2 and 3 has exactly one image. The others leave 3 without an image, or give 1 or 3 two images.
-
2. If f(x) = x² − 3x, what is f(−2)?
- −2
- 2
- −10
- 10
Show answer
Answer: D. f(−2) = (−2)² − 3(−2) = 4 + 6 = 10.
-
3. f : {−1, 0, 1, 2} → Z is given by f(x) = x². What is the range of f?
- {−1, 0, 1, 2}
- {0, 1, 4}
- {0, 1, 2, 4}
- Z
Show answer
Answer: B. The images are 1, 0, 1 and 4. Written once each, the range is {0, 1, 4}.
-
4. If f(x) = 3x + 2 and f(a) = 11, what is a?
- 3
- 35
- 13
- 9
Show answer
Answer: A. 3a + 2 = 11 gives 3a = 9, so a = 3.
-
5. For a function f : A → B, what is the set B called?
- The domain
- The range
- The pre-image
- The codomain
Show answer
Answer: D. A is the domain and B is the codomain. The range is the set of images actually produced, a subset of B.
Sign in to keep track of the lessons you finish.