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

When to Use This Formula

  • Determining the steepness and direction of a hill, ramp, or road grade — critical for ADA compliance (max 1:12 slope for wheelchair ramps), drainage design, and road engineering.
  • Calculating the rate of change between two data points in economics, science, or business — slope represents how fast one variable changes relative to another.
  • Finding the equation of a line given two points — slope is the first step, after which you use point-slope form (y - y₁ = m(x - x₁)) to get the full equation.
  • Designing roof pitch for proper water drainage — a slope of 4/12 means the roof rises 4 inches for every 12 inches of horizontal run.
  • Analyzing trends in plotted data — a positive slope means the trend is increasing, a negative slope means decreasing, and zero slope means flat.

Common Mistakes to Avoid

  • Swapping the x and y differences — slope is rise over run (Δy/Δx), not run over rise (Δx/Δy). Computing the reciprocal gives the inverse slope, which has a completely different meaning.
  • Subtracting coordinates inconsistently — if you compute y₂ - y₁ in the numerator, you must use x₂ - x₁ (same order) in the denominator. Using y₂ - y₁ over x₁ - x₂ flips the sign, turning a positive slope into a negative one.
  • Dividing by zero without recognizing a vertical line — when x₁ = x₂, the denominator is zero and the slope is undefined (not zero, not infinity). A vertical line has no slope in the traditional sense.
  • Confusing zero slope with undefined slope — a horizontal line has slope 0 (perfectly flat), while a vertical line has undefined slope. These are opposites, not the same thing.

Frequently Asked Questions

What is slope?

Slope measures the steepness and direction of a line. It is the ratio of the vertical change (rise) to the horizontal change (run) between two points.

What does a negative slope mean?

A negative slope means the line goes downward from left to right. A positive slope goes upward, zero slope is horizontal, and undefined slope is vertical.

Learn More

Guide

How to Solve Quadratic Equations - Complete Guide

Learn how to solve quadratic equations using factoring, the quadratic formula, and completing the square. Step-by-step methods with worked examples.

Ready to run the numbers?

Open Slope Calculator