Lelifi·tools

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.

Enter two points to get the slope, angle, distance, line equation, grade and roof pitch, plus a check against the ADA ramp limit.

By the Lelifi editors ·

Key takeaways

246810261014run = 6rise = 12(2, 3)(8, 15)Rise 12 over run 6 gives a slope of 2The dashed legs show the same ratio the formula uses: (15 - 3) / (8 - 2)
The rise of 12 and run of 6 between (2, 3) and (8, 15) give a slope of 2.
From two points to an equationpoints (2, 3) and (8, 15)rise = 15 - 3 = 12run = 8 - 2 = 6m = 12 / 6 = 2b = 3 - 2 x 2 = -1= y = 2x - 1Angle atan(2) = 63.43 degrees, distance sqrt(180) = 13.42.
Two points are enough to build the slope, the intercept and the equation of the line.
On this page
  1. Slope is rise over run
  2. Worked example: a wheelchair ramp
  3. Worked example: two points on a line
  4. Angle, percent grade and roof pitch
  5. Where slope math goes wrong
  6. Slope in a spreadsheet or on a chart
  7. Quick reference: slopes worth memorizing

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.

SlopeExample pointsWhat the line does
Positive(2, 3) and (8, 15), m = 2rises from left to right
Negative(0, 0) and (3, -4), m = -1.33falls from left to right
Zero(1, 4) and (9, 4), m = 0flat, 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.

RatioGradeRise over a 10 ft runAngle
1:205 percent6 in2.86 degrees
1:128.33 percent10 in4.76 degrees
1:1010 percent12 in5.71 degrees
1:812.5 percent15 in7.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.

StepWorkResult
Risey2 - y1 = 15 - 312
Runx2 - x1 = 8 - 26
Slope12 / 62
y-interceptb = y1 - m x1 = 3 - 2 x 2-1
Distancesqrt(6^2 + 12^2) = sqrt(180)13.42
Angleatan(2) in degrees63.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.

RatioPercent gradeDegreesRoof pitch
1:205 percent2.860.6/12
1:128.33 percent4.761/12
4:1233.33 percent18.434/12
6:1250 percent26.576/12
12:12100 percent4512/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.

MistakeWhat you getCorrect value
run / rise for the ramp120.0833
30 in rise over 30 ft run without converting10.0833
12.5 percent read as degrees12.5 degrees7.13 degrees
surface length used as run at 5 percent5.00 percent5.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.

ToolWhat it returnsWatch for
SLOPE(y range, x range)units of y per unit of xy range must come first
INTERCEPT(y range, x range)predicted y when x is 0same order as SLOPE
Chart trendlinethe same equation, displayedR 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.

SituationSlopeGradeAngle
Accessible ramp, maximum1:128.33 percent4.76 degrees
Walkway, comfortable1:205 percent2.86 degrees
Patio drainage1:502 percent1.15 degrees
Common roof pitch6:1250 percent26.57 degrees
Steep roof pitch12:12100 percent45 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

See all Math tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.