• Foundation
  • About 15 min
  • 5 practice questions

From relations to functions: the function test, domain and range

Decide whether a relation is a function using the 'exactly one image' test, find the domain and range of simple functions, and count how many functions exist between two small sets.

If something looks wrong, please tell us.

A relation can pair an element with many partners or with none. A function is the best-behaved kind of relation: each input has exactly one output. Functions are the main objects of the next topics in higher mathematics, and this lesson gives the test that separates functions from other relations, using only what you know about relations and sets.

Definition and the test

A function f from a set A to a set B is a relation in which every element of A is related to exactly one element of B. We write f : A → B and, if (a, b) is in the function, f(a) = b, where b is the image of a. The set A is the domain, B is the codomain, and the set of images actually reached is the range. In an arrow diagram, the test is: every element of A has exactly one arrow leaving it. Zero arrows fails and two arrows fails. Two different inputs may share the same image, and some elements of B may receive no arrow.

A relation from A to B is a function when every element of A has exactly one image. Domain = A. Range = the set of images, a subset of the codomain. Different inputs may have the same image.

Worked example 1: is it a function?

Let A = {1, 2, 3} and B = {a, b}. Test three relations. R₁ = {(1, a), (2, b), (3, a)}: every element of A has exactly one arrow, and the elements 1 and 3 share the image a, which is allowed. R₁ is a function. R₂ = {(1, a), (1, b), (2, a), (3, b)}: the element 1 has two images, so R₂ is not a function. R₃ = {(1, a), (2, b)}: the element 3 has no image, so R₃ is not a function from A to B.

Functions given by formulas

When a rule such as f(x) = 2x + 1 is given with a domain, the range is found by applying the rule to every element of the domain. If no domain is stated for a real-number rule, the domain is taken to be all real numbers for which the rule makes sense.

Worked example 2: range of a rule

Let f(x) = 2x + 1 with domain {0, 1, 2, 3}. Then f(0) = 1, f(1) = 3, f(2) = 5 and f(3) = 7, so the range is {1, 3, 5, 7}. Now let g(x) = x² with domain {−2, −1, 0, 1, 2}. The images are 4, 1, 0, 1, 4, so the range is {0, 1, 4}. Two different inputs, such as −2 and 2, share one output, and this is still a function.

Worked example 3: the natural domain

For f(x) = 1/(x − 3) we cannot divide by zero, so x = 3 must be excluded. The domain is all real numbers except 3, written R − {3}. For f(x) = √(x − 2) the number under the root must not be negative, so x − 2 ≥ 0 and the domain is [2, ∞). For f(x) = x² the domain is all of R, but the range is only the non-negative numbers [0, ∞), since a square is never negative.

Worked example 4: counting functions

How many functions are there from a set A with 3 elements to a set B with 2 elements? Each of the 3 elements of A has to choose one image from the 2 elements of B, independently. So there are 2 × 2 × 2 = 2³ = 8 functions. In general, there are q^p functions from a set with p elements to a set with q elements. Compare this with relations: there are 2^(pq) = 2⁶ = 64 relations from A to B, and only 8 of them are functions.

Common mistakes

  • Rejecting a relation because two inputs share an output: that is allowed. The failure is one input with two outputs, or with none.
  • Taking the codomain as the range: the range can be smaller.
  • Forgetting to exclude the values that make a denominator zero or a square-root argument negative.
  • Counting functions as p^q instead of q^p: the number of choices is the size of B, repeated once for each element of A.

Key takeaways: a function gives every input exactly one output. Domain is the inputs, range is the outputs actually used, and the codomain is the set where outputs are allowed to lie. The number of functions from a p-element set to a q-element set is q^p.

Check your understanding

  1. 1. Which relation from {1, 2, 3} to {a, b} is a function?

    1. {(1, a), (2, a), (3, b)}
    2. {(1, a), (1, b), (2, a), (3, b)}
    3. {(1, a), (2, b)}
    4. {(1, a), (2, b), (3, b), (3, a)}
    Show answer

    Answer: A. Each element of {1, 2, 3} has exactly one image in {(1, a), (2, a), (3, b)}. In the others, 1 has two images, 3 has no image, or 3 has two images.

  2. 2. What is the range of f(x) = 2x + 1 on the domain {0, 1, 2, 3}?

    1. {0, 1, 2, 3}
    2. {1, 3, 5, 7, 9}
    3. {1, 3, 5, 7}
    4. {2, 4, 6, 8}
    Show answer

    Answer: C. f(0) = 1, f(1) = 3, f(2) = 5 and f(3) = 7, so the range is {1, 3, 5, 7}.

  3. 3. What is the domain of f(x) = 1/(x − 3) over the real numbers?

    1. R
    2. R − {3}
    3. x > 3
    4. R − {0}
    Show answer

    Answer: B. The expression is undefined when x − 3 = 0, that is x = 3. Every other real number works, including numbers less than 3.

  4. 4. What is the domain of f(x) = √(x − 2)?

    1. (2, ∞)
    2. (−∞, 2]
    3. R
    4. [2, ∞)
    Show answer

    Answer: D. We need x − 2 ≥ 0, so x ≥ 2. The value x = 2 is allowed, since √0 = 0.

  5. 5. How many functions are there from a set of 3 elements to a set of 2 elements?

    1. 6
    2. 8
    3. 9
    4. 64
    Show answer

    Answer: B. Each of the 3 elements has 2 choices of image, so the number is 2³ = 8. (The number 64 counts all relations, 2⁶.)

Privacy · Terms · Refunds · Delivery