The slope formula
m = (y₂ − y₁) ÷ (x₂ − x₁)
b = y₁ − m × x₁
Distance = √((x₂ − x₁)² + (y₂ − y₁)²)
Angle = arctan(m)
Slope is "rise over run": how much y changes for each step in x. A positive slope goes up to the right, a negative slope goes down, 0 is flat and a vertical line has no defined slope.
Example
Through (1, 2) and (4, 8): m = (8 − 2) ÷ (4 − 1) = 6 ÷ 3 = 2. b = 2 − 2 × 1 = 0, so the line is y = 2x. The points are 6.708 apart, the midpoint is (2.5, 5) and the line rises at 63.43°.
Tips
- It doesn't matter which point you call the first one; the slope comes out the same.
- For a roof or ramp, slope is often given as a percent: multiply m by 100. The percentage calculator can help.
- Parallel lines have equal slopes; perpendicular lines have slopes that multiply to −1.
Frequently asked questions
What is the slope of a horizontal line?
0, because y doesn't change.
What is the slope of a vertical line?
Undefined, because the run (x₂ − x₁) is 0 and you can't divide by zero.
How do I write the equation from the slope?
Use y = mx + b, with b = y₁ − m × x₁. The calculator does this for you.
What is slope?
How steep a line is: the change in y divided by the change in x, often called rise over run.
How do you find the slope from two points?
Use m = (y₂ − y₁) ÷ (x₂ − x₁). For (1, 2) and (4, 8): (8 − 2) ÷ (4 − 1) = 2.
What does a negative slope mean?
The line falls from left to right: y decreases as x increases.
Written and checked by Vijay. Last updated .