Graphing a Function

A graph is a function's photograph. A rule like f(x) = x^2 - 2 tells you what happens to one input at a time; its graph shows you what happens to every input at once. Each point of the picture is one complete input-output fact, and the whole curve is thousands of those facts laid side by side — which makes a graph arguably the most information-dense picture in all of mathematics. One glance answers questions that would take pages of arithmetic: Where is the function biggest? Where does it hit zero? Is it climbing or falling at x = 3? Does it ever repeat itself?

You already read these pictures every day without noticing. The temperature curve in a weather app is a graph of a function (input: time, output: temperature). Your phone's battery screen is a graph (time in, percent out). A fitness tracker's heart-rate trace, a stock ticker, a hospital monitor — all of them are functions wearing their photographs. This page is about how those pictures are made, and how to read them like a native.

The recipe is astonishingly simple. Take the coordinate plane, and for each input x, plot one point: go across to x, then up (or down) to the output f(x). In symbols, the point is

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

Do that for every input in the domain and the dots merge into a curve: the graph of f. Nothing on the picture is decoration — every single point of the curve encodes one pair (x, f(x)), and no point that isn't such a pair is allowed in.

Step 1 — make a table of values

By hand, of course, you can't plot infinitely many points — so you sample. Choose a handful of convenient inputs (small whole numbers are the classic choice, spread on both sides of zero), run each through the rule, and record the outputs. 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, ready to plot: (-2, 3), (-1, 0), (0, -1), (1, 0), (2, 3). Notice the table is already whispering things about the picture: the outputs are symmetric (x = -2 and x = 2 give the same 3), the smallest output sits at x = 0, and the outputs hit 0 twice. A good table is half the graph.

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 — five points sketch the shape, fifty would nail it. And because this is a function, every input gives exactly one output, so the graph can never have two points stacked on the same vertical line. That is the vertical-line test from our first lesson, seen from the other side: it isn't an extra rule about graphs, it is just the definition of a function made visible.

One habit worth building now: after you draw any graph, audit it against the table. Does the curve really pass through (0, -1)? Does it bottom out where the table's outputs were smallest? A graph that contradicts its own table is wrong — the table is the evidence, the curve is the theory.

Worked example: graph f(x) = x^2 - 2, honestly, from scratch

Let's run the whole routine once more with no shortcuts, on f(x) = x^2 - 2.

Choose inputs. The rule is defined for every real number, so we pick a symmetric handful around zero: x = -3, -2, -1, 0, 1, 2, 3.

Compute outputs. Square, then subtract two:

x x^2 f(x) = x^2 - 2 point to plot
-397(-3, 7)
-242(-2, 2)
-11-1(-1, -1)
00-2(0, -2)
11-1(1, -1)
242(2, 2)
397(3, 7)

Plot, then join. The seven dots trace the same U-shape as before, slid one unit lower: the bottom of the U now sits at (0, -2). We join the dots with a smooth curve — but pause on that word "join", because it hides an assumption.

When is joining legitimate? Connecting the dots claims that the function keeps behaving sensibly between our samples — that at x = 1.5, say, the output really is on the curve we drew (1.5^2 - 2 = 0.25 — check: yes, it is). For x^2 - 2 that claim is safe: the rule accepts every number in between and changes gradually, with no jumps or gaps. But if the domain were only the whole numbers — say f(n) is your team's total goals after n matches — joining the dots would be a lie: there is no such thing as the goals after 2.5 matches, so the graph is honestly just dots. Rule of thumb: join only where the domain is unbroken and the rule behaves smoothly across it. (When calculus makes "no jumps" precise, it will be called continuity — this instinct you're building is the preview.)

Reading a graph backwards

So far we have used graphs forwards: given x, look up to find f(x). But a graph answers the reverse question just as easily, and that's often the one you actually care about: which inputs produce a given output? When does the temperature hit 30°? When is the battery at 20%? Algebraically that means solving f(x) = k — and the graph solves it with a ruler.

The horizontal-line trick: draw the horizontal line at height y = k and see where it crosses the curve. Every crossing point sits at some (x, k) — an input whose output is exactly k. Read its x-coordinate straight down onto the axis, and you have a solution. Below, the line y = 2 crosses our curve f(x) = x^2 - 2 twice, at x = -2 and x = 2 — and sure enough, (-2)^2 - 2 = 2 and 2^2 - 2 = 2.

The count of crossings is information too: it is the number of solutions of f(x) = k. Slide the line y = k down this U-shaped graph and watch: two crossings while k > -2, exactly one at the very bottom (k = -2), and none at all below it — the equation x^2 - 2 = -5 has no real solution, and the picture shows you why before you touch any algebra. Forwards reading uses a vertical line and always finds exactly one point (function!); backwards reading uses a horizontal line and may find two points, one, many, or none.

Three traps snare almost every new graph-reader:

Every graph tells a story

Once you can read heights and slopes, a graph becomes a narrative. Here is the depth of water in a bath, minute by minute. No formula this time — just a shape. Step through it and match each feature of the picture to an event in the bathroom.

Read it like a detective: a rising stretch means the output is growing (taps running); a flat stretch means nothing is changing (taps off, someone lying in the tub); a falling stretch means the output is shrinking (plug out). And the steepness carries meaning too — the drain empties the bath in six minutes while the taps took eight to fill it, so the downhill stretch is steeper than the uphill one. "How fast is the graph climbing?" is a question calculus will soon take deadly seriously; for now, notice that your eye already answers it.

This is the skill that makes all those everyday graphs readable. A flat battery graph overnight? The phone slept. A sudden downward cliff at 9 a.m.? You opened the camera. The shapes are a vocabulary, and you now speak it.

Try it live

Here is the graph of f(x) = ax^2 + b. Slide the controls to change the rule and watch its photograph redraw — every point on the curve is still just a (x, f(x)) pair, recomputed with the new rule. Before you touch anything, make two predictions: what should b do to the picture, and what should happen when a goes negative?

Check your predictions: b slides the whole curve up and down (it adds the same amount to every output), a stretches or squashes the U — and flips it upside down when negative. At a = 0 the square term vanishes and the "curve" flattens into the horizontal line y = b: a function whose output ignores its input has the dullest photograph imaginable.

Khan Academy shows functions drawn as graphs here:

So the legend goes. René Descartes — philosopher, soldier, famously late riser — was said to lie in bed watching a fly wander across the ceiling, and to wonder how he could describe the fly's position exactly. His answer: measure its distance from two walls. Two numbers, one point. Any pair of numbers names a spot on the ceiling; any spot on the ceiling names a pair of numbers. The story is probably too good to be strictly true — but the idea is exactly what he published.

In 1637, in La Géométrie (an appendix to his Discourse on Method, the book with "I think, therefore I am"), Descartes showed that with coordinates, every equation in two unknowns draws a curve, and every curve can be interrogated with algebra. Before him, geometry and algebra were separate kingdoms: the Greeks drew and reasoned with pictures, algebraists shuffled symbols, and never the twain met. Coordinates married them — which is why the plane is called Cartesian to this day. (Pierre de Fermat had the same idea independently at almost the same moment, and being Fermat, didn't bother publishing it properly.)

Every graph you have ever seen — the weather curve, the battery arc, the stock ticker, the figures on this page — is a direct descendant of that one idea. And calculus, which is where you are heading, was built barely fifty years later by Newton and Leibniz standing on it: you cannot ask "what is the slope of a curve at a point?" until curves are made of points with coordinates.