Slope Calculator
Slope is rise over run: m = (y2 - y1) / (x2 - x1). Enter two points to get the slope, angle, distance, line equation, grade in percent, roof pitch and a check against the 1:12 ADA ramp limit.
Enter two points. The calculator returns the slope, the angle, the distance, the line equation and the grade, and it checks a ramp against the 1:12 ADA limit.
| Slope (m) | |
| Rise and run | |
| Angle from horizontal | |
| Distance between the points | |
| y-intercept | |
| Equation | |
| Perpendicular slope | |
| Grade | |
| Roof pitch | |
| Ramp check (ADA) |
All calculations run in your browser, and nothing you type is uploaded or stored.
Enter two points to get the slope, angle, distance, line equation, grade and roof pitch, plus a check against the ADA ramp limit.
Key takeaways
- The points (2, 3) and (8, 15) give a rise of 12, a run of 6 and a slope of 2
- A 1:12 ramp is 8.33 percent and 4.76 degrees, the ADA maximum
- A 6/12 roof pitch is a slope of 0.5, which is 50 percent and 26.57 degrees
- Percent grade is rise / run x 100, and it is not the same scale as degrees
- A vertical line has no slope because the run is zero
On this page
Slope is rise over run
Slope measures how steep a line is, and it is one division: m = (y2 - y1) / (x2 - x1). The top of that fraction is the rise, the vertical change between the points. The bottom is the run, the horizontal change. A slope of 2 means the line climbs 2 units for every 1 unit it moves right.
The order of subtraction has to match. Subtracting the y values in one order and the x values in the other flips the sign and gives a slope that describes a line going the wrong way. Subtracting both in reverse is fine, because the two minus signs cancel: (3 - 15) / (2 - 8) is also 2.
| Slope | Example points | What the line does |
|---|---|---|
| Positive | (2, 3) and (8, 15), m = 2 | rises from left to right |
| Negative | (0, 0) and (3, -4), m = -1.33 | falls from left to right |
| Zero | (1, 4) and (9, 4), m = 0 | flat, the y value never changes |
| Undefined | (2, 1) and (2, 7) | vertical, the run is zero and the division has no answer |
Zero and undefined get confused often. A flat line has slope 0, because the rise is 0 while the run is 8. A vertical line has no slope at all, because the run is 0 and nothing can be divided by it. The calculator reports both cases in words rather than printing a fake number.
Slope is also a rate. If x is hours and y is dollars, a slope of 2 means 2 dollars per hour. That reading is why the same number shows up as a grade, a pitch and a trend, depending on what the axes measure.
Worked example: a wheelchair ramp
A ramp rises 30 inches over a horizontal run of 360 inches. The slope is 30 / 360 = 0.08333, which is the ratio 1:12 written as a decimal. As a grade that is 8.33 percent, and as an angle it is 4.76 degrees.
Those three numbers describe one ramp. The 2010 ADA Standards cap a ramp run at exactly this ratio: 1:12, or 8.33 percent, with a cross slope no steeper than 1:48, which is 2.08 percent. The Access Board guide to ramps allows two limited exceptions for existing sites: 1:10 with a maximum rise of 6 inches, and 1:8 with a maximum rise of 3 inches. Anything steeper than 1:8 is prohibited.
| Ratio | Grade | Rise over a 10 ft run | Angle |
|---|---|---|---|
| 1:20 | 5 percent | 6 in | 2.86 degrees |
| 1:12 | 8.33 percent | 10 in | 4.76 degrees |
| 1:10 | 10 percent | 12 in | 5.71 degrees |
| 1:8 | 12.5 percent | 15 in | 7.13 degrees |
The surface you walk on is longer than the run. For this ramp the sloped length is sqrt(30^2 + 360^2) = 361.25 in, about 30.1 ft, so ordering lumber by the 30 ft run alone leaves you just short. The calculator prints that distance next to the slope for exactly this reason.
Ramps are the one place where the slope number carries a legal limit, so it is worth checking it before the concrete goes in rather than after.
Worked example: two points on a line
Take the points (2, 3) and (8, 15). The rise is 15 - 3 = 12 and the run is 8 - 2 = 6, so the slope is 12 / 6 = 2.
| Step | Work | Result |
|---|---|---|
| Rise | y2 - y1 = 15 - 3 | 12 |
| Run | x2 - x1 = 8 - 2 | 6 |
| Slope | 12 / 6 | 2 |
| y-intercept | b = y1 - m x1 = 3 - 2 x 2 | -1 |
| Distance | sqrt(6^2 + 12^2) = sqrt(180) | 13.42 |
| Angle | atan(2) in degrees | 63.43 |
The equation follows from the intercept: y = 2x - 1. Check it against either point. At x = 2 the right side is 4 - 1 = 3, and at x = 8 it is 16 - 1 = 15, so the line passes through both.
The perpendicular slope is the negative reciprocal, -1 / 2 = -0.5. Two lines are perpendicular when the product of their slopes is -1, and 2 x (-0.5) = -1 confirms it. A horizontal line is the exception, since its perpendicular is vertical and has no slope to multiply.
The midpoint of the two points is ((2 + 8) / 2, (3 + 15) / 2) = (5, 9), which sits on the line because the line is straight. The point-slope form y - 3 = 2(x - 2) is the same equation before it is tidied up.
The algebra behind all of this is covered in the OpenStax chapter on the slope of a line, and MathWorld's slope entry handles the vertical line case that the formula cannot.
Angle, percent grade and roof pitch
Three trades describe the same steepness with three different numbers, and mixing them up is a common source of expensive mistakes.
Percent grade is rise divided by run, times 100. Roof pitch is the rise per 12 inches of run, written as 4/12 or 6/12. The angle in degrees is the arctangent of the slope, which is the number a protractor or a level app reports.
| Ratio | Percent grade | Degrees | Roof pitch |
|---|---|---|---|
| 1:20 | 5 percent | 2.86 | 0.6/12 |
| 1:12 | 8.33 percent | 4.76 | 1/12 |
| 4:12 | 33.33 percent | 18.43 | 4/12 |
| 6:12 | 50 percent | 26.57 | 6/12 |
| 12:12 | 100 percent | 45 | 12/12 |
An 8.33 percent grade is 4.76 degrees, not 8.33 degrees. The two scales agree only at very small angles, where the tangent of an angle is close to the angle itself. At 45 degrees the grade is 100 percent, which shows how fast the percent scale outruns the degree scale.
Roof pitch also sets the material estimate. The slope factor is sqrt(1 + m^2), which is 1.054 for a 4/12 roof and 1.118 for a 6/12 roof, so a 2,000 sq ft footprint needs about 2,108 sq ft of decking at 4/12 and 2,236 sq ft at 6/12.
Drainage uses the same math in inches. A 2 percent slope moves the surface down 0.24 in per foot of run, which is why patio pavers are usually set a quarter inch low per foot toward the drain.
Where slope math goes wrong
Most wrong slopes come from four habits.
Dividing the wrong way. Run over rise gives the reciprocal. For the ramp, 360 / 30 = 12, and a slope of 12 is a near cliff rather than a gentle ramp. Keep the y values on top.
Mixing units. A rise of 30 inches over a run of 30 feet is not a slope of 1. Convert first: 30 ft is 360 in, so the slope is 0.0833. Feeding 30 and 30 into the formula gives 1, which is twelve times too steep.
Using the sloped surface as the run. Grade is defined on the horizontal distance. A road that climbs 5 ft over 100 ft measured along the pavement has a run of 99.88 ft, so the true grade is 5.01 percent, not 5.00. The difference is small at 5 percent and grows on steep grades, which is why surveyors measure horizontally.
Treating percent as degrees. A 12.5 percent grade is 7.13 degrees. Reading it as 12.5 degrees overstates the angle by more than 70 percent.
| Mistake | What you get | Correct value |
|---|---|---|
| run / rise for the ramp | 12 | 0.0833 |
| 30 in rise over 30 ft run without converting | 1 | 0.0833 |
| 12.5 percent read as degrees | 12.5 degrees | 7.13 degrees |
| surface length used as run at 5 percent | 5.00 percent | 5.01 percent |
A fifth case is not an error but a choice: which direction counts as positive. Going from right to left flips the sign of the slope even though the line has not moved. Pick a direction, state it, and the sign stops being a surprise.
Slope in a spreadsheet or on a chart
Excel, Google Sheets and most statistics packages compute a slope from a column of data with one function: SLOPE(known_ys, known_xs). The y values come first, which is the reverse of how most people describe a chart, and that reversed order is the usual reason a result looks inverted.
INTERCEPT uses the same order and returns the other half of the line. Together they give y = slope x + intercept, the same equation the two-point calculator builds.
| Tool | What it returns | Watch for |
|---|---|---|
| SLOPE(y range, x range) | units of y per unit of x | y range must come first |
| INTERCEPT(y range, x range) | predicted y when x is 0 | same order as SLOPE |
| Chart trendline | the same equation, displayed | R squared is fit, not steepness |
A trendline labeled y = 2.5x + 10 means the fitted value rises 2.5 units for each extra unit of x. The R squared value next to it says how closely the points follow that line, on a scale from 0 to 1. A slope of 2.5 with an R squared of 0.2 describes a steep guess, not a strong trend.
One more caution: a regression slope is an average over all the points, while the two-point slope is exact for the pair you entered. With three or more points that do not line up, the two numbers answer different questions.
Quick reference: slopes worth memorizing
A handful of ratios cover most household and trade questions, and knowing them saves a calculator trip.
| Situation | Slope | Grade | Angle |
|---|---|---|---|
| Accessible ramp, maximum | 1:12 | 8.33 percent | 4.76 degrees |
| Walkway, comfortable | 1:20 | 5 percent | 2.86 degrees |
| Patio drainage | 1:50 | 2 percent | 1.15 degrees |
| Common roof pitch | 6:12 | 50 percent | 26.57 degrees |
| Steep roof pitch | 12:12 | 100 percent | 45 degrees |
The 2 percent patio slope works out to a quarter inch per foot: 0.02 x 12 = 0.24 in. That is the number to give a contractor who asks how much fall you want across a 12 ft patio, which is 2.88 in total.
For anything that has to pass an inspection, confirm the local code rather than relying on a rule of thumb. The ADA figures on this page come from the federal standard, and states and cities sometimes add their own requirements on top.
Frequently asked questions
What is the slope formula?
m = (y2 - y1) / (x2 - x1). Rise over run, with the y values on top and the x values on the bottom.
What is the slope of the points (2, 3) and (8, 15)?
2. The rise is 15 - 3 = 12, the run is 8 - 2 = 6, and 12 / 6 = 2. The line is y = 2x - 1.
What is a 1:12 slope in percent?
8.33 percent, which is also 4.76 degrees. That is the maximum running slope the ADA allows for a ramp.
What is the maximum ADA ramp slope?
1:12, or 8.33 percent, with a cross slope no steeper than 1:48. Existing sites may use 1:10 for a 6 in rise or 1:8 for a 3 in rise.
What is a 6/12 roof pitch in degrees?
26.57 degrees. The slope is 0.5, which is a 50 percent grade.
What does a slope of 0 mean?
The line is horizontal. The rise is zero, so the y value never changes as x moves.
Why is the slope of a vertical line undefined?
The run is zero, and division by zero has no value. A vertical line is written as x = a constant instead.
How do I find the angle from a slope?
Take the arctangent of the slope and convert to degrees. A slope of 0.0833 gives 4.76 degrees.
How do I find the distance between two points?
Distance = sqrt((x2 - x1)^2 + (y2 - y1)^2). For (2, 3) and (8, 15) that is sqrt(180) = 13.42.
What is the perpendicular slope?
The negative reciprocal, -1 / m. For a slope of 2 the perpendicular slope is -0.5, and 2 x (-0.5) = -1.
Is a 10 percent grade the same as 10 degrees?
No. A 10 percent grade is 5.71 degrees, because the angle is the arctangent of 0.1 rather than the percent itself.
How much fall do I need for a patio?
About 2 percent, which is a quarter inch per foot: 0.24 in per foot, or 2.88 in across a 12 ft patio.
Why does Excel SLOPE give a different answer than my two points?
SLOPE fits a line through all the data, while the two-point formula uses exactly two points. With more than two points that do not line up, the results differ by design.
Spotted a wrong number or a broken result?
More Math tools
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.