Enter two coordinate points to calculate slope, line equation, distance and midpoint.
Slope Formula Explained
Slope is rise over run: m = (y₂ − y₁) ÷ (x₂ − x₁). From (1, 2) to (4, 8) the line rises 6 over a run of 3, so the slope is 2. A horizontal line has slope 0 and a vertical line has an undefined slope. Enter two points above to get the slope, the line equation, the distance, the midpoint and the angle.
Slope (m) measures the steepness and direction of a line. It is defined as rise over run: the change in y divided by the change in x between any two points on the line. A positive slope rises left to right; negative falls; zero is horizontal; undefined is vertical.
Slope Formula
Slope-Intercept Form
Distance Formula
Midpoint Formula
Slope as Ratio, Percent Grade and Degrees
The same steepness can be written three ways. Percent grade is the slope times 100, and the angle is arctan(slope). A 100% grade is 45°, not vertical.
| Rise : run | Slope m | Percent grade | Angle |
|---|---|---|---|
| 1 : 20 | 0.05 | 5% | 2.86° |
| 1 : 12 | 0.0833 | 8.33% | 4.76° |
| 1 : 10 | 0.1 | 10% | 5.71° |
| 1 : 8 | 0.125 | 12.5% | 7.13° |
| 1 : 4 | 0.25 | 25% | 14.04° |
| 1 : 2 | 0.5 | 50% | 26.57° |
| 1 : 1 | 1 | 100% | 45° |
| 2 : 1 | 2 | 200% | 63.43° |
| 4 : 1 | 4 | 400% | 75.96° |
Under the 2010 ADA Standards, a walking surface steeper than 1:20 counts as a ramp, and a ramp may be no steeper than 1:12. Going the other way from degrees: 5° is an 8.75% grade, 10° is 17.63% and 30° is 57.74%.
Roof Pitch to Degrees
Roof pitch gives the rise in inches for every 12 inches of run, so a 6/12 roof has a slope of 6 ÷ 12 = 0.5.
| Pitch | Slope | Percent grade | Angle |
|---|---|---|---|
| 2/12 | 0.1667 | 16.67% | 9.46° |
| 3/12 | 0.25 | 25% | 14.04° |
| 4/12 | 0.3333 | 33.33% | 18.43° |
| 5/12 | 0.4167 | 41.67% | 22.62° |
| 6/12 | 0.5 | 50% | 26.57° |
| 8/12 | 0.6667 | 66.67% | 33.69° |
| 10/12 | 0.8333 | 83.33% | 39.81° |
| 12/12 | 1 | 100% | 45° |
Worked Examples
A negative slope
Points (−2, 5) and (4, −1). Rise = −1 − 5 = −6, run = 4 − (−2) = 6, so m = −1. The intercept is b = 5 − (−1)(−2) = 3, giving y = −x + 3. The line falls one unit for each unit to the right and meets the x-axis at 135°.
A decimal slope
Points (3, −2) and (7, 4). m = 6 ÷ 4 = 1.5 and b = −2 − 1.5 × 3 = −6.5, so y = 1.5x − 6.5. The distance between the points is √(4² + 6²) = 7.21 and the angle of inclination is 56.31°.
A vertical line
Points (2, 3) and (2, 7). The run is 0, and dividing by zero has no answer, so the slope is undefined. The line is x = 2, and any line perpendicular to it is horizontal with slope 0.
Ramp and road grades
A ramp that climbs 30 inches at the 1:12 maximum needs 30 × 12 = 360 inches, or 30 ft, of run. A road at a 6% grade climbs 0.06 × 5,280 = 316.8 ft over one mile.
Common Mistakes
- Subtracting in a different order. If you take y₂ − y₁ on top, take x₂ − x₁ below. Mixing the order flips the sign.
- Run over rise. Slope is the vertical change divided by the horizontal change, not the other way round.
- Percent read as degrees. A 100% grade is 45°. A 10% road is only 5.71°.
- Zero and undefined mixed up. Horizontal lines have slope 0. Vertical lines have no slope at all.
- Using the same point twice. Two identical points do not define a line, so there is no slope to find.