Relations and functions: domain, codomain and range

Unit 2 · Functions

What a function is, how to read its domain, codomain and range, and how to find the natural domain and the range of a given rule.

Relations

A relation from a set $A$ to a set $B$ is any set of ordered pairs $(a, b)$ where $a \in A$ and $b \in B$. For example, "is less than" from ${1, 2, 3}$ to ${2, 3}$ gives ${(1,2), (1,3), (2,3)}$. Here $1$ is related to two different elements, so this relation is not a function.

Functions

A function $f: A \to B$ is a rule that gives each element $x$ of $A$ exactly one element $f(x)$ of $B$. Two conditions matter: every $x \in A$ must have an image, and it must have only one.

Arrow diagram of f(x) = x² from {−1, 1, 2} to {1, 2, 4, 5}

In the diagram $f(x) = x^2$ with domain $A = {-1, 1, 2}$ and codomain $B = {1, 2, 4, 5}$. Both $-1$ and $1$ go to $1$, which is allowed: two inputs may share one output. The range is ${1, 4}$, while $2$ and $5$ are in the codomain but are never reached.

Careful: when only a rule such as $f(x) = \dfrac{1}{x}$ is given, take the natural domain: the largest set of real numbers for which the rule makes sense. Here that is $x \ne 0$.

Vertical line test

A curve in the plane is the graph of a function of $x$ only if each vertical line $x = c$ cuts it at most once (once if $c$ is in the domain, not at all otherwise). The circle $x^2 + y^2 = 1$ fails the test, because $x = 0$ cuts it at $(0, 1)$ and $(0, -1)$.

Finding the natural domain

Three things stop a rule from working for a real number $x$:

  1. A zero denominator: $\dfrac{1}{g(x)}$ needs $g(x) \ne 0$.
  2. A negative number under a square root (or any even root): $\sqrt{g(x)}$ needs $g(x) \ge 0$.
  3. Both together: $\dfrac{1}{\sqrt{g(x)}}$ needs $g(x) > 0$.

Write the answer as an interval or a union of intervals. $[a, b]$ is a closed interval (ends included), $(a, b)$ is an open interval (ends not included), and $\cup$ joins pieces. $\mathbb{R}$ is the set of real numbers.

Example: Find the natural domain of $f(x) = \dfrac{\sqrt{x - 2}}{x - 5}$.

The square root needs $x - 2 \ge 0$, so $x \ge 2$. The denominator needs $x \ne 5$. Remove $5$ from $[2, \infty)$:

Answer: $[2, 5) \cup (5, \infty)$.

Finding the range

Method 1: complete the square for quadratics. Method 2: solve for $x$. Put $y = f(x)$, solve for $x$ in terms of $y$, and keep the $y$ for which a real $x$ in the domain exists.

Example: Find the range of $f(x) = x^2 - 4x + 7$ (a) on $\mathbb{R}$, (b) on the domain $[0, 3]$.

Complete the square: $f(x) = (x - 2)^2 + 3$. The vertex is $(2, 3)$ and the parabola opens upwards.

(a) $(x-2)^2 \ge 0$ for all real $x$ and takes every value from $0$ upwards, so $f(x) \ge 3$. Range $= [3, \infty)$.

(b) $x = 2$ lies in $[0, 3]$, so the minimum $f(2) = 3$ is reached. At the ends, $f(0) = 7$ and $f(3) = 4$. The larger end value is $7$. The graph is continuous, so every value from $3$ to $7$ occurs.

Answer: (a) $[3, \infty)$; (b) $[3, 7]$.

Exam tip: Whenever the domain is restricted, as in "$f(x) = \dots,\ 0 \le x \le 3$", check the vertex and both end points. Many students find the vertex only and lose the marks for the range. Always state the interval with the correct brackets.