Slope Calculator Formula

Understand the math behind the slope calculator. Each variable explained with a worked example.

Formulas Used

Slope

slope = (y2 - y1) / (x2 - x1)

Y Intercept

y_intercept = y1 - ((y2 - y1) / (x2 - x1)) * x1

Distance

distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)

Angle Deg

angle_deg = atan2(y2 - y1, x2 - x1) * 180 / pi

Variables

VariableDescriptionDefault
x1x₁1
y1y₁2
x2x₂4
y2y₂8

How It Works

How to Calculate Slope

Formula

m = (y₂ - y₁) / (x₂ - x₁)

The slope represents the rate of change — how much y changes for each unit increase in x.

Line Equation

Once you have the slope (m) and y-intercept (b), the line equation is: y = mx + b

Where b = y₁ - m × x₁

Worked Example

Find the slope of the line through points (1, 2) and (4, 8).

x1 = 1y1 = 2x2 = 4y2 = 8
  1. 01Slope = (8 - 2) / (4 - 1) = 6 / 3 = 2
  2. 02Y-intercept: b = 2 - 2 × 1 = 0
  3. 03Line equation: y = 2x
  4. 04Distance = √((4-1)² + (8-2)²) = √(9 + 36) = √45 ≈ 6.7082

Ready to run the numbers?

Open Slope Calculator