Graphing a function from a table
A rule gives one output for every input, but not every rule draws a straight line. How do you find out what its picture looks like?
Where you are 5 in Graphs of functions
When you reach for it
A function is a rule that gives exactly one output for each input it allows (functions as input-output rules). Each input with its output is an ordered pair, and each pair is a point on the coordinate plane. The graph of a function is the set of all its input-output pairs, plotted as points: the point (x, y) is on the graph exactly when y is the output the rule gives for the input x.
That definition is also the method. There are usually infinitely many pairs, so you work out a few in a table of values, plot them, and look at the pattern. For a straight line, graphing a line from a table needs three points and a ruler. This lesson is for every other rule, where the table must also show which way the graph bends, whether to join the points at all, and what goes in the gaps.
The procedure
The running example is y = x^2: the output is the input multiplied by itself.
Choosing the inputs
Every number can be squared, so every x is allowed. For a rule whose shape you do not yet know, take more inputs than a line would need, spread on both sides of 0, and include 0 itself. Here take the integers from -3 to 3. A negative input goes in brackets, so that its sign is squared with it: (-3)^2 = (-3)(-3) = 9.
| x | y = x^2 |
|---|---|
| -3 | 9 |
| -2 | 4 |
| -1 | 1 |
| 0 | 0 |
| 1 | 1 |
| 2 | 4 |
| 3 | 9 |
Plotting and reading the shape
Plot each pair: across to the input, then up or down to the output. Before joining anything, look at what the points do.
They do not line up. The inputs go up by 1 each time, but the outputs change by -5, -3, -1, +1, +3, +5. A line needs equal output steps for equal input steps, and these are not equal; they even change sign. So the graph is a curve.
The table shows two more features. The outputs come in matching pairs, x = 2 and x = -2 both giving 4, because (-x)^2 = x^2: the graph is the same on both sides of the y-axis. And no output is negative, because a square is positive or zero, so the lowest point is (0, 0). This U shape is a parabola.
Filling the gaps
The graph is every pair, not only seven. Inputs between the integers have outputs too:
A straight segment from (1, 1) to (2, 4) would be halfway up, at \displaystyle \frac{1 + 4}{2} = 2.5, when x = 1.5. The rule says 2.25, a little lower, so a ruler would put wrong points on the graph. In-between points fill in a smooth curve with no corners: draw one, freehand, through all the points and on to the edges of the grid, since every x is allowed.
Join the points or not
Joining points claims that every input between them is allowed and that its output is on what you drew. Three cases come up.
- The input can be any number in a stretch, such as a length or a time. Join the points with a smooth curve, or a line if they line up, but only over the inputs the situation allows: a length is never negative, and a ball stops falling when it lands (Examples 1, 3 and 4).
- The input counts whole things, such as photos or paving slabs. Leave the dots separate, even when they follow a curve, because 2.5 slabs means nothing (Example 4).
- The rule stays flat and then jumps, such as a charge for each hour or part of an hour. The graph is flat pieces, with an open circle and a filled dot at each jump to show which piece the jump’s own input belongs to (Example 2).
What decides is the input and the rule, never the shape the dots happen to make. The inputs a situation allows are its reasonable domain.
A line or a curve
Points on one straight line, with equal output steps for equal input steps, suggest a line; points that bend show a curve. But a few points are only a sample, and badly chosen inputs can line up by accident (Example 2 and Exercise 10). Spread the inputs out, add in-between ones, and let the rule decide. Telling the two kinds apart in general is its own lesson.
Worked examples
Twelve divided by the input
Graph \displaystyle y = \frac{12}{x} for positive values of x.
SolutionDivision by 0 has no answer, so x = 0 is not an input. Inputs that divide 12 exactly keep the outputs whole:
| x | \displaystyle y = \frac{12}{x} |
|---|---|
| 1 | 12 |
| 2 | 6 |
| 3 | 4 |
| 4 | 3 |
| 6 | 2 |
| 12 | 1 |
The points do not line up. From x = 1 to x = 2 the output drops by 6, and from x = 2 to x = 3 by only 2: equal input steps, unequal output steps. The graph falls steeply and then levels off.
Two more inputs show the ends. Near 0 the outputs grow very large: \displaystyle \frac{12}{0.5} = 24, off the top of this grid. Far out they shrink toward 0: \displaystyle \frac{12}{24} = 0.5. They never reach 0, since 12 divided by a positive number is positive. So the curve meets neither axis.
Every positive number is an allowed input, so join the points with one smooth curve. In between, \displaystyle \frac{12}{8} = 1.5 puts (8, 1.5) on the curve between (6, 2) and (12, 1). Doubling the input halves the output: this is the shape of an inversely proportional relationship.
Parking by the started hour
A parking lot charges 4 dollars for each hour or part of an hour, and a car may stay up to 5 hours. Make a table of the charge for stays of 0.5, 1, 1.5, and so on up to 5 hours, and graph the charge against the time parked.
SolutionA part of an hour counts as a whole one, so the charge is 4 dollars for each hour started. A stay of 1.5 hours starts a second hour and costs 2 \times 4 = 8 dollars. A stay of exactly 1 hour starts only one, and costs 4 dollars.
| hours | charge (dollars) |
|---|---|
| 0.5, 1 | 4 |
| 1.5, 2 | 8 |
| 2.5, 3 | 12 |
| 3.5, 4 | 16 |
| 4.5, 5 | 20 |
Time can be any number up to 5, so the gaps must be filled, but not with a smooth curve. Every stay longer than 1 hour and up to 2 hours, such as 1.1 or 1.75 hours, costs 8 dollars. So over that stretch the graph is a flat piece at height 8, and the same happens over each hour.
At t = 1 two pieces meet, and the function must give one charge, not two. The rule says 4, so the lower piece ends in a filled dot at (1, 4), meaning “on the graph”, and the next piece begins with an open circle at (1, 8), meaning “not on the graph, though everything just to its right is”. No vertical line joins the pieces: it would give the single input t = 1 every charge from 4 to 8. A graph of flat pieces like this is a step function, a cousin of the greatest integer function.
A table of whole hours alone would have misled: (1, 4), (2, 8), (3, 12), (4, 16) and (5, 20) lie on a straight line through the origin. The half hours reveal the steps.
A ball’s height from a table
Nuno throws a ball upwards from a balcony. A video gives its height above the ground every half second until it lands.
| time (s) | height (m) |
|---|---|
| 0 | 15 |
| 0.5 | 18.75 |
| 1 | 20 |
| 1.5 | 18.75 |
| 2 | 15 |
| 2.5 | 8.75 |
| 3 | 0 |
Graph the height against the time, and describe the shape.
SolutionThere is no formula here, only pairs, and that is enough: each row is a point. One square across is half a second and one square up is 2 meters.
The ball is somewhere at every moment between readings and moves smoothly, so join the points with a smooth curve. It starts at (0, 15), not at the origin, because the ball leaves the hand 15 meters up, and it stops at (3, 0), when the ball lands.
The height changes by +3.75, +1.25, -1.25, -3.75, -6.25, -8.75 in each half second: unequal steps that change sign, so the curve rises, turns over, and falls faster and faster. The heights repeat on either side of t = 1, which suggests the top is at 1 second, 20 meters up. Seven readings cannot prove that; a reading at 0.9 or 1.1 seconds would test it.
The same rule, joined or not
Odile is planning a square patio.
(a) Graph the area A square meters of a square patio against its side s meters, so A = s^2, for sides from 1 to 4 meters.
(b) The patio will be laid with square slabs, n along each side, so it needs n^2 slabs. Graph the number of slabs against n, for n from 1 to 4.
SolutionBoth rules square the input, so both tables read the same:
| input | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| output | 1 | 4 | 9 | 16 |
(a) A side can be any length from 1 to 4 meters, such as 2.5 meters, with area 2.5^2 = 6.25 square meters. So join the points with a smooth curve from (1, 1) to (4, 16), stopping at both ends. It is part of the right-hand half of the parabola y = x^2; a side cannot be negative.
(b) A patio has 1, 2, 3 or 4 slabs along a side, never 2.5. The graph is four separate dots.
The two graphs share every plotted point and are still different graphs, because the situations allow different inputs. The dots in (b) follow a curve (the steps 3, 5, 7 are unequal); they are just not joined.
Is the point on the graph?
Decide which of these points are on the graph of y = x^2, and find every point on the graph with output 16.
(a) (-3, 9) \qquad (b) (2.5, 6.25) \qquad (c) (-1.5, -2.25) \qquad (d) (4, 8)
SolutionA point is on the graph exactly when its second coordinate is the rule’s output for its first. So square the first coordinate and compare.
(a) (-3)^2 = 9. On the graph.
(b) 2.5^2 = 6.25. On the graph, between (2, 4) and (3, 9), though not in the table.
(c) (-1.5)^2 = 2.25, not -2.25. Not on the graph; no point of it lies below the x-axis.
(d) 4^2 = 16, not 8. Not on the graph.
For output 16 the input must square to 16, and both 4^2 = 16 and (-4)^2 = 16. The points are (4, 16) and (-4, 16). Two inputs sharing an output is allowed in a function; one input with two outputs is not.
Boundaries
The plotted points are a sample. What happens between them comes from the rule, or for measurements from what the situation does, never from the dots alone. In Example 2 the whole-hour points lie on a line, and the graph between them is steps.
Only the inputs the rule allows. \displaystyle \frac{12}{x} has no output at x = 0, so its graph has no point there. A situation can allow fewer still: a length is not negative, a count is whole, a ball is not in the air after it lands. The graph covers those inputs and stops.
One output for each input. The graph of a function never has two points straight above one another. That is why a step function uses an open circle and a filled dot and has no vertical pieces (testing graphs for functions).
Where this goes next
Plotting from a table is how every new kind of graph is first met: the absolute value graph is a V found this way, and exponential graphs start flat and take off, as a table of 2^x shows at once. Once drawn, a graph can be read: reading values off a graph runs this lesson backwards, and features of a graph names the landmarks the examples kept finding, such as a lowest point. The parking charge is a first piecewise function, a rule made of several pieces.
Exercises
Make the table and plot
For each rule, make a table for the given inputs, plot the points, and say whether the graph is a line or a curve.
- y = x^2 + 1 for x = -2, -1, 0, 1, 2.
- \displaystyle y = \sqrt{x} for x = 0, 1, 4, 9, 16. Why are there no negative inputs?
- y = x^3 for x = -2, -1, 0, 1, 2.
- y = (x - 1)^2 for x = -1, 0, 1, 2, 3. Where is its lowest point?
Join the points or not
- A second parking lot charges 5 dollars for the first hour or part of it, and 2 dollars for each further hour or part of an hour, for stays of up to 4 hours. Find the charge for stays of 0.5, 1, 1.5, 2, 3, 3.5 and 4 hours, describe the graph, and find the charge for 2 hours 10 minutes.
- Margarethe drops a pebble from a bridge 80 meters above a river. Its height after t seconds is h = 80 - 5t^2 meters until it reaches the water. Make a table for t = 0, 1, 2, 3, 4, say when it reaches the water, and find its height at t = 2.5. Is that above or below the straight segment from (2, 60) to (3, 35)?
- For each situation, say whether the graph should be joined, separate dots, or flat pieces with jumps, and why. (a) Storage used on Romilly’s phone against the number of photos. (b) The depth of water in a bath against minutes since the tap was turned on. (c) A charge per started hour against minutes parked. (d) The cost of n concert tickets against n.
Line or curve
- A table gives x = 0, 1, 2, 3, 4 and y = 1, 3, 5, 7, 9. Is the graph a line or a curve? If a line, give its rule.
- A table gives x = 0, 1, 2, 3, 4 and y = 1, 2, 4, 8, 16. Is the graph a line or a curve?
- For y = x^3 - 4x, find the outputs at x = -2, 0 and 2, then at x = -1 and x = 1. Is the graph a line?
On the graph or not
- Which of these points are on the graph of y = x^2 - 3: (2, 1), (-2, 1), (0, -3), (3, 9), (0.5, -2.75)?
- On the graph of y = x^2 + 2, find every point with output 11, the point with input 4, and every point with output 1.
Reasoning
- The points (0, 0), (1, 1) and (2, 4) of y = x^2 are joined with straight segments. Compare the segment’s height at x = 1.5 with the rule’s output there, and explain why the graph should be a smooth curve instead.
- For the parking lot of Example 2, explain why the graph has an open circle at (2, 12) and a filled dot at (2, 8), and why vertical lines joining the flat pieces would be wrong.
- Explain why the graph of a function can never contain both (2, 5) and (2, 7).
- Romilly draws the graph of \displaystyle y = \frac{12}{x} for positive x and ends it on the y-axis at (0, 12). Explain what is wrong, and why the curve never meets either axis.
Answers
- Outputs 5, 2, 1, 2, 5. A curve, a U with lowest point (0, 1); the steps -3, -1, +1, +3 are not equal.
- Outputs 0, 1, 2, 3, 4. A curve: from x = 0 to 1 the output rises 1 for an input step of 1, from 1 to 4 it rises 1 for a step of 3, so it rises more and more slowly. No negative inputs, since no number squares to a negative.
- Outputs -8, -1, 0, 1, 8. A curve through the origin, rising throughout; the steps 7, 1, 1, 7 are not equal.
- Outputs 4, 1, 0, 1, 4. A U with lowest point (1, 0), the shape of y = x^2 moved 1 to the right: a square is never negative, and is 0 only when x = 1.
- Charges 5, 5, 7, 7, 9, 11, 11 dollars. Four flat pieces at 5, 7, 9 and 11, one over each hour, each open at its left end and closed at its right end. A stay of 2 hours 10 minutes starts a third hour: 5 + 2 + 2 = 9 dollars.
- Heights 80, 75, 60, 35, 0 meters; it reaches the water at t = 4, since 80 - 5 \cdot 16 = 0. At t = 2.5 the height is 80 - 5(6.25) = 48.75 meters. The segment there is at \displaystyle \frac{60 + 35}{2} = 47.5, so the pebble is above it, and the graph is a smooth curve from (0, 80) to (4, 0).
- (a) Separate dots: photos are counted. (b) Joined: time passes through every value and the depth changes smoothly. (c) Flat pieces with jumps: the charge stays the same through each hour and jumps when a new one starts. (d) Separate dots: tickets are counted.
- A line: each step of 1 in x raises y by 2. Its rule is y = 2x + 1.
- A curve: the steps 1, 2, 4, 8 are not equal. Each output doubles the one before.
- At -2, 0 and 2 the outputs are all 0. At x = -1 the output is 3 and at x = 1 it is -3. Not a line: (1, -3) is off the x-axis, the line through the first three points.
- On the graph: (2, 1), (-2, 1), (0, -3) and (0.5, -2.75). Not (3, 9), since 3^2 - 3 = 6.
- Output 11: (3, 11) and (-3, 11), since x^2 = 9. Input 4: (4, 18). Output 1: no point, since x^2 + 2 is never less than 2.
- The segment from (1, 1) to (2, 4) is at \displaystyle \frac{1 + 4}{2} = 2.5 when x = 1.5, but the rule gives 1.5^2 = 2.25, below it. Every in-between input has its own output, so straight pieces put wrong points on the graph; more in-between points fill in a smooth curve.
- A stay of exactly 2 hours costs 8 dollars, so (2, 8) is on the graph: a filled dot. Any stay just over 2 hours costs 12, but 2 hours itself does not: an open circle at (2, 12). A vertical line at t = 2 would give that one input every charge from 8 to 12.
- A function gives exactly one output for each input, and the two points would give the input 2 the two outputs 5 and 7.
- 12 cannot be divided by 0, so there is no point (0, 12); the output 12 belongs to x = 1. Near 0 the outputs grow without limit (\displaystyle \frac{12}{0.1} = 120), so the curve climbs beside the y-axis without touching it, and a positive number over a positive number is positive, so it never meets the x-axis.