Part 8 of 10 · LinesSee the whole course
How to find the equation of a line from two points
Find the slope from the two points, then put one point into y = mx + b to find b. Write m and b into the equation, and check it with the other point.
The four steps
- Find the slope. m = (y₂ − y₁) ÷ (x₂ − x₁), with the points in the same order on the top and the bottom. (If that is new, see how to find the slope from two points.)
- Find b. Put m and one of the points into y = mx + b, then solve for b.
- Write the equation. Replace m and b in y = mx + b.
- Check. Put the other point in. If the equation is true, you are done.
Try it. Point A stays at (1, 2). Move point B and watch the three steps change.
- slope = (8 − 2) ÷ (3 − 1) = 3
- b = 2 − 3 × 1 = −1
- y = 3x − 1
Example 1: (1, 2) and (3, 8)
Slope: (8 − 2) ÷ (3 − 1) = 6 ÷ 2 = 3
Find b: 2 = 3(1) + b, so b = −1
Equation: y = 3x − 1
Check (3, 8): 3(3) − 1 = 8 ✓
This is the picture above, in its starting position.
Example 2: with negative numbers, (−2, 5) and (4, −1)
Slope: (−1 − 5) ÷ (4 − (−2)) = −6 ÷ 6 = −1
Find b: 5 = (−1)(−2) + b, so 5 = 2 + b and b = 3
Equation: y = −x + 3
Check (4, −1): −4 + 3 = −1 ✓
Put brackets around negative numbers when you substitute. (−1)(−2) is +2, and that is where most sign slips happen.
Example 3: when the line is vertical, (2, 1) and (2, 7)
Both points have x = 2, so the run is 2 − 2 = 0 and the slope is undefined. A vertical line cannot be written as y = mx + b. It is simply x = 2: every point on it has x equal to 2. (More on this in our post on horizontal and vertical lines.)
Why one point is enough for b
The slope says how steep the line is, but not where it sits. One point pins it down. Once you know the slope and one point that is on the line, there is only one line it can be, so the other point is not needed for finding b. It is your check.
You may also see the point-slope form, y − y₁ = m(x − x₁). For Example 1 it is y − 2 = 3(x − 1). Expand it and you get the same y = 3x − 1.
Watch it explained in under a minute
The five mistakes to avoid
- Stopping after the slope. The slope is only half of the equation.
- Subtracting the points in a different order on the top and the bottom.
- Reading b off the wrong place. b is the height where the line crosses the y-axis, not the y-value of your point (unless the point is on the y-axis).
- Sign slips with negatives. Use brackets: 5 = (−1)(−2) + b.
- Skipping the check. Putting the other point in takes ten seconds and catches most errors.
Try it yourself
Find the equation of the line through each pair of points. Tap a question to see the answer.
1. (0, 3) and (2, 7)
Slope: (7 − 3) ÷ (2 − 0) = 2. The point (0, 3) is on the y-axis, so b = 3. y = 2x + 3. Check (2, 7): 4 + 3 = 7 ✓.
2. (1, 5) and (3, 1)
Slope: (1 − 5) ÷ (3 − 1) = −2. Then 5 = (−2)(1) + b, so b = 7. y = −2x + 7. Check (3, 1): −6 + 7 = 1 ✓.
3. (2, 4) and (6, 6)
Slope: (6 − 4) ÷ (6 − 2) = 2 ÷ 4 = ½. Then 4 = ½(2) + b, so b = 3. y = ½x + 3. Check (6, 6): 3 + 3 = 6 ✓.
Where this fits in
You now go both ways: from an equation to a graph (graph a line from its equation) and from two points back to an equation. The next post covers the two special cases that do not fit the pattern: horizontal and vertical lines.