Writing Equations in Slope-Intercept Form
To write an equation in slope-intercept form, find the slope m and the y-intercept b, then put them into y = mx + b. If you don’t know b, substitute the slope and one point into y = mx + b and solve for b. This works for a graph, two points or a word problem.
Before this lesson: You should know slope-intercept form, the slope formula and how to solve two-step equations.
Extra practice: The Algebra 1 Unit 4 Practice Pack (Part 1) has printable problems, answer keys and a cheat sheet for this unit.
What You Need to Write the Equation
Every line in slope-intercept form needs two numbers: the slope m and the y-intercept b. What you do depends on what you’re given.
| What you know | What to do |
|---|---|
| The slope and the y-intercept | Put them straight into y = mx + b. |
| The slope and one point | Substitute the slope and the point into y = mx + b, then solve for b. |
| Two points | Find the slope with the slope formula first. Then use one point to solve for b. |
| A graph | Read b where the line crosses the y-axis. Count the rise and run to find m. |
How to Find b From the Slope and a Point
- Write y = mx + b with your slope in place of m.
- Put the point’s x-value in for x and its y-value in for y.
- Solve the equation for b.
- Write the final equation with your m and b.
- Check: put the point back in and make sure both sides match.
Here is why this works. Every point on a line makes its equation true. So when you plug in a point, the only unknown left is b.
Worked Examples
Example 1: Slope and y-intercept
Write the equation of the line with slope −4 and y-intercept 7.
y = mx + b
Step 1. Write the slope-intercept form.
y = -4x + 7
Step 2. Substitute m = -4 and b = 7.
Answer: y = -4x + 7
Example 2: Slope and one point
Write the equation of the line with slope 3 that passes through (2, 1).
y = 3x + b
Step 1. Substitute the slope into y = mx + b.
1 = 3(2) + b
Step 2. Substitute the point: x = 2 and y = 1.
1 = 6 + b
Step 3. Multiply.
-5 = b
Step 4. Subtract 6 from both sides to solve for b (see one-step equations).
y = 3x - 5
Step 5. Write the equation with m = 3 and b = −5.
Answer: y = 3x - 5
Check: 3(2) - 5 = 6 - 5 = 1. The point (2, 1) is on the line.
Example 3: Two points
Write the equation of the line through (−2, 5) and (4, −1).
m = \frac{-1 - 5}{4 - (-2)}Step 1. Find the slope with the slope formula.
m = \frac{-1 - 5}{4 + 2}Step 2. Subtracting −2 is the same as adding 2 (see adding and subtracting integers).
m = \frac{-6}{6}Step 3. Do the top and the bottom.
m = -1
Step 4. Divide.
5 = -1(-2) + b
Step 5. Use the point (−2, 5) to find b. Substitute x = −2, y = 5 and m = −1.
5 = 2 + b
Step 6. Multiply. A negative times a negative is positive.
3 = b
Step 7. Subtract 2 from both sides.
y = -x + 3
Step 8. Write the equation with m = −1 and b = 3.
Answer: y = -x + 3
Check: Use the other point: -(4) + 3 = -4 + 3 = -1. The point (4, −1) is on the line too.
Example 4: From a graph
Write the equation of the line in the graph.
b = -2
Step 1. Find where the line crosses the y-axis: (0, −2).
Step 2. Find another point where the line crosses grid corners exactly: (3, 2).
2 - (-2) = 4
Step 3. Count the rise from (0, −2) up to the level of (3, 2). The line goes up 4.
3 - 0 = 3
Step 4. Count the run from x = 0 to x = 3. The line goes right 3.
m = \frac{4}{3}Step 5. Divide the rise by the run.
y = \frac{4}{3}x - 2Step 6. Substitute m and b into y = mx + b.
Answer: y = \frac{4}{3}x - 2
Example 5: Word problem
A taxi charges a starting fee plus a cost per mile. A 3-mile ride costs $10.50, and an 8-mile ride costs $20.50. Write an equation for the cost C of a ride of d miles.
Step 1. Write the facts as points (miles, cost): (3, 10.50) and (8, 20.50).
m = \frac{20.50 - 10.50}{8 - 3}Step 2. Find the slope, which is the cost per mile.
m = \frac{10}{5}Step 3. Subtract on the top and on the bottom.
m = 2
Step 4. Divide.
10.50 = 2(3) + b
Step 5. Use (3, 10.50) to find b, the starting fee.
10.50 = 6 + b
Step 6. Multiply.
4.50 = b
Step 7. Subtract 6 from both sides.
Answer: C = 2d + 4.50. The taxi charges $2 per mile plus a $4.50 starting fee.
Check: An 8-mile ride: 2(8) + 4.50 = 16 + 4.50 = 20.50. It matches.
Common Mistakes
| Mistake | What it looks like | How to fix it |
|---|---|---|
| Using the point’s y-value as b | Slope 3 through (2, 1) written as y = 3x + 1 | b is the y-value only when x = 0. Solve for b. |
| Adding instead of subtracting | 5 = 2 + b, so b = 7 | Subtract 2 from both sides: b = 3. |
| Slope upside down | Points (1, 3) and (3, 11) give m = \frac{2}{8} | The y-values go on top: m = \frac{8}{2} = 4. |
| Sign errors with negatives | -1(-2) = -2 | A negative times a negative is positive: -1(-2) = 2. |
| Skipping the check | Writing an equation that misses one of the points | Put the other point into your equation. Both sides should match. |
Special Cases
- Horizontal lines: The line through (−4, 3) and (6, 3) has slope \frac{0}{10} = 0. Its equation is y = 3.
- Vertical lines: The line through (3, 1) and (3, 8) has the same x-value for both points. Its slope is undefined, so the equation is x = 3. It can’t be written as y = mx + b. See Horizontal and Vertical Lines.
- Another method: Point-slope form, y - y_1 = m(x - x_1), is another way to write a line from a point and a slope. It has its own lesson later in this unit.
Practice Problems
Write each equation in slope-intercept form.
- Slope 5, y-intercept −2
- Slope -\frac{2}{3}, y-intercept 4
- Slope 2, through (3, 10)
- Slope −3, through (−1, 8)
- Slope \frac{1}{4}, through (8, 1)
- Through (1, 3) and (3, 11)
- Through (−2, 6) and (2, −2)
- Through (0, −5) and (5, 0)
- Through (−4, 3) and (6, 3)
- A plumber charges a fixed fee plus an hourly rate. A 2-hour job costs $190, and a 5-hour job costs $340. Write an equation for the cost C of an h-hour job.
Show answers
1.
y = 5x - 2
Substitute m = 5 and b = −2 into y = mx + b.
2.
y = -\frac{2}{3}x + 4Substitute m = -\frac{2}{3} and b = 4.
3.
10 = 2(3) + b
Substitute m = 2 and the point (3, 10)
10 = 6 + b
Multiply.
b = 4
Subtract 6 from both sides.
The equation is y = 2x + 4.
4.
8 = -3(-1) + b
Substitute m = −3 and the point (−1, 8)
8 = 3 + b
Multiply.
b = 5
Subtract 3 from both sides.
The equation is y = -3x + 5.
5.
1 = \frac{1}{4}(8) + bSubstitute m = \frac{1}{4} and the point (8, 1)
1 = 2 + b
Multiply.
b = -1
Subtract 2 from both sides.
The equation is y = \frac{1}{4}x - 1.
6.
m = \frac{11 - 3}{3 - 1} = \frac{8}{2} = 4Find the slope.
3 = 4(1) + b
Substitute m = 4 and the point (1, 3)
3 = 4 + b
Multiply.
b = -1
Subtract 4 from both sides.
The equation is y = 4x - 1.
7.
m = \frac{-2 - 6}{2 - (-2)} = \frac{-8}{4} = -2Find the slope.
6 = -2(-2) + b
Substitute m = −2 and the point (−2, 6)
6 = 4 + b
Multiply.
b = 2
Subtract 4 from both sides.
The equation is y = -2x + 2.
8.
m = \frac{0 - (-5)}{5 - 0} = \frac{5}{5} = 1Find the slope.
b = -5
The point (0, −5) is on the y-axis, so it is the y-intercept.
The equation is y = x - 5.
9.
m = \frac{3 - 3}{6 - (-4)} = \frac{0}{10} = 0Find the slope.
b = 3
A slope of 0 means a horizontal line. Both points have y = 3.
The equation is y = 0x + 3, or y = 3.
10.
Write the facts as points (hours, cost): (2, 190) and (5, 340)
m = \frac{340 - 190}{5 - 2} = \frac{150}{3} = 50Find the slope.
190 = 50(2) + b
Substitute m = 50 and the point (2, 190)
190 = 100 + b
Multiply.
b = 90
Subtract 100 from both sides.
The equation is C = 50h + 90: $50 per hour plus a $90 fee.
Want more practice? The Algebra 1 Unit 4 Practice Pack (Part 1) has 39 pages of problems on this and the other lessons in the unit, with step-by-step answers and a cheat sheet.
Writing Equations FAQ
How do you write an equation in slope-intercept form from two points?
Find the slope with m = \frac{y_2 - y_1}{x_2 - x_1}. Then put the slope and one of the points into y = mx + b and solve for b.
How do you find b in y = mx + b?
Put the slope and any point on the line into y = mx + b, then solve for b. If you have a graph, b is where the line crosses the y-axis.
How do you write an equation from a graph?
Read the y-intercept where the line crosses the y-axis. Then count the rise and run between two grid points to find the slope.
Can you write a vertical line in slope-intercept form?
No. A vertical line has an undefined slope, so you write it as x = a instead.
Summary
- Slope-intercept form is y = mx + b. You need m and b.
- With two points, find the slope first.
- To find b, put the slope and one point into y = mx + b and solve.
- On a graph, b is where the line crosses the y-axis.
- Always check your equation with a second point.
Previous lesson: Slope-Intercept Form
Next lesson: Point-Slope Form
Next unit: Systems of Equations
Back to the Algebra 1 Index