Slope Calculator
The slope between two points, the line’s equation, its angle and the distance.
Good to know. A 10% road sign means 10 m up for every 100 m along. It feels far steeper on a bike.
How it works
In plain words
The slope is the change in y divided by the change in x: rise over run. The line’s equation is y = mx + b, where b, the y-intercept, is y₁ − m × x₁. The angle is the arctangent of the slope, and the distance comes from Pythagoras.
The formula
m = (y₂ − y₁) ÷ (x₂ − x₁) b = y₁ − m × x₁ angle = arctan(m) · distance = √((x₂ − x₁)² + (y₂ − y₁)²)
Worked example
From (1, 2) to (5, 10), y rises 8 while x runs 4, so the slope is 8 ÷ 4 = 2. The line is y = 2x, at an angle of 63.43°.
Sources
No outside data or rates: this is plain arithmetic.
4 automated tests check its answers on every change.
About the slope calculator
The slope of a line measures how steep it is: how much it goes up (or down) for each step to the right. Give two points on the line, and the calculator works out the slope, the line’s equation, its angle and grade, and the distance and midpoint between the points.
Slope is rise over run: the change in y divided by the change in x. A positive slope goes up to the right, a negative one down, a slope of 0 is flat, and a vertical line has no slope at all, since the run is zero. The equation y = mx + b, the slope-intercept form, gives every point on the line: m is the slope and b is where the line crosses the y-axis.
The same idea describes real slopes. Road signs give the grade as a percentage: the slope times 100, so a 10% hill rises 10 m in 100 m, about 5.7°. Wheelchair ramps are usually limited to 1:12, a grade of 8.3%. Roof pitch is the rise over a run of 12, and stairs have a rise over their going.
The distance between the two points follows from Pythagoras’ theorem on the rise and run, and the midpoint is halfway along both.
Questions people ask
How do I find the slope between two points?
Subtract the y values and divide by the difference in x values, in the same order: (10 − 2) ÷ (5 − 1) = 2.
How do I turn a slope into an angle?
Take the arctangent: a slope of 1 is 45°, and a slope of 2 is about 63.4°.
What is the slope of a vertical line?
It is undefined, because the run is zero and you can’t divide by zero. Its equation is x = a number.