Slope Calculator

Slope, line equation, distance and midpoint from two points.

Slope Calculator by AIPreciseTools · Open the full calculator ↗

Slope formula

Slope m = (y₂ − y₁) ÷ (x₂ − x₁) ("rise over run") Slope-intercept form: y = mx + b, where b = y₁ − m × x₁ Distance = √((x₂ − x₁)² + (y₂ − y₁)²) Midpoint = ((x₁ + x₂) ÷ 2, (y₁ + y₂) ÷ 2) Angle = arctan(m) Grade = m × 100%

Example: through (1, 2) and (4, 8), the rise is 6 and the run is 3, so the slope is 2. Then b = 2 − 2 × 1 = 0, so the line is y = 2x. The points are √(9 + 36) = 6.7082 apart, the midpoint is (2.5, 5), and the line climbs at 63.43°.

Reading a slope

  • Positive: the line rises from left to right. Negative: it falls.
  • Zero: a horizontal line, y = b. Undefined: a vertical line, x = a, because the run is zero.
  • Parallel lines have the same slope. Perpendicular lines have slopes that multiply to −1, like 2 and −½.

In roads and ramps, slope is usually given as a grade: a 5% grade rises 5 feet per 100 feet. For roof slopes, see the roofing calculator.

Frequently asked questions

How do you find the slope from two points?

Subtract the y-values and divide by the difference of the x-values, in the same order: m = (y₂ − y₁) ÷ (x₂ − x₁).

What is an undefined slope?

A vertical line has an undefined slope, because the run (change in x) is zero and you can't divide by zero.

How do I find the y-intercept?

Once you have the slope, plug either point into y = mx + b and solve for b: b = y₁ − m × x₁.

Was this calculator helpful?