Graph of a function
Learning Objectives
- Define the graph of a function as a set of ordered pairs.
- Sketch the graph of a function given by a formula or a table.
- Use the vertical line test to decide whether a curve is the graph of a function.
- Read off domain, image, and specific values from a graph.
- Recognise the graphs of \(x \mapsto x\), \(x \mapsto x^2\), \(x \mapsto |x|\), and constant functions.
Motivation
We now have both ingredients we need: Lesson 1 told us what a function \(f \colon A \to B\) is, and Lesson 2 gave us the Cartesian product \(A \times B\) — the set of all ordered pairs with first component in \(A\) and second component in \(B\). We are ready to combine them.
The graph of a function collects every input-output assignment into a single subset of \(A \times B\). When \(A\) and \(B\) are subsets of \(\mathbb{R}\), that subset lives in the Cartesian plane and we can draw it — turning the abstract idea "for each input there is one output" into a picture we can inspect at a glance.
Graph of a function
Let \(f \colon A \to B\) be a function. The graph of \(f\) is the set of all ordered pairs
\[G_f = \{\,(a,\, f(a)) \mid a \in A\,\} \subseteq A \times B.\]
Each element of the domain contributes exactly one pair to the graph, so \(G_f\) has exactly as many elements as \(A\) (when \(A\) is finite) or, more generally, \(G_f\) and \(A\) are in one-to-one correspondence.
Graph of a finite function
Let \(A = \{1, 2, 3\}\), \(B = \{a, b, c\}\), and \(f(1) = b,\; f(2) = a,\; f(3) = b\). The graph is
\[G_f = \{(1, b),\; (2, a),\; (3, b)\}.\]
It contains three pairs — one per element of the domain. The pair \((1, b)\) records that \(f(1) = b\); the pair \((3, b)\) records that \(f(3) = b\). Both pairs have the same second component, but different first components — that is fine. The definition only forbids two pairs with the same first component and different second components.
Graphs in the Cartesian plane
When both \(A\) and \(B\) are subsets of \(\mathbb{R}\), each pair \((x, f(x))\) is a point in the Cartesian plane. Plotting all such points produces the familiar "curve" we associate with a function.
Strictly, the graph is the set of points, not the drawing — but drawing is the most common way to interact with it, and we will freely speak of "the graph" to mean the picture.
Reference graphs
The following four functions appear throughout this course and the ones that follow. Their graphs are worth committing to memory.
The identity function \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = x\) — the line \(y = x\) through the origin with slope \(1\). It passes through \((0,0)\), \((1,1)\), \((-2,-2)\).
The squaring function \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = x^2\) — a parabola opening upward, with vertex at the origin. It passes through \((0,0)\), \((1,1)\), \((-1,1)\), \((2,4)\), \((-2,4)\). The symmetry about the \(y\)-axis comes from \(f(-x) = (-x)^2 = x^2 = f(x)\); we will name this property (evenness) in a later unit.
The absolute-value function \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = |x|\) — two rays meeting at the origin: for \(x \geq 0\) it coincides with \(y = x\), and for \(x < 0\) with \(y = -x\). A V-shape symmetric about the \(y\)-axis.
A constant function \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = 3\) — every input maps to \(3\), so the graph is the horizontal line \(y = 3\). More generally, the graph of \(f(x) = c\) is the horizontal line \(y = c\).
The vertical line test
A set of points in the Cartesian plane is the graph of some function \(f \colon A \to \mathbb{R}\) (where \(A \subseteq \mathbb{R}\)) if and only if every vertical line intersects the set in at most one point.
This is a direct geometric restatement of the uniqueness condition: a vertical line \(x = a\) collects all points with first coordinate \(a\). If the line hits the set at two different heights, that means \(a\) would be assigned two different values — violating the definition of a function.
If a vertical line misses the set entirely, that simply means \(a \notin A\): the value \(a\) is not in the domain.
Applying the vertical line test
A circle fails the test. The unit circle in the plane is the set \(\{(x,y) \mid x^2 + y^2 = 1\}\). The vertical line \(x = 0\) intersects it at \((0, 1)\) and \((0, -1)\) — two points. So the unit circle is not the graph of any function.
A semicircle passes. The upper semicircle \(\{(x,y) \mid x^2 + y^2 = 1,\; y \geq 0\}\) passes the test: every vertical line with \(-1 \leq x \leq 1\) meets it in exactly one point, and all other vertical lines miss it entirely. It is the graph of \(f \colon [-1, 1] \to \mathbb{R},\; f(x) = \sqrt{1 - x^2}\).
Reading information from a graph
Given the graph of \(f \colon A \to B\) in the Cartesian plane, we can read off several things directly:
Domain. The set of \(x\)-coordinates for which the graph has a point. Geometrically: project the graph onto the horizontal axis.
Image. The set of \(y\)-coordinates that actually appear. Geometrically: project the graph onto the vertical axis.
Value at a point. To find \(f(a)\), draw the vertical line \(x = a\); the \(y\)-coordinate where it meets the graph is \(f(a)\).
Zeros. The values of \(x\) where the graph crosses the horizontal axis, i.e. the solutions of \(f(x) = 0\).
Reading from the graph of \(f(x) = x^2 - 1\)
Consider \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = x^2 - 1\). Its graph is the parabola \(y = x^2\) shifted down by \(1\).
Domain: \(\mathbb{R}\) (the graph extends indefinitely left and right).
Image: \([-1, +\infty)\). The lowest point of the parabola is the vertex at \((0, -1)\), so \(-1\) is the smallest value attained.
Value at \(x = 2\): \(f(2) = 4 - 1 = 3\) — the point \((2, 3)\) on the graph.
Zeros: \(x^2 - 1 = 0\) gives \(x = 1\) and \(x = -1\). The graph crosses the horizontal axis at \((-1, 0)\) and \((1, 0)\).
Connection to Computer Science
Plotting a function's graph is one of the earliest things a programmer does with data: given a list of input-output pairs, draw them as points or connect them with a line. Every spreadsheet chart and every data visualisation library starts from the same idea — turn a table of \((x, f(x))\) values into a picture. The vertical line test even has a programming analogue: if your data has two different \(y\)-values for the same \(x\), something is wrong with your mapping.
Does the graph determine the function?
Suppose two functions \(f \colon A \to B\) and \(g \colon A \to C\) have exactly the same graph: \(G_f = G_g\). Does it follow that \(f = g\)?
Not necessarily. Equal graphs mean that \(f\) and \(g\) have the same domain and agree at every point, but the graph does not record the codomain. For instance, \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = x^2\) and \(g \colon \mathbb{R} \to [0, +\infty),\; g(x) = x^2\) produce identical graphs, yet \(f \neq g\) in our convention (different codomains).
So the graph captures almost everything about a function — everything except the codomain. To recover the full function from its graph, you must also know which set \(B\) was declared as the codomain.
Exercises
Exercise 1
For each curve described below, decide whether it is the graph of a function.
Exercise 2
Consider the function \(f \colon \mathbb{R} \to \mathbb{R},\; f(x) = |x| - 2\). Its graph is the V-shape of \(|x|\) shifted down by \(2\).
Exercise 3
Each item describes a graph. Choose the function whose graph matches the description.
Exercise 4
Let \(f \colon \{0, 1, 2, 3\} \to \mathbb{R}\) be defined by \(f(x) = x^2 - x\). The graph \(G_f\) is a set of four ordered pairs \((x, f(x))\). Write each pair below.
Exercise 5
Two functions are defined by the same formula \(f(x) = x^2\) and have the same domain \(\mathbb{R}\), but different codomains.
Summary
The graph of \(f \colon A \to B\) is the set \(G_f = \{(a, f(a)) \mid a \in A\} \subseteq A \times B\).
When \(A, B \subseteq \mathbb{R}\), the graph is a set of points in the Cartesian plane.
A curve in the plane is the graph of some function if and only if it passes the vertical line test: every vertical line meets it in at most one point.
From a graph we can read the domain, the image, specific values, and zeros.
Reference graphs to remember: \(y = x\) (line), \(y = x^2\) (parabola), \(y = |x|\) (V-shape), \(y = c\) (horizontal line).
The graph does not record the codomain — two functions with the same graph but different codomains are different functions.