Slope Calculator
Two points define a line, and a line has more useful properties than just its gradient. This returns the equation in three forms, the angle in degrees and as a percentage grade, and the distance and midpoint.
Two Points
Any real coordinates, including negatives and decimals.
The line itself
Between the two points
Rise over run, and the two cases that break it
m = (y₂ − y₁) / (x₂ − x₁). A positive slope climbs left to right, a negative one falls, and zero is perfectly level.
The two edge cases matter. A vertical line has Δx = 0, so the slope is undefined — not infinite, not zero, undefined, because the division cannot be performed. A horizontal line has Δy = 0 and a slope of exactly zero. Calling a vertical line "infinite slope" is the mistake that produces a division-by-zero crash the first time someone codes it.
Degrees or percent: they are not the same thing
Road signs use percentage grade, which is just the slope × 100 — a 10% grade rises 10 metres over 100 horizontal metres. The angle is arctan(m), so a 10% grade is 5.7°, not 10°. They only agree near zero and diverge badly as the slope rises: a 100% grade is 45°, and there is no percentage that corresponds to vertical.
Three forms of the same line
Slope-intercept (y = mx + b) is the most readable and the fastest to graph. Point-slope (y − y₁ = m(x − x₁)) is what you write down first, before any rearranging. Standard form (Ax + By = C) is the only one that can express a vertical line, which is why linear algebra prefers it.
Perpendicular and parallel
Parallel lines share a slope. Perpendicular lines have slopes whose product is −1, so the perpendicular slope is the negative reciprocal: a line of slope 2 is crossed at a right angle by one of slope −½. The exception is the horizontal/vertical pair, where one slope is zero and the other undefined — the product rule cannot be applied and the answer is handled separately.
Frequently Asked Questions
What is the slope of a vertical line?
How do I convert a slope into an angle?
What is the difference between slope and grade?
How do I find the distance between two points?
Sources
Official publications only. Links open the original document in a new tab.
- National Institute of Standards and Technology Special Publication 811 — Guide for the use of the SI Significant figures and rounding conventions
- National Institute of Standards and Technology CODATA fundamental physical constants Values of the fundamental physical constants