9.1 The Idea of a Function

SL 2.2

In this section you will learn
  • what a relation and a function are, using arrow (mapping) diagrams
  • the words domain, codomain and range
  • function notation: \(f(x)\), \(f : x \mapsto \ldots\), and other letters such as \(v(t)\) and \(C(n)\)
  • how a function is shown as a graph, and how to read the domain and range from it
  • the vertical line test for deciding whether a graph is a function
  • how a function can be used as a mathematical model

Relations and functions

In real life, two quantities are often linked by a rule. For example:

  • the perimeter \(P\) of a square depends on its side \(s\): \(\;P = 4s\);
  • the time \(t\) hours for a \(120\) km journey depends on the speed \(v\) km/h: \(\;t = \dfrac{120}{v}\).

Any rule that links the elements of one set to the elements of another set is called a relation. A relation is a function if every input gives exactly one output.

We can show a relation with an arrow diagram (also called a mapping diagram). In Figure 1 (left), \(X = \{-2, 1, 2\}\), \(Y = \{0, 1, 4, 9\}\) and the rule is “square the number”:

\[ -2 \mapsto (-2)^2 = 4, \qquad 1 \mapsto 1^2 = 1, \qquad 2 \mapsto 2^2 = 4 . \]

Every element of \(X\) has exactly one arrow, so this is a function. It does not matter that two inputs (\(-2\) and \(2\)) go to the same output.

In Figure 1 (right), the element \(5\) has two arrows (to \(3\) and to \(7\)). So this relation is not a function.

Figure 1: Left: a function. Right: a relation that is not a function.

Function, domain, codomain, range Not in the formula booklet

A function \(f\) from a set \(X\) to a set \(Y\) is a rule that gives each element of \(X\) exactly one element of \(Y\).

  • The domain is the set of inputs, \(X\).
  • The codomain is the set \(Y\) that the outputs are taken from.
  • The range is the set of outputs that actually occur. It is part of the codomain.

In Figure 1 (left), the domain is \(\{-2, 1, 2\}\), the codomain is \(\{0, 1, 4, 9\}\) and the range is \(\{1, 4\}\).

Example 1 Which of these relations, from \(X = \{1, 2, 3\}\), are functions? For each function, state the range.

(a) \(1 \mapsto 5,\; 2 \mapsto 6,\; 3 \mapsto 7\)

(b) \(1 \mapsto 4,\; 2 \mapsto 4,\; 3 \mapsto 4\)

(c) \(1 \mapsto 2,\; 1 \mapsto 3,\; 2 \mapsto 3,\; 3 \mapsto 1\)

(d) \(1 \mapsto 0,\; 3 \mapsto 2\)

(a) Each input has exactly one output: a function. Range \(\{5, 6, 7\}\).

(b) Each input has exactly one output (it is the same output, but that is allowed): a function. Range \(\{4\}\).

(c) The input \(1\) has two outputs: not a function.

(d) The input \(2\) has no output: not a function from \(X\).

Function notation

We usually give a function a letter, such as \(f\), \(g\) or \(h\). There are two common ways to write the rule:

\[ f(x) = x^2 + 3 \qquad\text{or}\qquad f : x \mapsto x^2 + 3 . \]

Both mean “\(f\) is the function that takes \(x\) and gives \(x^2 + 3\)”. We read \(f(x)\) as “\(f\) of \(x\)”. \(f(x)\) is the output (the image of \(x\)).

The domain is often written next to the rule, for example \(f(x) = x^2 + 3,\; x \in \mathbb{R}\), or \(x \geq 0\).

Other letters are used too, especially in applications: \(v(t)\) for a velocity at time \(t\), \(C(n)\) for the cost of \(n\) items, \(A(r)\) for the area of a circle of radius \(r\).

Example 2 Let \(f(x) = 5x - x^2\).

(a) Find \(f(2)\) and \(f(-3)\).

(b) Find and simplify \(f(a + 1)\).

(c) Solve \(f(x) = 4\).

(a) \(f(2) = 10 - 4 = 6\). \(\qquad f(-3) = -15 - 9 = -24\).

(b) Replace every \(x\) by \((a + 1)\):

\[ f(a + 1) = 5(a + 1) - (a + 1)^2 = 5a + 5 - a^2 - 2a - 1 = -a^2 + 3a + 4 . \]

(c) \(5x - x^2 = 4 \Rightarrow x^2 - 5x + 4 = 0 \Rightarrow (x - 1)(x - 4) = 0\), so \(x = 1\) or \(x = 4\).

Graphical representation of functions

The graph of a function \(f\) is the set of all points \((x, y)\) with \(y = f(x)\), where \(x\) is in the domain.

For example, let \(f(x) = (x - 1)^2 + 2\) with domain \(0 \leq x \leq 3\) (Figure 2).

Figure 2: The domain is on the \(x\)-axis and the range is on the \(y\)-axis.

The graph helps us in three ways.

  1. It shows where the function starts and where it ends: at \((0, 3)\) and \((3, 6)\).
  2. It shows the domain on the \(x\)-axis and the range on the \(y\)-axis. Here the domain is \(\{x : 0 \leq x \leq 3\}\) and the range is \(\{y : 2 \leq y \leq 6\}\). The lowest point is the vertex \((1, 2)\), not an end point.
  3. It shows that each \(x\) gives exactly one \(y\). For example \(f(0) = 3\) and \(f(1) = 2\).

Testing functions: the vertical line test

Not every curve is the graph of a function. The circle \(x^2 + y^2 = 25\) passes through \((3, 4)\) and \((3, -4)\), so the input \(x = 3\) has two outputs. A circle is not a function.

Look at Figure 3.

  • Left: \(y = x^3 - 3x + 1\), \(\;-2 \leq x \leq 2.5\). Every vertical line \(x = a\) (with \(a\) in the domain) meets the curve once. For example \(x = -1\) meets it only at \((-1, 3)\), and \(x = 1\) only at \((1, -1)\). This is a function.
  • Right: \(y^2 = x + 2\). The line \(x = 2\) meets the curve at \((2, 2)\) and \((2, -2)\). This is not a function.
Figure 3: The vertical line test.

Vertical line test Not in the formula booklet

A graph represents a function if and only if every vertical line \(x = a\), with \(a\) in the domain, meets the graph exactly once.

Example 3 Use the graphs in Figure 4 to decide whether each relation is a function. Give a reason.

(a) \(y = (x - 1)^2,\; x \in \mathbb{R}\)

(b) \(y = -\sqrt{x},\; x \geq 0\)

(c) \(y^2 = 4x,\; x \geq 0\)

Figure 4

(a) Every vertical line meets the parabola exactly once. It is a function.

(b) For each \(x \geq 0\) the vertical line meets the curve exactly once, at \(\big(x, -\sqrt{x}\big)\). It is a function.

(c) \(y^2 = 4x\) means \(y = \pm 2\sqrt{x}\). For \(x > 0\) the vertical line meets the curve twice, for example at \((1, 2)\) and \((1, -2)\). It is not a function.

Notice: the symbol \(\sqrt{x}\) always means the non-negative square root. So \(y = \sqrt{x}\) and \(y = -\sqrt{x}\) are functions, but \(y = \pm\sqrt{x}\) is not.

A function as a mathematical model

Functions are used to model real situations. When we use a function as a model, we must also think about the domain that makes sense in the real situation.

Example 4 A stone is thrown upwards. Its height in metres after \(t\) seconds is modelled by

\[ h(t) = 20t - 5t^2 . \]

(a) Find \(h(1)\) and explain what it means.

(b) Find the time when the stone lands, and hence state a sensible domain for \(h\).

(c) Find the range of \(h\) for this domain.

(a) \(h(1) = 20 - 5 = 15\). After \(1\) second the stone is \(15\) m above the ground.

(b) \(h(t) = 0 \Rightarrow 5t(4 - t) = 0 \Rightarrow t = 0\) or \(t = 4\). The stone lands after \(4\) s. A sensible domain is \(0 \leq t \leq 4\) (negative times, or times after landing, have no meaning).

(c) \(h(t) = -5(t^2 - 4t) = -5(t - 2)^2 + 20\). The maximum height is \(20\) m at \(t = 2\), and the least height is \(0\). The range is \(0 \leq h(t) \leq 20\).

Common errors

✗ Wrong ✓ Right Why
“Two inputs give the same output, so it is not a function.” It can still be a function. Only one input with two outputs breaks the rule.
\(f(a + 1) = 5a + 1 - a^2 + 1\) \(f(a + 1) = 5(a + 1) - (a + 1)^2\) Replace every \(x\) by the whole bracket \((a + 1)\).
Range of Figure 2 is \(3 \leq y \leq 6\) \(2 \leq y \leq 6\) The least value is at the vertex, not at an end point.
Using a horizontal line to test for a function Use vertical lines A vertical line fixes one input \(x\).
\(y = \pm\sqrt{x}\) is a function It is not Each \(x > 0\) gives two values of \(y\).

Exercises

1 The relation \(R\) maps \(\{0, 1, 2, 3\}\) to \(\{1, 2, 3, 4, 5\}\) by \(0 \mapsto 1\), \(1 \mapsto 3\), \(2 \mapsto 5\), \(3 \mapsto 3\). Is \(R\) a function? If so, state its domain and range.

Every input has exactly one output, so \(R\) is a function. Domain \(\{0, 1, 2, 3\}\); range \(\{1, 3, 5\}\).

2 A function \(g\) has domain \(\{-1, 0, 1, 2\}\) and \(g(x) = 2x^2 - 1\). List the range of \(g\).

\(g(-1) = 1\), \(g(0) = -1\), \(g(1) = 1\), \(g(2) = 7\). The range is \(\{-1, 1, 7\}\).

3 Let \(f(x) = 3 - 2x\). Find

(a) \(f(4)\)

(b) \(f\!\left(-\dfrac{1}{2}\right)\)

(c) the value of \(x\) for which \(f(x) = 11\).

(a) \(3 - 8 = -5\).

(b) \(3 + 1 = 4\).

(c) \(3 - 2x = 11 \Rightarrow x = -4\).

4 Let \(f(x) = x^2 - 4x\). Find and simplify \(f(x + 2)\).

\(f(x + 2) = (x + 2)^2 - 4(x + 2) = x^2 + 4x + 4 - 4x - 8 = x^2 - 4\).

5 Let \(g(x) = \dfrac{6}{x + 1}\), \(x \neq -1\). Solve \(g(x) = 3x - 1\).

\(6 = (3x - 1)(x + 1) = 3x^2 + 2x - 1 \Rightarrow 3x^2 + 2x - 7 = 0\).

\[ x = \frac{-2 \pm \sqrt{4 + 84}}{6} = \frac{-2 \pm \sqrt{88}}{6} = \frac{-1 \pm \sqrt{22}}{3} . \]

Neither value is \(-1\), so both are solutions.

6 Which of these are functions of \(x\)? Give a reason.

(a) \(y = x^3 - x\)

(b) \(x^2 + y^2 = 9\)

(c) \(x = 4\)

(d) \(y = 4\)

(a) Yes: each \(x\) gives one value \(x^3 - x\).

(b) No: for example \(x = 0\) gives \(y = 3\) and \(y = -3\).

(c) No: this is a vertical line, so the input \(4\) has infinitely many outputs.

(d) Yes: every \(x\) gives the one value \(4\) (a constant function).

7 The function \(f(x) = 2x + 1\) has domain \(-1 \leq x \leq 3\). Sketch the graph and state the range.

The graph is a straight line segment from \((-1, -1)\) to \((3, 7)\). The function is increasing, so the range is \(-1 \leq f(x) \leq 7\).

8 The function \(h(x) = x^2 - 2x\) has domain \(-1 \leq x \leq 4\). Find the range of \(h\).

\(h(x) = (x - 1)^2 - 1\), with vertex \((1, -1)\) inside the domain. End points: \(h(-1) = 3\), \(h(4) = 8\).

The least value is \(-1\) and the greatest is \(8\). Range: \(-1 \leq h(x) \leq 8\).

9 A taxi company charges a fixed amount of $4 plus $1.50 per kilometre.

(a) Write down a function \(C(d)\) for the cost of a journey of \(d\) km.

(b) Find \(C(12)\).

(c) A journey cost $31. How long was it?

(a) \(C(d) = 4 + 1.5d\), \(\;d \geq 0\).

(b) \(C(12) = 4 + 18 = \$22\).

(c) \(4 + 1.5d = 31 \Rightarrow 1.5d = 27 \Rightarrow d = 18\) km.

10 A ball is kicked upwards. Its height in metres after \(t\) seconds is \(h(t) = 1 + 14t - 7t^2\).

(a) Find the maximum height.

(b) Find, to 3 significant figures, the time when it hits the ground.

(c) State a sensible domain for \(h\).

(a) \(h(t) = -7(t^2 - 2t) + 1 = -7(t - 1)^2 + 8\). The maximum height is \(8\) m (at \(t = 1\)).

(b) \(-7(t - 1)^2 + 8 = 0 \Rightarrow (t - 1)^2 = \dfrac{8}{7} \Rightarrow t = 1 + \sqrt{\dfrac{8}{7}} = 2.07\) s (the other root is negative).

(c) \(0 \leq t \leq 2.07\) (approximately).