30% off your first 3 months

Get the deal

Graphing a line from its equation

by DuckyHelperNov 12, 20264 min read
Math

TL;DR:

  • In y = mx + b, b is where the line crosses the y axis and m is the slope.

  • Start at the intercept and use the slope as rise over run to plot more points.

  • Parallel lines share a slope. Perpendicular slopes multiply to −1.

An equation like y = −2x + 4 packs a whole picture into a few symbols. Two numbers in it tell you where to start and which way to go. Once you can read them, a line takes less than a minute to draw, and you can check it with a single test point.

Reading y = mx + b

In the slope-intercept form y = mx + b, the number b is the y-intercept: the point (0, b) where the line crosses the vertical axis. The number m is the slope, rise over run, as in slope as a rate of change. A positive slope climbs to the right and a negative slope falls.

Worked example: y = −2x + 4

  1. Read the intercept: b = 4, so plot (0, 4).

  2. Read the slope: m = −2, which is −2/1. From (0, 4), go right 1 and down 2 to reach (1, 2).

  3. Repeat: right 1, down 2 again gives (2, 0). This is the x-intercept.

  4. You can go backwards too: left 1, up 2 gives (−1, 6).

  5. Draw a straight line through the points, extending with arrows at both ends.

x

y = −2x + 4

−1

6

0

4

1

2

2

0

3

−2

Points on the line

Check every row: −2(−1) + 4 = 6, −2(0) + 4 = 4, −2(1) + 4 = 2, −2(2) + 4 = 0, −2(3) + 4 = −2. All match.

Check with a test point

Pick a point you did not use for plotting and see whether it lies on the line. Try x = 5: y = −10 + 4 = −6. Is (5, −6) on your drawing? Follow the slope: from (3, −2), right 1 and down 2 gives (4, −4), then (5, −6). Yes. A point that does not fit the equation is off the line. For example, (1, 3) gives −2 + 4 = 2 ≠ 3, so it lies above the line.

Two quick intercepts

Another way to graph is to find where the line meets each axis. Set x = 0 for the y-intercept: y = 4. Set y = 0 for the x-intercept: 0 = −2x + 4, so x = 2. Plot (0, 4) and (2, 0) and join them. That uses only two points, so a third point is a worthwhile check. The same line can be written in standard form as 2x + y = 4.

Parallel and perpendicular lines

  • Parallel lines have the same slope and different intercepts. A line parallel to y = −2x + 4 through (0, 1) is y = −2x + 1.

  • Perpendicular lines have slopes whose product is −1, the negative reciprocal. A line perpendicular to slope −2 has slope 1/2, since −2 × 1/2 = −1. Through (0, 4): y = ½x + 4.

Test perpendicularity with a point: the two lines meet at (0, 4). From there, the first goes right 1 and down 2, and the second goes right 2 and up 1. Those two moves form a right angle, as the vectors (1, −2) and (2, 1) have a dot product 1×2 + (−2)×1 = 0.

Try three more yourself

Graph y = ½x − 3. The intercept is (0, −3). The slope is 1/2, so go right 2 and up 1: (2, −2), (4, −1), (6, 0). Check: ½(6) − 3 = 0.

Build an equation from two points, (1, 5) and (3, 9). The slope is (9 − 5)/(3 − 1) = 4/2 = 2. Substitute a point to find b: 5 = 2(1) + b, so b = 3. The line is y = 2x + 3. Check the other point: 2(3) + 3 = 9.

Convert 3x + 2y = 12 to slope-intercept form: 2y = −3x + 12, so y = −1.5x + 6. The intercepts are (0, 6) and, setting y to 0, 3x = 12, so (4, 0). Check: −1.5(4) + 6 = 0.

Special cases

  • A horizontal line y = 3 has slope 0.

  • A vertical line x = 2 has an undefined slope and is not a function of x.

  • A line through the origin has b = 0, like y = 3x.

If you are given a graph rather than an equation, work in reverse. Read the y-intercept where the line crosses the vertical axis, pick two clear grid points to find the rise and run, and write y = mx + b. Then check your equation against a third point on the picture. This works both ways, so you can move freely between an equation and its line.

How to check your answer

  • Intercept. Does your line cross the y axis at b?

  • Direction. Negative slope should fall left to right.

  • Third point. Plug a new x into the equation and see if the point lies on the drawn line.

  • Steepness. A slope of magnitude 2 is steeper than a slope of 1.

Common mistakes

  • Plotting rise and run in the wrong order, using right 2 and down 1.

  • Ignoring the sign of the slope.

  • Misreading y = −2x + 4 as intercept −2.

  • Joining points with a curve.

  • Using the x-intercept as the b value.

Where you will use it next

Boundary lines like this one are the first step in graphing inequalities, as in inequalities and why the sign flips. Directions and steps along a line become arrows in vectors: adding forces and velocities.

Frequently asked questions

What if the equation is not in slope-intercept form?

Solve it for y first. For example, 2x + y = 4 becomes y = −2x + 4.

How many points do I need to draw a line?

Two define a line. A third acts as a check.

Get started

DuckyHelper can
do more

It sees your screen and works in any app you use. Try it for 10 minutes, no card.

Get it for Mac, Windows or Linux

Share

Questions and jobs

Do anything

Ask it a question or hand it a job, in any app.

Doing jobs for you is in early access on Mac. Asking works on Mac, Windows and Linux.