Graphing a Function

We now have everything we need to see a function. A graph turns a rule into a picture by treating each input-output pair as a point on the coordinate plane.

The trick is simple: for an input x, the output is f(x), so we plot the point

\bigl(x,\ f(x)\bigr).

Do that for enough inputs across the domain and the dots reveal the shape of the whole function.

Step 1 — make a table of values

Choose a handful of convenient inputs, run each through the rule, and record the output. For f(x) = x^2 - 1 a small table looks like this:

\begin{array}{c|c} x & f(x) = x^2 - 1 \\ \hline -2 & 3 \\ -1 & 0 \\ 0 & -1 \\ 1 & 0 \\ 2 & 3 \end{array}

Each row is one ordered pair: (-2, 3), (-1, 0), (0, -1), and so on.

Step 2 — plot the points, then connect them

Plot each pair, then join the dots with a smooth curve. Step through the build below: the points appear one at a time, and the last step draws the curve that passes through them all.

The more inputs you sample, the more faithful the curve. Because this is a function, every input gives exactly one output — so the graph never doubles back over a vertical line (that's the vertical-line test from our first lesson).

Try it live

Here is the graph of f(x) = ax^2 + b. Slide the controls to change the rule and watch its picture redraw — every point on the curve is still just a (x, f(x)) pair.

Khan Academy shows functions drawn as graphs here: