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)) * x1Distance
distance = sqrt((x2 - x1)^2 + (y2 - y1)^2)Angle Deg
angle_deg = atan2(y2 - y1, x2 - x1) * 180 / piVariables
| Variable | Description | Default |
|---|---|---|
x1 | x₁ | 1 |
y1 | y₁ | 2 |
x2 | x₂ | 4 |
y2 | y₂ | 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
- 01Slope = (8 - 2) / (4 - 1) = 6 / 3 = 2
- 02Y-intercept: b = 2 - 2 × 1 = 0
- 03Line equation: y = 2x
- 04Distance = √((4-1)² + (8-2)²) = √(9 + 36) = √45 ≈ 6.7082
Ready to run the numbers?
Open Slope Calculator