Slope Formula and Slope-Intercept Form (y = mx + b) With Examples

Slope of the line through (1, 3) and (4, 9): rise 6 over run 3 gives m = 2, and the slope-intercept form is y = 2x + 1

The slope of a line is m = (y2 − y1) ÷ (x2 − x1), the rise divided by the run, and slope-intercept form writes the line as y = mx + b, where b is the y-intercept. For the points (1, 3) and (4, 9), m = 6 ÷ 3 = 2, and 3 = 2(1) + b gives b = 1, so the line is y = 2x + 1.

In short: Slope = rise ÷ run = change in y ÷ change in x. In y = mx + b, m is the slope (steepness) and b is where the line crosses the y-axis.

In this guide
  1. The slope formula
  2. Types of slope
  3. Slope from two points
  4. Slope-intercept form
  5. How to graph y = mx + b
  6. Write the equation of a line
  7. From standard form
  8. Parallel and perpendicular lines
  9. Slope in real life
  10. Common mistakes
  11. Practice problems
  12. FAQ

The Slope Formula

Slope measures how steep a line is: how much y changes when x goes up by 1. For any two points (x1, y1) and (x2, y2) on the line:

m = (y2 − y1) ÷ (x2 − x1)

Slope of the line through (1, 3) and (4, 9): rise 6 over run 3 gives m = 2, and the slope-intercept form is y = 2x + 1
From (1, 3) to (4, 9) the line rises 6 and runs 3, so the slope is 2.

The Four Types of Slope

TypeWhat the line doesExample
PositiveGoes up from left to righty = 2x + 1 (m = 2)
NegativeGoes down from left to righty = −3x + 4 (m = −3)
ZeroFlat (horizontal)y = 5 (m = 0)
UndefinedStraight up and down (vertical)x = 2 (run is 0, so you cannot divide)

How to Find the Slope From Two Points

  1. Label the points (x1, y1) and (x2, y2).
  2. Subtract the y-values: y2 − y1.
  3. Subtract the x-values in the same order: x2 − x1.
  4. Divide and simplify.

Example: (−2, 5) and (3, −5): m = (−5 − 5) ÷ (3 − (−2)) = −10 ÷ 5 = −2.

Example: (2, 7) and (5, 7): m = (7 − 7) ÷ (5 − 2) = 0 ÷ 3 = 0, a horizontal line.

Slope-Intercept Form: y = mx + b

In y = mx + b, m is the slope and b is the y-intercept, the point (0, b) where the line crosses the y-axis. In y = 2x + 1, the slope is 2 and the line crosses the y-axis at (0, 1).

How to Graph y = mx + b

  1. Plot the y-intercept (0, b).
  2. Use the slope as rise over run to find a second point.
  3. Draw a straight line through the two points.

Example: Graph y = (2/3)x − 1. Start at (0, −1). The slope 2/3 means up 2 and right 3, which lands on (3, 1). Join the points.

How to Write the Equation of a Line

From two points: find m, then put one point into y = mx + b to find b.

Example: Through (1, 3) and (4, 9): m = 2. Then 3 = 2(1) + b, so b = 1 and the line is y = 2x + 1. Check with (4, 9): 2(4) + 1 = 9 ✓.

From a slope and a point (point-slope form): use y − y1 = m(x − x1), then simplify.

Example: Slope −1/2 through (4, 6): y − 6 = −1/2(x − 4), so y = −1/2x + 2 + 6 = −1/2x + 8.

From Standard Form to Slope-Intercept Form

Solve the equation for y. This is the same skill as solving for x.

Example: 3x + 2y = 8 → 2y = −3x + 8 → y = −3/2x + 4. The slope is −3/2 and the y-intercept is 4.

Try it

Type an equation such as 2x + 3y = 12 and choose “solve for y” to get y = −2/3x + 4 with every step.

Open the solve for x calculator

Parallel and Perpendicular Lines

  • Parallel lines have the same slope: y = 2x + 1 and y = 2x − 5 never meet.
  • Perpendicular lines have slopes that multiply to −1. A line perpendicular to y = 2x + 1 has slope −1/2.

Slope in Real Life

Slope is a rate of change. A taxi charges $3 to start and $2 per kilometer, so the cost is y = 2x + 3. The slope 2 is the price per kilometer and the intercept 3 is the starting fee. A 10 km ride costs 2(10) + 3 = $23.

Common Mistakes

  • Mixing the order. If you start with y2 on top, start with x2 on the bottom.
  • Putting x over y. Slope is change in y over change in x.
  • Dropping the minus sign when subtracting a negative coordinate: 3 − (−2) = 5.
  • Calling a vertical line slope 0. Horizontal lines have slope 0; vertical lines have undefined slope.

Practice Problems (With Answers)

1. Find the slope through (2, 1) and (6, 9).

(9 − 1) ÷ (6 − 2) = 8 ÷ 4 = 2.

2. Find the slope through (0, 4) and (2, 0).

(0 − 4) ÷ (2 − 0) = −2.

3. Write the equation of the line through (1, 2) and (3, 8).

m = 6 ÷ 2 = 3. Then 2 = 3(1) + b, so b = −1: y = 3x − 1.

4. Write 4x + 2y = 10 in slope-intercept form.

2y = −4x + 10, so y = −2x + 5.

5. What slope is perpendicular to y = 4x − 7?

−1/4, because 4 × (−1/4) = −1.

FAQ

What is the slope formula?

m = (y₂ − y₁) ÷ (x₂ − x₁). For (1, 3) and (4, 9), m = 6 ÷ 3 = 2.

What do m and b mean in y = mx + b?

m is the slope (how steep the line is) and b is the y-intercept, where the line crosses the y-axis.

How do you find the equation of a line from two points?

Find the slope, then substitute one point into y = mx + b to find b. Through (1, 3) and (4, 9), the line is y = 2x + 1.

What is the slope of a horizontal or vertical line?

A horizontal line has slope 0. A vertical line has an undefined slope because the run is 0.

How do you know if two lines are perpendicular?

Their slopes multiply to −1, such as 2 and −1/2.

Sources and Further Reading

Related: systems of equations, functions in algebra, basic algebra formulas, the math glossary and all free math calculators.

Check your working in seconds

Type any problem from this guide into the free CalcSolver calculator and see the answer, with fractions, instantly.