Slope Calculator

Slope is rise over run: how far the line goes up for each step to the right. Drag two points to see the slope, the y-intercept and the equation of the line.

Answer

Slope m

3

Liney = 3x − 1
y-intercept−1
Angle71.57°
−10−10−5−5551010run 2rise 6P (1, 2)Q (3, 8)

Drag P or Q (they snap to halves), or focus one and use the arrow keys.

Why this answer

  1. Rise. y₂ − y₁ = 8 − 2 = 6.
  2. Run. x₂ − x₁ = 3 − 1 = 2.
  3. Rise ÷ run. m = 6 ÷ 2 = 3. Positive: the line goes up to the right.
  4. Find b. Put P into y = mx + b: 2 = 3 × 1 + b, so b = 2 − 3 = −1.
  5. The line. y = 3x − 1. Check with Q: 3 × 3 + −1 = 8 ✓

Put it to use

Slope in real life

  • Ramps: ADA ramps max out at 1:12, a slope of 1/12 ≈ 0.083.
  • Roofs: a “6/12 pitch” rises 6 in for every 12 in across, slope 0.5.
  • Grades: a 6% road grade is a slope of 0.06.
  • Estimate a value between two points with Linear Interpolation.

How it works

The slope calculator finds how steep a line is from two points, P(x₁, y₁) and Q(x₂, y₂). Slope is rise over run: how far the line goes up or down for each step to the right.

It subtracts the y-values to get the rise and the x-values to get the run, then divides. It also finds the y-intercept b by putting P into y = mx + b, and writes the full equation of the line. A check with Q confirms the equation.

If both points have the same x-value, the run is zero. You can't divide by zero, so the page reports the slope as undefined and gives the vertical line's equation, x = constant.

m = (y₂ − y₁) ÷ (x₂ − x₁) = rise ÷ runb = y₁ − m × x₁Line: y = mx + bVertical line (x₁ = x₂): slope undefined, equation x = x₁

Worked example: Slope through P(−1, 4) and Q(3, −2)

  1. Rise: y₂ − y₁ = −2 − 4 = −6.
  2. Run: x₂ − x₁ = 3 − (−1) = 4.
  3. Slope: m = −6 ÷ 4 = −1.5. It is negative, so the line goes down to the right.
  4. Intercept: 4 = −1.5 × (−1) + b, so b = 4 − 1.5 = 2.5.
  5. Line: y = −1.5x + 2.5. Check with Q: −1.5 × 3 + 2.5 = −4.5 + 2.5 = −2 ✓

Common mistakes

  • Putting run over rise. Slope is the change in y divided by the change in x, never the other way around.
  • Subtracting in a different order on top and bottom. If you use y₂ − y₁ on top, you must use x₂ − x₁ below, or the sign flips.
  • Calling a vertical line's slope zero. A horizontal line has slope 0. A vertical line has an undefined slope.
  • Dropping a negative when a coordinate is negative, such as writing 3 − (−1) as 2 instead of 4.

Frequently asked questions

What is the formula for slope?

m = (y₂ − y₁) ÷ (x₂ − x₁). It is the change in y divided by the change in x between two points.

What does a negative slope mean?

The line goes down as you move to the right. A slope of −1.5 means y drops 1.5 for every 1 step right.

Why is the slope of a vertical line undefined?

Both points share the same x-value, so the run is 0. Dividing by 0 has no answer, so the slope is undefined.

How do I turn slope into a percent grade?

Multiply the slope by 100. A slope of 0.06 is a 6% grade, and a roof pitch of 6/12 is a slope of 0.5, or 50%.