Written by Erum Nazeer Built by Muhammad Ayaz Akhtar Updated

Maths calculator

Slope Calculator

Enter two coordinate points and get slope, angle, distance, y-intercept, and the full line equation with a live graph. The same rise-over-run formula works for coordinate geometry, roof pitch, ramp grade, driveway slope, pipe drainage, and any other situation where you need to measure how much something rises or falls over a horizontal distance.

m = (y2 - y1) ÷ (x2 - x1)

Coordinate geometry

Enter two points

P1 P2 run rise
Formula: slope = rise ÷ run = (y2 - y1) ÷ (x2 - x1)

On This Page

Rise Over Run

m = (y2 − y1) ÷ (x2 − x1)
Slope diagram on a coordinate plane showing two points P₁ and P₂ with rise (Δy) and run (Δx) labeled, illustrating m = rise ÷ run
Coordinate plane showing two points P₁ and P₂ with rise (Δy) and run (Δx) labeled, illustrating slope m = rise ÷ run

Slope tells you how far a line moves up or down for each step to the right. A positive slope climbs from left to right, a negative one falls, zero is flat and a vertical line is undefined because its run is zero. Positive vs negative slope shows how to read the sign at a glance.

Enter two points and the calculator returns the slope, angle, percent grade, y-intercept, line equation and a graph. The order of the points does not matter, as long as you subtract in the same order top and bottom. Read slope from the coordinates, not from how steep a stretched graph looks. The straight-line gap between the same points also appears; the Distance Calculator adds 3D and latitude/longitude modes.

Three Ways to Write the Line

FormLooks likeUse it when
Slope-intercepty = mx + bYou want the slope m and the y-axis crossing b. The calculator gives this.
Point-slopey − y1 = m(x − x1)You know the slope and one point
StandardAx + By = CA textbook gives it; the slope is −A/B and the intercept is C/B

A slope of 3 through (2, 5) gives y − 5 = 3(x − 2), which expands to y = 3x − 1. And 3x + 2y = 10 rearranges to y = −1.5x + 5. A vertical line has no slope-intercept form, so it is written x = constant.

Decimal, Percent, Degrees and Pitch

These are four ways of stating the same steepness. Percent = slope × 100, angle = arctan(slope), and roof pitch is rise per 12 of run, so X:12 = slope × 12.

SlopePercentAngleWhere you see it
0.011%0.57°Low end for drains and driveways
0.0833 (1:12)8.33%4.76°ADA maximum for a wheelchair ramp
0.25 (3:12)25%14.04°Low-slope residential roof
0.333 (4:12)33.3%18.43°Common roof pitch
0.5 (6:12)50%26.57°Steeper roof
0.667 (8:12)66.7%33.69°Steep roof
1.0 (12:12)100%45°Rise equals run

For a roof, enter (0, 0) and (12, rise) and multiply the slope by 12 for the pitch. The arctan step is the same one used to find angles in the Triangle Calculator.

Slope Targets for Ramps, Roofs, Drains and Driveways

Five Lines, Worked

  1. (1, 2) and (7, 6): rise 4, run 6, slope 0.6667.
  2. (−2, 8) and (4, 2): rise −6, run 6, slope −1, falling left to right.
  3. (2, 5) and (6, 13): slope 8 ÷ 4 = 2. Then 5 = 2(2) + b gives b = 1, so y = 2x + 1.
  4. (3, 1) and (3, 9): run 0, so the slope is undefined. The line is vertical, x = 3.
  5. A ramp rising 1.5 ft over 12 ft: 0.125, or 12.5%, well over the ADA's 8.33%.

A rise of 2 over a run of 10 is 0.2, 20%, or about 11.31°. In Excel, =SLOPE(y_range, x_range) fits a line through many points, =(B2-B1)/(A2-A1) handles two, and =INTERCEPT(y_range, x_range) gives b.

How the Calculator Is Verified

Slope and distance are computed from the same dx and dy values but by two separate formulas that don't feed into each other: slope is dy divided by dx, distance is the square root of dx squared plus dy squared, so a distance figure appears next to the slope on every calculation, including ones where the slope itself is undefined. When dx is 0 the line is vertical, and the code returns the literal string "Undefined" for slope along with a 90 degree angle and the equation x = [value], instead of dividing by zero. If both points are identical (dx and dy both 0), the calculator skips computation entirely and shows an explicit message that the two points don't define a line.

Frequently Asked Questions

How do you calculate percent slope and grade?

Multiply decimal slope by 100: slope 0.08 = 8% grade. A road sign reading "8% grade" means the road rises (or falls) 8 meters for every 100 meters of horizontal distance. To convert percent back to decimal, divide by 100.

What does undefined slope mean, and how is it different from zero slope?

A vertical line has undefined slope because both x-values are equal, making the run zero, division by zero is undefined. A horizontal line has zero slope because the rise is zero while run is nonzero: 0 ÷ run = 0. Horizontal = zero slope; vertical = undefined slope.

References