Graphing Linear Equations

Learning goals

  • Treat the graph as the equation's whole solution set
  • Plot two solutions to fix the line, and a third to check
  • Build a table by solving for yy and choosing inputs
  • Find both intercepts by setting each variable to zero
  • Draw y=cy = c horizontal and x=cx = c vertical
  • Test a point by substituting its coordinates

What the graph of an equation is

A solution of a linear equation in two variables is an ordered pair (x,y)(x, y) that makes the equation true. You met these pairs in Equations with Two Variables. Each pair names a point on the coordinate plane.

The graph of an equation is the set of all points (x,y)(x, y) whose coordinates make the equation true, plotted on the coordinate plane. A solution gives a point on the graph; a pair that fails the equation gives a point off it. The graph is the equation’s whole solution set drawn as a picture.

For a linear equation this graph is a straight line, which is why the equation is called linear. Two different points fix a line. Once you find two solutions and plot them, you can lay a ruler across them and draw the entire graph. We will find these points using a table or the places where the line crosses the axes.

Graphing with a table of values

The most direct way to graph a linear equation is to find several solutions, plot them, and draw the line they fall on. For a nonvertical line, solve the equation for yy, choose values of xx, and compute the matching yy. Each pair (x,y)(x, y) is one point of the graph. A good habit is to pick a small spread of xx-values, including zero and a negative, so the points are not all crowded together.

Worked example 1 Graph y=2x−1y = 2x - 1 from a table

The equation is already solved for yy, so choose a handful of xx-values and compute each yy.

y=2(−1)−1=−3,y=2(0)−1=−1,y=2(1)−1=1,y=2(2)−1=3.\begin{aligned} y = 2(-1) - 1 &= -3, &\qquad y = 2(0) - 1 &= -1, \\ y = 2(1) - 1 &= 1, &\qquad y = 2(2) - 1 &= 3. \end{aligned}

Collecting the results in a table keeps the pairs straight:

xxy=2x−1y = 2x - 1Solution (x,y)(x, y)
−1-1−3-3(−1,−3)(-1, -3)
00−1-1(0,−1)(0, -1)
1111(1,1)(1, 1)
2233(2,3)(2, 3)

Plot the four points. They line up perfectly, so lay a ruler across them and draw a straight line. Extend it past the outer points and add arrowheads to show it runs on forever in both directions. That line is the graph of y=2x−1y = 2x - 1.

The graph of y = 2x - 1Four solution points of y = 2x - 1 plotted from a table, all lying on one straight line.xy-1123-3-1130(-1, -3)(0, -1)(1, 1)(2, 3)y = 2x - 1
The four table solutions of y = 2x - 1, the points (-1, -3), (0, -1), (1, 1), and (2, 3), all fall on one straight line. Extended in both directions, that line is the complete graph: every point on it is a solution, and every solution is a point on it.

Why do the points always line up instead of scattering? The table already hints at the reason: each time xx climbs by 11, the value of yy climbs by the same 22.

Why the solution points fall on a straight line#

First try a different equation, y=3x+2y = 3x + 2, to see that the pattern is not special to the table above. Its points include (1,5)(1, 5) and (4,14)(4, 14):

3(1)+2=5,3(4)+2=14.3(1)+2=5,\qquad 3(4)+2=14.

The move of 33 to the right gives a move of 99 up, three times as much. The same is true from any starting point and for a move of any size. If we change xx by any amount hh, then

3(x+h)+2=(3x+2)+3h.3(x+h)+2=(3x+2)+3h.

So every solution is reached from any other by moving vertically three times as far as we move horizontally, with the signs included. That means each step between two solutions runs in the same straight direction, forward or backward, so the points all lie on one line.

The same reasoning explains the table for y=2x−1y = 2x - 1. A step of 11 in xx gives

2(x+1)−1=(2x−1)+2,2(x+1)-1=(2x-1)+2,

exactly 22 more than the old yy. A step of 12\tfrac{1}{2} gives a rise of 11; a step of 0.10.1 gives a rise of 0.20.2. These are instances of the same rule for any step, not just whole-number inputs.

In general, solving a nonvertical linear equation for yy gives y=kx+dy = kx + d, where kk and dd are fixed numbers. Changing xx by hh changes yy by khkh, since k(x+h)+d=(kx+d)+khk(x+h)+d=(kx+d)+kh. Thus all its solutions follow one straight direction, including the points between grid marks. Conversely, every point reached by such a step satisfies the equation. Vertical equations fix xx instead; their solutions form one straight column, as we will see below.

The same routine graphs any linear equation that is not vertical. When the equation is not already solved for yy, solve for it first, then build the table. (A vertical equation such as x=4x = 4 cannot be solved for yy at all, since it has no yy in it. It gets its own quick rule later in this lesson.)

Worked example 2 Graph x+y=4x + y = 4 from a table

First solve for yy by subtracting xx from both sides:

y=4−x.y = 4 - x.

Now choose a few values of xx, including a negative one so the points spread out, and compute yy:

xxy=4−xy = 4 - xSolution (x,y)(x, y)
−1-155(−1,5)(-1, 5)
0044(0,4)(0, 4)
1133(1,3)(1, 3)
2222(2,2)(2, 2)

Plotting (−1,5)(-1, 5), (0,4)(0, 4), (1,3)(1, 3), and (2,2)(2, 2) gives four points that fall on one line, and drawing through them graphs x+y=4x + y = 4. If one point landed off the line through the others, you would know to look for an arithmetic slip.

Check your understanding

You are graphing y=3x−2y = 3x - 2 with a table. Which ordered pair belongs in the table?

Answer choices

Graphing with the intercepts

Because two different points are enough to fix a line, you do not need a long table. You need only two solutions, and two of them are especially easy to find and to plot: the points where the graph crosses the axes.

The x-intercept is the point where the line crosses the x-axis. Every point on the x-axis has y=0y = 0, so to find it, set y=0y = 0 and solve for xx. The y-intercept is the point where the line crosses the y-axis. Every point on the y-axis has x=0x = 0, so set x=0x = 0 and solve for yy. Each choice makes one term drop out, which keeps the arithmetic short.

Take 3x+2y=123x + 2y = 12. For the x-intercept, set y=0y = 0:

3x+2(0)=12,3x=12,x=4,3x + 2(0) = 12, \qquad 3x = 12, \qquad x = 4,

so the line crosses the x-axis at (4,0)(4, 0). For the y-intercept, set x=0x = 0:

3(0)+2y=12,2y=12,y=6,3(0) + 2y = 12, \qquad 2y = 12, \qquad y = 6,

so it crosses the y-axis at (0,6)(0, 6). Plot those two points, draw the line through them, and the graph is done.

Graphing 3x + 2y = 12 from its interceptsThe line 3x + 2y = 12 drawn through the two intercept points (0, 6) on the y-axis and (4, 0) on the x-axis.xy2462460(0, 6)(4, 0)3x + 2y = 12
Graphing 3x + 2y = 12 from its two intercepts. Setting y = 0 gives the x-intercept (4, 0); setting x = 0 gives the y-intercept (0, 6). The single line through those two points is the graph.

You do not have to use the intercepts. If an intercept is awkward to plot, choose an easier value of xx and compute its yy instead.

For a slanted line through the origin, such as y=2xy = 2x, both intercepts are (0,0)(0, 0). That is only one point, so choose another xx to find a second point.

Horizontal and vertical lines need a different shortcut. For example, y=3y = 3 never meets the x-axis, while y=0y = 0 is the x-axis itself. We can draw these lines directly from their equations.

Worked example 3 Graph 3x−4y=123x - 4y = 12 using its intercepts

Find the x-intercept by setting y=0y = 0:

3x−4(0)=12,3x=12,x=4,3x - 4(0) = 12, \qquad 3x = 12, \qquad x = 4,

so the x-intercept is (4,0)(4, 0). Find the y-intercept by setting x=0x = 0:

3(0)−4y=12,−4y=12,y=−3,3(0) - 4y = 12, \qquad -4y = 12, \qquad y = -3,

so the y-intercept is (0,−3)(0, -3). The second intercept is below the x-axis, which is fine. Plot (4,0)(4, 0) on the x-axis and (0,−3)(0, -3) on the y-axis, then draw the line through the two points to graph 3x−4y=123x - 4y = 12.

Check your understanding

What is the x-intercept of the graph of 5x+2y=205x + 2y = 20?

Answer choices

Horizontal and vertical lines

Two kinds of lines look different from the slanted ones above, and they come from equations that mention only one variable.

Consider y=3y = 3. Read literally, it says the y-coordinate is 33 and says nothing at all about xx. So xx is free to be any number while yy must stay 33: the pairs (−2,3)(-2, 3), (0,3)(0, 3), (1,3)(1, 3), and (100,3)(100, 3) are all solutions. Plot a few and they sit at the same height, three units above the x-axis. Connecting them gives a horizontal line. Every equation of the form y=cy = c graphs as a horizontal line at height cc.

Now consider x=−2x = -2. It fixes the x-coordinate at −2-2 and says nothing about yy. So this time yy is free and xx stays −2-2: the pairs (−2,−2)(-2, -2), (−2,0)(-2, 0), and (−2,2)(-2, 2) are all solutions. They line up in a single column two units left of the y-axis, and connecting them gives a vertical line. Every equation of the form x=cx = c graphs as a vertical line through x=cx = c.

A horizontal line y = 3 and a vertical line x = -2The horizontal line y = 3 sits three units above the x-axis and the vertical line x = -2 sits two units left of the y-axis; they cross at (-2, 3).xy-22-230(-2, 3)y = 3x = -2
The equation y = 3 graphs as a horizontal line at height 3, and x = -2 graphs as a vertical line two units left of the y-axis. They cross at (-2, 3), the one point whose coordinates satisfy both equations.

These fit the same pattern as the slanted lines. You can write y=3y = 3 as 0⋅x+y=30 \cdot x + y = 3: the coefficient of xx is zero, so changing xx does not change yy, which stays at 33. In the same way, x=−2x = -2 is x+0⋅y=−2x + 0 \cdot y = -2. They are ordinary linear equations with one coefficient zero. Read y=3y = 3 as “stay at height 33” and x=−2x = -2 as “stay in the column −2-2.”

Worked example 4 Graph x=4x = 4 and y=−1y = -1 on the same axes

The equation x=4x = 4 fixes the x-coordinate at 44 and leaves yy free. Therefore its solutions are (4,−3)(4, -3), (4,0)(4, 0), (4,2)(4, 2), and so on, all in the column four units right of the y-axis. They form a vertical line through x=4x = 4.

The equation y=−1y = -1 fixes the y-coordinate at −1-1 and leaves xx free. Therefore its solutions are (−3,−1)(-3, -1), (0,−1)(0, -1), (2,−1)(2, -1), and so on, all at the height one unit below the x-axis. They form a horizontal line through y=−1y = -1.

Drawn on the same axes, the vertical line x=4x = 4 and the horizontal line y=−1y = -1 cross at the single point where both rules hold at once, namely (4,−1)(4, -1).

Check your understanding

Which of these equations graphs as a horizontal line?

Answer choices

Checking whether a point is on a line

Because the graph is exactly the set of solutions, deciding whether a given point lies on a line takes no drawing at all. Substitute the point’s coordinates into the equation. If the two sides come out equal, the point is a solution and sits on the line. If they do not, the point is off the line.

Is (3,5)(3, 5) on the graph of y=2x−1y = 2x - 1? Put in x=3x = 3 and y=5y = 5:

2(3)−1=5,2(3) - 1 = 5,

and the right side equals the point’s yy-value of 55, so (3,5)(3, 5) is on the line. Is (2,4)(2, 4) on the graph of 3x+2y=123x + 2y = 12? Substitute:

3(2)+2(4)=6+8=14,3(2) + 2(4) = 6 + 8 = 14,

which is not 1212, so (2,4)(2, 4) is not on the line. Substitution gives an exact check even when a drawing is too small to read accurately.

Worked example 5 Find a missing coordinate so a point lies on a line

The point (k,7)(k, 7) lies on the line y=2x−1y = 2x - 1. Because the point is on the line, its coordinates must satisfy the equation, so substitute y=7y = 7 and solve for the unknown xx-coordinate kk:

7=2k−1,8=2k,k=4.7 = 2k - 1, \qquad 8 = 2k, \qquad k = 4.

So the point is (4,7)(4, 7).

For a second case, find the point on 3x+2y=123x + 2y = 12 whose x-coordinate is 11. Substitute x=1x = 1 and solve for yy:

3(1)+2y=12,2y=9,y=92.3(1) + 2y = 12, \qquad 2y = 9, \qquad y = \tfrac{9}{2}.

So the point is (1,92)\left(1, \tfrac{9}{2}\right). The fractional yy is no problem: the line passes through plenty of points that do not land on whole-number grid marks, and this is one of them.

Common mistakes

Practice

Multiple Choice Questions (MCQ)

Progressively harder sets of questions. Each opens on its own page.

Core practice

Practice problems at the level of the course, to be worked out on paper. Hints one at a time, then the answer or the full worked solution, with your progress kept in this browser.

Core practice Work it out on paper 10 problems Start →
More practice (optional)

Extra sets, as hard as the Challenge set. Each one opens on its own page.

More resources (optional)

Other explanations of this lesson, if you want a second take.

A bit of history (optional)

How could a picture show something changing? In the 1300s, the French scholar Nicole Oresme explored that question by representing the size of one quantity along another. A changing speed, for example, could be pictured by lengths standing above a line representing time. Uniform change gave the picture a straight upper edge. Oresme was interested in motion as well as mathematics; he later became bishop of Lisieux. (MacTutor biography; historical study of his diagrams, p. 164.)

These pictures were not yet the algebraic graphs used today. In the 1630s, René Descartes and Pierre de Fermat developed ways to study geometry with equations. Their work traveled by different routes: Descartes published La Géométrie in 1637, while Fermat sent his methods to other mathematicians in letters and manuscripts. Both routes helped make algebra a way to investigate shapes. (Descartes, Fermat.)

Your progress

See all your progress →