mathematics / functions / drawing the graph
Drawing the Graph
A curve on a screen is a short table of values with the gaps between them guessed. Six shapes cover most of what you will meet, and three numbers turn any one of them into a whole family, so a family is one curve moved rather than a list to learn.
By the end you can
- build a graph from a table of values, one row and one point at a time, and say what a row and a point have in common
- say what a line drawn between two plotted points is claiming, and find a rule where the claim is wrong
- recognise x, x², x³, 1/x, √x and |x| on sight, and name the one feature that settles each
- predict what a, h and k do to any of those six before touching a slider, including which way x − h moves a curve
- work out a, h and k for a jet of water from where the hose stands, how high it is and how far the tap is open, and check the answer against the water
- tell a typing error apart from an input the rule genuinely has no value at
Plot it by hand
Pick a few inputs, work out the output for each, mark every pair as a point, and the graph builds up one row at a time.
The previous page said the graph is the record of every pair the function produces. Every pair is infinitely many of them, and you have a pencil and an afternoon. So nobody draws a graph that way. What people do instead is pick a short list of inputs, work out the output for each one, mark the pairs, and join them up.
The list is a table of values, and it is the graph filed differently. One row holds one input and its output. That row is one point. Nothing is added when the row becomes a dot and nothing is lost, which is the same claim the fold made on the previous page, now with the pairs arriving one at a time instead of all at once.
f(x) = x²
| x | f(x) | (x, f(x)) |
|---|---|---|
| −3.000 | 9.000 | (−3.000, 9.000) |
x = −3.000 gives 9.000, not added yet. No points on the plane.
add two points first, then joining them has something to join
The table and the plot hold the same numbers. Each row is one input, its output and the pair written together, and each dot on the axes is that same pair placed on the plane. Hovering a row, or pressing the button in it, rings the matching dot, and every row is reachable from the keyboard. Teal marks the input on the horizontal axis and amber the output on the vertical one. The hollow circle is the candidate point, worked out but not added. Nothing has been added yet, so there are no filled dots. Joining draws a straight line through those dots in order of x and claims nothing else: it is off now, and nothing about the rule changes when you press it.
A table and a pair of axes holding the same information twice. Every row you add is one input, its output, and one dot placed on the axes at the same moment.
The figure links each row to its dot, so you can find either one from the other. That link is the claim of the step: a row and a point are the same pair written two ways.
Choosing the inputs is the part with judgement in it. Whole numbers spread evenly are the usual opening, because they are quick to work out and they cover ground. Then look at what came back. Where three dots in a row sit almost on a straight line, a fourth between them tells you little. Where the dots change direction, crowd together, or leave a gap, that is where another input earns its place.
Joining the dots is a separate act and it is not part of the record. The rule was asked about the inputs in your table and about no others. The line you draw between two dots is your claim about what the rule does in between, and the rule was never consulted. Usually that claim is close to true. The next step is about the times it is not.
How many points is enough
Take too few sample points and the line you draw through them is a shape the rule never had.
Every graph you have seen on a screen was made the way you made one in the last step. A plotting program picks a number of x values across the window, works out the rule at each, and joins consecutive results with straight segments. What is drawn is a chain of straight pieces, a polyline, with the pieces short enough that it reads as a curve. matplotlib does this. So does a graphing calculator.
7 samples across 0.000 to 6.000, one every 1.000, joined in order. Every one of these samples has f(x) = 0.000, so the line through them lies flat along the horizontal axis. That line is yours, not the axis.
Try it Press the 7 chip on the wave. What is it doing between the samples?
Pick one The figure holds the answer back until you do.
The heavy line is your own line through your samples, and it is drawn by joining consecutive results with straight pieces rather than by asking the rule what happens between them. The dots are the 7 points actually taken, one every 1.000 across the interval; they are hidden above 40 because at that density they read as a solid band rather than as a count. The rule itself is deliberately hidden until you press show the truth, so that the shape you believe first is your own. No colour anywhere in this figure: nothing here is an input or an output being read off, it is two curves compared.
A pair of axes, a slider for how many sample points are taken across the interval, chips for which rule is being sampled, and a control that shows the rule the dots came from.
The dots are values the rule returned. The straight segments joining them were drawn by the figure and not computed from the rule, and that distinction is the whole step.
Watch the segments rather than the dots. The dots are right at every setting, and the segments are where the error lives.
like that is fine when the rule does nothing between the samples that the samples did not see coming. When it does, the polyline is not a slightly rough version of the truth. It is a different shape, drawn with complete confidence.
Reveal the true curve and compare the two. The gap between them is not measurement error, and nothing was rounded. Every dot your polyline passes through is exactly right, because the rule really does take those values at those inputs. All of the wrongness lives in the segments between the dots, which are the part nobody computed.
The count going up is not the same as the error going down. On the wave, take the count from 7 to 13 and every sample still comes back zero, the line stays flat, and the widest gap between your line and the true curve is 1.0000 at both settings. At 9 samples the gap is 1.3559, worse than at 7. It settles only once the samples are closer together than the feature: 0.2105 at 25, and 0.0020 at 301. The other curve fails in a different way. At four samples it returns 0.005, 0.217, 0.009 and 0.002, and the line through them misses the top of a bump by 0.8137.
Raising the count never proves you have enough. It rules out the features too wide to hide between your samples, and a rule can always have something narrower. The only real defence is knowing something about the rule before you plot it: where it turns, where it has no value, how fast it is able to change. That is what the next step is for.
Six shapes worth knowing
Six curves cover most of what you will meet, and each is settled by one feature rather than by its formula.
Meeting curves one formula at a time leaves you with a list to memorise and no way to check it. Six shapes cut the list down to something you can hold. Each one is a , the plainest member of its family, and the next two steps turn each parent into the entire family it heads.
x = 2.000
curves all 6
Every curve is drawn in the same ink and no curve has a colour of its own; the one you are studying is drawn heavier, and which curve it is, is its name written on it. Teal marks the input and the probe you drag along the horizontal axis, amber the outputs it reads off. 6 of six shown. x runs straight through the origin at 45 degrees, and here it reads 2.000. x² turns once, its left half mirroring its right, and here it reads 4.000. x³ never turns; it flattens at the origin and keeps climbing, and here it reads 8.000. 1/x comes in two separate pieces, with no value at 0, and here it reads 0.500. √x has nothing at all left of 0, with a filled endpoint at the origin, and here it reads 1.414. |x| has a corner at the origin and is straight on both sides, and here it reads 2.000. x² and x³ leave the top or bottom of the frame at this x. The curve is cut off by the frame and the number is printed in full, because the value exists and the drawing has no room for it. The ring on the horizontal axis at x = 0 marks the input 1/x has no value at, and the dashed line there is the one it runs alongside without touching.
One pair of axes carrying all six curves at once, a control for showing and hiding each, and a probe you drag along the horizontal axis to read off what every shown curve does there.
Hide everything, then bring back two at a time. A pair is where a difference shows; six at once is where it hides.
Three questions to put to any curve here. Which part of the horizontal axis is it allowed to live on. Does its left half mirror its right half. Does it ever change direction.
f(x) = x is the reference. It is straight, it climbs at the same rate everywhere, and the other five are described by how they fail to do that.
f(x) = x² and f(x) = x³ differ in what they do with negative inputs. Squaring a negative gives a positive, so the left half is folded up to match the right: x² is an and its graph is symmetric about the vertical axis. Cubing a negative gives a negative, so the left half stays below the axis: x³ is an and its graph has rotational symmetry about the origin. x³ never turns around either. It flattens off near the origin and then keeps climbing.
f(x) = √x lives on half the axis only, because the refusal from the previous page is still in force below 0. It starts at the origin and rises without bound, but ever more slowly.
f(x) = 1/x is the odd one out on every count. It has no value at 0, so it arrives in two separate pieces. Close to 0 it runs away upwards on one side and downwards on the other. Far out in either direction it flattens towards 0 without landing on it. Both of the lines it approaches and never reaches are : a vertical one at x = 0, and a horizontal one at y = 0.
f(x) = |x| is the , which returns the size of a number with its sign thrown away, so |−3| and |3| are both 3. Its graph is two straight half lines meeting at a corner at the origin. It resembles x² at a glance and is nothing like it: x² is curved everywhere and has no corner anywhere. The corner matters later, because it is the one place where asking how steep a curve is has no single answer.
Sliding the whole curve
A curve moved up, down, left or right is still the same curve, and two numbers do all four moves.
y = (x − 3)² + 2 looks like a rule you would need a fresh table of values for. It is x² and nothing else, standing somewhere else on the page. That is what this step and the next are for: a family of curves is not a list to learn, it is one curve and instructions for where to put it.
Take k first, because nothing about it surprises anybody. f(x) + k runs the rule, takes the output, and adds k to it. Every point on the curve goes up by k, or down when k is negative, and nothing else changes. The shape survives untouched because the addition happens after the rule has finished its work.
Now h, and before you touch it, commit. Leave k at zero, take h to a positive value, and decide which way the curve is about to go.
y = 1.0 · x² + 0.0
The vertex of x² was at (0.000, 0.000) and is now at (0.000, 0.000).
The faint curve is the parent x² and it never moves whatever the sliders do; the heavier one is what the sliders make of it. The hollow circle marks the vertex of the parent and the filled one marks where that same point has gone. h slides the curve sideways and k moves it up and down. Right now y = 1.0 · x² + 0.0, and the marked point sits at (0.000, 0.000).
A parent curve drawn faintly, a moved copy of it on the same axes, sliders for h and k, and the equation above the drawing written with the values you set.
Move one slider at a time. Two at once and you cannot tell which of them did what.
Pick one point on the faint parent and find where that point has gone on the copy. One point is easier to track than a whole curve.
The faint parent stays where it is whatever the sliders do. It is there so there is always an unmoved version to measure against.
It goes right. Nearly everybody expects left, because the formula contains a subtraction and a subtraction feels like a move backwards.
Here is the reason. f(x − h) does not change what the rule does. It changes what the rule is handed. Give it x, and it works out the bracket first, then asks the parent for its value there. So the height of the moved curve at x is the height the parent had at x − h. To make the bracket come out at 0, which is where the interesting part of most parents sits, you have to hand it x = h. Every feature therefore turns up h further along than it was. The curve reaches a given height when the bracket does, and with h subtracted the bracket needs a bigger x to get there.
Everything the parent has moves with it and nothing is left behind. Slide 1/x and its vertical leaves x = 0 and stands at x = h. Slide √x and the input it starts at is no longer 0 but h, so the whole domain travels with the curve. Slide |x| and the corner sits at the point (h, k). Change the parent in the figure and the two sliders behave identically on a curve that looks nothing like the last one, which is the claim worth taking away from here.
Stretching and flipping
Multiplying the output by a pulls the curve away from the horizontal axis, and a negative a turns it upside down.
The third slider does something different in kind from the other two. a multiplies the output after the rule has run, so every height is scaled. A point at height 2 goes to 2a. A point at height −1 goes to −a.
One set of points does not move at all. A point at height 0 stays at height 0 whatever a is, because a · 0 = 0. So the curve is pulled away from the horizontal axis and stays pinned to it wherever it met it. That is the difference between a stretch and a slide. A slide moves every point by the same amount. A stretch moves each point by an amount proportional to how far from the axis it already was.
y = 1.0 · x² + 0.0
The vertex of x² was at (0.000, 0.000) and is now at (0.000, 0.000).
The faint curve is the parent x² and it never moves whatever the sliders do; the heavier one is what the sliders make of it. The hollow circle marks the vertex of the parent and the filled one marks where that same point has gone. a stretches it away from the horizontal axis, with a negative a flipping it top to bottom. Right now y = 1.0 · x² + 0.0, and the marked point sits at (0.000, 0.000).
The same construction as the previous step, with a as the slider to work on.
Move a on its own, so whatever changes is a's doing and nothing else.
Watch heights rather than left to right positions, and watch how far each part of the curve sits from the horizontal axis. Then take a below zero and look at which way up the drawing sits.
Then change the parent and run a again. The claim of this step is that a does the same thing to all six, which is a thing you can test rather than believe.
Above 1, a pulls the curve taller. Between 0 and 1 it squashes the curve flatter. Below 0 it flips the curve top to bottom, a reflection in the horizontal axis, and the size of a still sets how tall. At exactly a = 0 every output the rule produced becomes 0 and the curve flattens onto the horizontal axis. Nothing of the shape survives, so that setting is a degenerate case rather than an interesting one.
The order of operations in a · f(x − h) + k is not decoration. Run one input through it left to right: subtract h, apply the rule, multiply by a, add k. The multiplication happens before the addition, so k is the last thing done, and the curve ends up at height k wherever the parent was at height 0. Write a · (f(x − h) + k) instead and the stretch scales k as well, putting the curve at height a · k. The two forms agree when a = 1, and when k = 0, and differ everywhere else.
Count what you have now. Six parents and three sliders is not eighteen curves to learn. It is six shapes and three motions, and the motions are the same three on every shape. Change the parent and every slider does what it did before. That is checkable in the figure in front of you rather than something to take on trust, so check it.
Aiming a hose
A jet of water is a parabola, and where the hose stands, how high it is and how far the tap is open work out its a, h and k.
A hose stands on the lawn on a short stand, pointed up at a fixed 50 degrees, and there is a bucket some distance away on the ground. You want to know where the water will land before you open the tap. Nothing in that question mentions a curve, and the answer is one anyway. The water traces a parabola, so it is x² with some a, h and k, and those three numbers are not yours to pick. The hose fixes them.
The water lands at 6.318 m. It lands in the bucket.
The hose points up at a fixed 50 degrees and you choose where it stands, how high the nozzle is, and how far the tap is open. The panel above the drawing works a, h and k out from the launch and from nothing else, and prints each one as its formula with its numbers in it. The beads are worked out from the two launch speeds and gravity and from nothing else, one bead per equal slice of time; the faint curve is the equation from the panel. The beads sitting on that curve is the check, and it is the whole figure. Moving the stand moves h and nothing else, raising the nozzle moves k and nothing else, and opening the tap moves all three, because a, h and k are every one of them worked out from the launch speed. a is the only one of the three that changes the arc's shape. Right now h is 3.808 m, k is 2.077 m and a is −0.330 per metre. The beads crowd near the top because equal slices of time cover less ground where the water is moving slowly. Drag the bucket along the ground to put it somewhere else.
A hose on a stand, a bucket on the ground, and one arc of water drawn as a chain of beads. A panel above the drawing works a, h and k out from the launch. A line under the drawing says where the water lands.
The faint curve and the beads come from two separate calculations. Read the panel first, then look at whether the beads sit on the curve. That agreement is the whole figure.
The beads are spaced evenly in time rather than in distance, so wherever they crowd together the water is moving slowly.
Split the speed the water leaves the nozzle at into a sideways part, vx, and an upward part, vy. Nothing acts on vx, so horizontal distance is that speed multiplied by time. Gravity works on the upward part at g = 9.80665 metres per second per second, taking it to zero after vy/g seconds, and that moment is the top of the arc. The top sits at the stand's distance plus vx · vy/g, which is h. Its height is the nozzle height plus vy²/(2g), which is k. The sideways speed alone sets how wide the arc is: a = −g/(2 · vx²), negative because the arc opens downwards.
The panel above the drawing does that arithmetic and prints the equation. The beads are drawn a second time by a second route. Each bead is the water's position at one slice of time, worked out from the two speeds and gravity, and that code never reads a, h or k. So the beads sitting on the drawn curve is a check rather than a decoration. If the algebra above it were wrong, the beads would drift off the line and say so.
Move the stand a metre further out and h grows by exactly a metre, while k and a do not move at all. Raise the nozzle and k rises with it, while h and a stay exactly where they were. Only the tap changes a, and a is the only one of the three that changes the arc's shape. Those are the same three numbers as the sliders in the last two steps, arrived at from a hose rather than from a notation exercise.
Type your own
A box where you type a rule and watch the same plotting procedure run on something nobody chose for you.
Nothing new is taught here. Every curve on this page so far was picked by whoever wrote the page, and a shape you were shown is easier to believe than one you found. This removes that.
Type an expression in x, or press one of the examples.
The box reads numbers, the letter x, the four operations, brackets, and these named functions: sqrt, abs, ln, sin, cos, exp. A power is written with ^ or as a superscript, so x^2 and x² both read, and the chips above show the superscript spelling. A multiply is required between a number and x, written * or ·, so 2*x reads and 2x does not. When what you type cannot be read, a caret marks the character the message is about; if a rule had already read, that one stays drawn at full weight and a line above the drawing names it, and if none ever has, there is nothing to draw and the axes stay empty. An expression that reads fine but has no value at some input is a different thing and is not a mistake: the horizontal axis carries a ring at each refused input, nothing is drawn there, and no message is shown. An expression with no value anywhere leaves the plot hatched and empty. The window is currently x and y from −4 to 4, and both axes always share it, so the drawing is square and f(x) = x always sits at 45 degrees.
A text box, a pair of axes, and whatever you asked for. What is on screen here is entirely yours, so nothing in this sentence can tell you what to look at. What the box accepts is listed with it.
When what you type cannot be read as a rule, the message says where reading stopped, and any curve already drawn stays where it is.
When the rule reads fine but has no value at some inputs, the drawing carries nothing at those inputs and no error is reported. That is the rule refusing an input, from the previous page, and it is not a mistake in your typing.
The box reads numbers, the letter x, addition, subtraction, multiplication, division, powers, brackets, and the named functions listed beside it. It is a small parser and not a computer algebra system. It will not simplify what you type, it will not solve anything, and it will not rearrange. It reads a formula, works it out at many x values, and joins the results, which is the procedure from the first two steps of this page with your formula in it.
Typing errors are ordinary here and the box expects them. The one people hit first is 2x. On paper two things written next to each other are multiplied, and here the multiplication sign is required. An unclosed bracket is the second. Stopping after ^ with nothing behind it is the third. In each case the message says where reading stopped, and any curve already drawn stays where it is, so a half typed rule never blanks the drawing.
A second kind of failure is not a failure. 1/0 and √(−1) are both legal to type and neither has a value, and the same goes for any named function handed an input outside its own domain. That is the rule refusing, which the previous page spent two steps on, and it is reported as an absence rather than as an error. The drawing carries no point at that input because there is no point to carry.
One thing worth typing before you go wherever you like with it. Take one of the six parents, choose your own a, h and k, and write out a · f(x − h) + k in full with the numbers in it. Set the sliders in the stretching figure earlier on this page to the same three numbers. The two drawings should be the same drawing. That is a check on the two steps that moved a curve, and it does not require believing either of them.
Every number on this page is worked out from the controls as you set them, including the ones in the legends, the table and the compute panel. Nothing here was stored as a picture. The parent curve is shared between the sliding step and the stretching one, so the same shape carries across; every other control belongs to its own figure and starts fresh.
Challenge
The water lands at 5.818 m. That is 0.818 m past the bucket.
Try it Move the stand out to 3 m. Can the water still hit the bucket?
Not yet The stand is at 1.5 m. The question starts once it is out at 3 m or more.
The hose points up at a fixed 50 degrees and you choose where it stands, how high the nozzle is, and how far the tap is open. The panel above the drawing works a, h and k out from the launch and from nothing else, and prints each one as its formula with its numbers in it. The beads are worked out from the two launch speeds and gravity and from nothing else, one bead per equal slice of time; the faint curve is the equation from the panel. The beads sitting on that curve is the check, and it is the whole figure. Moving the stand moves h and nothing else, raising the nozzle moves k and nothing else, and opening the tap moves all three, because a, h and k are every one of them worked out from the launch speed. a is the only one of the three that changes the arc's shape. Right now h is 3.308 m, k is 2.077 m and a is −0.330 per metre. The beads crowd near the top because equal slices of time cover less ground where the water is moving slowly. The bucket is fixed in this copy of the figure, so where the water lands is the only thing that can move.