How to Find the Slope of a Line from Two Points
For two points with different x-coordinates, slope is the change in y divided by the change in x: m = (y2 - y1) / (x2 - x1). Two distinct points with the same x-coordinate define a vertical line with undefined slope.
On this page▾
What slope measures
Slope compares how much a line goes up or down (the rise) with how much it moves left to right (the run). The usual letter for slope is m.
The Common Core grade 8 standards explain why one number is enough to describe a whole line: using similar triangles, students show that the slope m is the same between any two distinct points on a non-vertical line. In other words, it does not matter which two points you pick. If they are on the same straight line, you get the same slope.
The formula
For two distinct points (x1, y1) and (x2, y2), with x2 different from x1:
m = (y2 - y1) / (x2 - x1)
The top is the change in y (the rise). The bottom is the change in x (the run). Subtract in the same order on top and bottom. If both given points are identical, they do not determine a unique line or slope.
Example 1: a positive slope
Find the slope through (2, 3) and (6, 11).
- Change in y: 11 - 3 = 8
- Change in x: 6 - 2 = 4
- Slope: 8 / 4 = 2
A slope of 2 means that every time x goes up by 1, y goes up by 2. The line rises as you read it from left to right.
Check by swapping the order: (3 - 11) / (2 - 6) = -8 / -4 = 2. Same answer, which confirms the order does not matter as long as you are consistent.
Example 2: a negative slope
Find the slope through (-1, 5) and (3, -3).
- Change in y: -3 - 5 = -8
- Change in x: 3 - (-1) = 4
- Slope: -8 / 4 = -2
The line falls as you read it from left to right. Watch the double negative in the run: subtracting -1 is the same as adding 1.
Example 3: zero and undefined slopes
Through (1, 4) and (5, 4), the change in y is 4 - 4 = 0, so the slope is 0 / 4 = 0. The line is horizontal.
Through (3, 1) and (3, 7), the change in x is 3 - 3 = 0, so the formula asks you to divide 6 by 0. Division by zero is not defined, so a vertical line has an undefined slope. This is exactly why the grade 8 standard limits its statement to non-vertical lines.
| Two points | Rise | Run | Slope | Line looks |
|---|---|---|---|---|
| (2, 3), (6, 11) | 8 | 4 | 2 | rising |
| (-1, 5), (3, -3) | -8 | 4 | -2 | falling |
| (1, 4), (5, 4) | 0 | 4 | 0 | flat |
| (3, 1), (3, 7) | 6 | 0 | undefined | vertical |
From slope to the equation y = mx + b
The same grade 8 standard asks students to derive the equation y = mx + b for a line that crosses the vertical axis at b. Once you have m, you only need b, the y-intercept.
Using Example 1: m = 2, and the line passes through (2, 3).
- Start with y = 2x + b.
- Substitute the point: 3 = 2(2) + b, so 3 = 4 + b.
- Solve: b = -1.
The equation is y = 2x - 1.
Check with the other point: at x = 6, y = 2(6) - 1 = 11. That matches (6, 11), so the equation is right.
Using Example 2: m = -2 and the point (-1, 5). Then 5 = -2(-1) + b, so 5 = 2 + b and b = 3. The equation is y = -2x + 3. Check with (3, -3): -2(3) + 3 = -3. It matches.
Finding where two lines meet is covered in How to Solve a System of Two Linear Equations.
A word problem: rate of change and starting value
The grade 8 functions standards describe slope in real situations as a rate of change, and the y-intercept as the initial value, found from a description or from two (x, y) values.
Problem: A candle is 20 cm tall after burning for 2 hours and 14 cm tall after 5 hours. It burns at a steady rate. How fast is it burning, and how tall was it at the start?
Treat time as x and height as y, giving the points (2, 20) and (5, 14).
- Slope: (14 - 20) / (5 - 2) = -6 / 3 = -2. The candle loses 2 cm per hour.
- Starting height: 20 = -2(2) + b, so b = 24. The candle started at 24 cm.
The model is height = -2(hours) + 24. The negative slope makes sense, since the candle gets shorter over time, and the units of the slope are centimeters per hour.
Common mistakes
- Mixing the order. Writing (y2 - y1) on top but (x1 - x2) on the bottom flips the sign of your answer. Pick a first point and stick with it.
- Putting x on top. Slope is rise over run: change in y divided by change in x.
- Losing a negative sign. Subtracting a negative coordinate can cause a sign error. Write the parentheses: 3 - (-1).
- Calling a vertical line's slope zero. Horizontal lines have slope 0. Vertical lines have an undefined slope.
Sources
About this guide
Howlane operator · Checked against the official sources listed above. It is general information, not professional advice.
AboutEditorial standardsCorrectionsReport an error
Edit history
- Updated
- Updated
- Updated
- Updated
- Published