The slope formula finds the slope m of a line through two points (x₁, y₁) and (x₂, y₂): m = (y₂ − y₁) / (x₂ − x₁), the rise divided by the run. For (1, 2) and (4, 8), m = (8 − 2) / (4 − 1) = 6/3 = 2.
Reviewed by the Helping with Math Team · Updated 22 October 2026
What is the slope formula?
A straight line can be written as y = mx + b, where m is the slope of the line. There is more on this here. The slope formula lets you find m from any two points on the line.
The slope is the difference in the y-values divided by the difference in the x-values. This is often called the rise over the run.
m = (y₂ − y₁) / (x₂ − x₁)
- Rise = y₂ − y₁ (the vertical change).
- Run = x₂ − x₁ (the horizontal change).
- Positive slope: the line goes up from left to right. Negative slope: it goes down.
- Slope 0: a horizontal line. A vertical line has an undefined slope because the run is 0.
Examples using the formula
Example 1
Find the slope of the line through (1, 2) and (4, 8).
Solution
m = (8 − 2) / (4 − 1) = 6/3 = 2. The line rises 2 units for every 1 unit to the right.
Example 2
Find the slope again, this time taking (4, 8) as the first point and (1, 2) as the second.
Solution
m = (2 − 8) / (1 − 4) = −6 / −3 = 2. It does not matter which point you call (x₁, y₁), as long as you use the same order on the top and the bottom.
Example 3
Find the slope of the line through (−2, 5) and (3, −5).
Solution
m = (−5 − 5) / (3 − (−2)) = −10/5 = −2. The slope is negative, so the line falls from left to right.
Example 4
Find the slope of the line through (2, 3) and (7, 3).
Solution
m = (3 − 3) / (7 − 2) = 0/5 = 0. The line is horizontal.
Example 5
Find the slope of the line through (5, 1) and (5, 6).
Solution
m = (6 − 1) / (5 − 5) = 5/0, which is undefined. The line is vertical.
Try it: slope explorer
Move the two points. The rise, run and slope update, and the triangle shows the rise over the run.
rise = 5 − 2 = 3, run = 4 − 1 = 3, m = 1
Common mistakes
- Putting the x difference on top. Rise (y) goes on top, run (x) on the bottom.
- Mixing the order: (y₂ − y₁) on top but (x₁ − x₂) on the bottom gives the wrong sign.
- Forgetting that subtracting a negative means adding: 3 − (−2) = 5.
Worksheets
Use this worksheet for practice: Calculating the Slope of a Line, using m = (y₂ − y₁)/(x₂ − x₁) (2 pages).
Check yourself: the slope formula
4 quick questions. Tap an answer to see if you are right.
Slope through (0, 1) and (2, 7)?
m = (7 − 1) / (2 − 0) = 6/2 = 3.
Slope through (1, 5) and (3, 1)?
m = (1 − 5) / (3 − 1) = −4/2 = −2.
Slope through (4, 2) and (9, 2)?
The rise is 2 − 2 = 0, so m = 0/5 = 0.
Slope through (3, 1) and (3, 8)?
The run is 3 − 3 = 0, and you cannot divide by 0.
Answered 0 of 4.
Slope Formula FAQs
What is the slope formula?
m = (y₂ − y₁) / (x₂ − x₁): the change in y divided by the change in x between two points.
Does it matter which point is first?
No, as long as you subtract in the same order on the top and the bottom.
What does a negative slope mean?
The line goes down from left to right.
What is the slope of a horizontal line?
0, because the rise is 0.
Why is the slope of a vertical line undefined?
The run is 0, and you cannot divide by 0.








