Slope Calculator

Calculate slope, y-intercept, line equation, distance, and midpoint from two coordinate points.

Line Equation

y = 2x

Slope (m)2.000000
Y-intercept (b)0.000000
Distance6.708204
Angle63.43°
Midpoint(1.5, 3)
Rise / Run6 / 3

How to Use the Slope Calculator

This slope calculator (also called a slope of a line calculator or rise over run calculator) takes any two points on a coordinate plane and returns the slope, the y-intercept, the full line equation in slope-intercept form, the distance between the points, the angle of the line in degrees, and the midpoint. Everything recalculates as you type, so you can plug in homework problems, survey data, or trend line points and read the answer instantly.

  1. Enter Point 1 as (x1, y1). This is the starting point on the line. The default is (0, 0), which is the origin.
  2. Enter Point 2 as (x2, y2). This is any other point on the same line. The default is (3, 6), which gives a slope of 2.
  3. Read the slope and equation in the result panel. The slope (m) is the rise over run ratio. The y-intercept (b) is where the line crosses the y-axis. Together they form the line equation y = mx + b.
  4. Check the extras. Distance is the straight-line gap between your two points from the distance formula. Angle is the inclination of the line measured counter-clockwise from the positive x-axis. Midpoint is the point exactly halfway between Point 1 and Point 2.

If both x-values are identical, the line is vertical and slope is undefined (the calculator flags this). A negative slope means the line goes down from left to right. A slope of 0 means a horizontal line. A slope of 1 is a 45 degree diagonal. The bigger the absolute value of the slope, the steeper the line.

Slope Formulas and Worked Examples

The slope of a line is a single number that describes how steep the line is and whether it rises or falls. Every formula on this page comes from the same idea: divide the change in y by the change in x.

1. The Slope Formula (Rise over Run)

m = (y2 − y1) / (x2 − x1)

Example with points (1, 3) and (4, 11):
  rise = 11 − 3 = 8
  run  = 4 − 1 = 3
  m    = 8 / 3 ≈ 2.6667

So the line rises 8 units for every 3 units it moves right.

Order matters only in that you must subtract the coordinates in the same order on top and bottom. (y2 − y1) / (x2 − x1) and (y1 − y2) / (x1 − x2) give the same answer because both the numerator and denominator flip sign.

2. Three Forms of a Line Equation

Slope-intercept form:  y = mx + b
Point-slope form:      y − y1 = m(x − x1)
Standard form:         Ax + By = C

Example using slope m = 8/3 through point (1, 3):
  Point-slope:    y − 3 = (8/3)(x − 1)
  Slope-intercept: y = (8/3)x + 1/3
  Standard:       8x − 3y = −1

Slope-intercept form is the quickest read: m is the slope, b is the y-intercept. Point-slope form is easiest when you have a slope and one point but no y-intercept. Standard form is preferred for systems of equations and when A, B, and C are integers.

3. Parallel and Perpendicular Lines

Parallel lines:       m1 = m2         (same slope)
Perpendicular lines:  m1 × m2 = −1    (negative reciprocals)
                      m2 = −1 / m1

Example: a line with slope 2
  Parallel line slope:      2
  Perpendicular line slope: −1/2 = −0.5

A line perpendicular to y = 3x + 4 has slope −1/3. A line perpendicular to y = −0.25x + 7 has slope 4. The only exception is horizontal and vertical lines: a horizontal line (slope 0) is perpendicular to a vertical line (slope undefined), even though the product rule does not apply because one slope is undefined.

4. Special Cases: Horizontal and Vertical Lines

Horizontal line:  m = 0           y = c         (example: y = 5)
Vertical line:    m is undefined   x = c         (example: x = 2)

For a horizontal line the rise is 0, so 0 / run = 0.
For a vertical line the run is 0, so rise / 0 is undefined.

A horizontal line has every y-value equal to the same constant, so there is no rise anywhere along it. A vertical line has every x-value equal to the same constant, so you cannot divide by the run. The calculator above detects vertical lines automatically and labels the slope as undefined.

5. Distance, Midpoint, and Angle

Distance:  d = √[(x2 − x1)² + (y2 − y1)²]
Midpoint:  M = ((x1 + x2)/2, (y1 + y2)/2)
Angle:     θ = arctan(m)   (in degrees)

For points (0, 0) and (3, 6):
  d = √(3² + 6²) = √45 ≈ 6.7082
  M = (1.5, 3)
  θ = arctan(2) ≈ 63.43°

6. Slope as Rise/Run, Rate of Change, Percent, and Degrees

The same slope can be written in four ways depending on the context. Engineers and builders often use percent grade or a 1 in X ratio. Scientists and economists usually state slope as a rate of change. Geometry problems use degrees. All of these are the same underlying number.

Decimal slope:   m = rise / run
Percent grade:   % = (rise / run) × 100
Degrees:         θ = arctan(rise / run)
Ratio:           1 in X   means rise of 1 per run of X, so m = 1/X

A 5% grade is a slope of 0.05, which is about 2.86 degrees. A wheelchair ramp at 1 in 12 is a slope of 0.0833, which is 8.33% or about 4.76 degrees. The quick-reference table below covers the values you are most likely to see.

Slope (m)AnglePercent GradeRatioReal-World Example
00%flathorizontal floor, calm water
0.052.86°5%1 in 20typical roof pitch, gentle road grade
0.08334.76°8.33%1 in 12ADA max wheelchair ramp
0.526.57°50%1 in 2steep hiking trail
145°100%1 in 1diagonal, black diamond ski run
263.43°200%2 in 1very steep staircase
−1−45°−100%−1 in 1downward diagonal
undefined90°infiniteverticalcliff face, wall

Slope in the Real World: Grades, Gradients, Regression, and Mistakes

Slope is one of the most useful numbers in applied math. The same m = rise / run that solves a homework problem also sets the legal limit on a wheelchair ramp, the drainage on a roof, the safe limit for a railway, and the coefficient in a linear regression. This section covers how slope shows up outside the textbook and the mistakes that cost people points or build permits.

Real-World Uses of Slope

Almost every field that deals with physical space or rates of change uses slope under a different name: grade, pitch, incline, gradient, or beta coefficient. The numbers below are the standards you will see quoted in construction, transportation, and accessibility codes.

ApplicationTypical SlopeWhat It Means
US Interstate highway max grade6%0.06 rise per 1 run, 3.43°
Typical residential road4% to 8%0.04 to 0.08
Railway max grade (mainline)2.2%0.022, limits train tonnage
Roof pitch (low slope)4/12 = 33.3%4 rise per 12 run, 18.43°
Roof pitch (steep)12/12 = 100%45° roof, classic A-frame
ADA wheelchair ramp (max)1:12 = 8.33%1 rise per 12 run, 4.76°
Driveway (max recommended)15%steeper tends to scrape bumpers
Treadmill incline (max)12% to 15%equivalent to a steep trail
Black diamond ski run40% and up21.8° and steeper

The ADA 1:12 ramp rule is a common real-world slope problem: for every 1 inch of vertical rise, you need 12 inches of horizontal run. A standard porch 30 inches above grade needs 30 × 12 = 360 inches (30 feet) of ramp. Steeper than 1:12 and the ramp is out of code for public accommodations.

Slope vs Gradient vs Percent vs Degrees

These four words describe the same line but use different units. Most slope confusion comes from mixing them up. Here is how they convert.

decimal slope (m) = rise / run
percent grade (%) = m × 100
angle (θ)         = arctan(m)
ratio (1 in X)    = 1 / m  (when m is positive)

Converting between the four for a 10% grade:
  percent:  10%
  decimal:  0.10
  degrees:  arctan(0.10) ≈ 5.71°
  ratio:    1 in 10

Percent grade and degrees are not the same thing. A common error is treating 45% grade as a 45° angle. A 45% grade is only arctan(0.45) ≈ 24.2°. You need a 100% grade (1 rise per 1 run) to hit a true 45° angle. In civil engineering and trail signage you will almost always see percent grade. Aviation and surveying typically use degrees.

Slope in Regression and Data Science

When you fit a straight line to a cloud of data points, the slope of that line is called the regression coefficient, written β1 in the equation y = β0 + β1x. It tells you how much y is predicted to change for a one-unit increase in x. If you run a regression of home price (y) on square footage (x) and get β1 = 180, that says each extra square foot is associated with about $180 more in price, holding everything else equal.

Linear regression line:  y = β0 + β1 × x

β1 (slope)     = Σ[(xi − x̄)(yi − ȳ)] / Σ[(xi − x̄)²]
β0 (intercept) = ȳ − β1 × x̄

Same rise/run idea, just fitted to many points instead of two.

In Excel or Google Sheets, SLOPE(y_range, x_range) returns β1 and INTERCEPT(y_range, x_range) returns β0. The regression slope is also the answer you get from the TREND or LINEST functions. In Python, numpy.polyfit(x, y, 1) returns the same two numbers in a list.

Common Slope Mistakes

Three errors show up over and over in homework, construction plans, and even published reports. Check for them before trusting a slope number you calculated by hand.

  1. Swapping x and y. Slope is (y2 − y1) / (x2 − x1), not (x2 − x1) / (y2 − y1). The rise (change in y) goes on top. If you flip them, you get the reciprocal, which is the slope of the perpendicular line, not the original.
  2. Losing the sign on a negative slope. For points (2, 8) and (5, 2), the slope is (2 − 8) / (5 − 2) = −6 / 3 = −2, not 2. The negative sign tells you the line goes down from left to right. Dropping it reverses the direction of the line.
  3. Inconsistent subtraction order. If you use y2 − y1 on top, you must use x2 − x1 on the bottom. Mixing (y2 − y1) / (x1 − x2) flips the sign of the slope.

One more worth flagging: degrees versus percent grade, covered above. A 30 degree road is a 57.7% grade, not 30%. Pay attention to which unit the problem or blueprint is using before you plug numbers in.

Frequently Asked Questions

Divide the change in y (rise) by the change in x (run). Formula: m = (y2 − y1) / (x2 − x1). For points (1, 3) and (4, 9): rise = 9 − 3 = 6, run = 4 − 1 = 3, slope = 6/3 = 2. A slope of 2 means for every 1 unit you move right, the line goes up 2 units. Always keep the subtraction order consistent: whichever point you label as Point 2, use its coordinates in both the numerator and the denominator.

Related Calculators