Skip to content
UnitFormula

The slope of a line measures its steepness as rise over run: m = (y2 − y1) ÷ (x2 − x1), the change in y divided by the change in x between two points. For (1, 2) and (4, 8), that's (8 − 2) ÷ (4 − 1) = 6 ÷ 3 = 2. A positive slope rises, a negative slope falls, zero is horizontal, and a vertical line has undefined slope.

Slope Calculator — slope of a line from two points

Line through (1, 2) and (4, 8).

Slope (m)2
run = 3rise = 6m = 2
  • run = 3
  • rise = 6
  • m = 2

Quick examples

How it's calculated

  1. m = (y₂ − y₁) ÷ (x₂ − x₁)m=y2y1x2x1m = \frac{y_2 - y_1}{x_2 - x_1}
    x1
    = 1
    y1
    = 2
    x2
    = 4
    y2
    = 8
    2
Slope (m)2

How it works

The slope of a line tells you how steep it is and which way it tilts. It's the rise over the run — how much the line goes up (change in y) for each step across (change in x) — between any two points on it:

m = (y₂ − y₁) ÷ (x₂ − x₁)

The sign carries the direction: a positive slope rises left to right, a negative slope falls, and a zero slope is a flat, horizontal line. A vertical line is the one exception — its run is zero, so the slope is undefined (you'd be dividing by zero).

Worked example

Find the slope of the line through (1, 2) and (4, 8). The rise is 8 − 2 = 6, and the run is 4 − 1 = 3:

m = 6 ÷ 3 = 2

So the line climbs 2 units up for every 1 across. A line through (0, 0) and (2, 6) has slope 3, a steeper climb; a line from (1, 5) to (3, 5) has slope 0 (it's horizontal); and one that drops, like (0, 4) to (2, 0), has a negative slope of −2.

Frequently asked questions

How do I find the slope from two points?

Subtract the y-coordinates to get the rise, subtract the x-coordinates (in the same order) to get the run, and divide. For (2, 3) and (5, 12): (12 − 3) ÷ (5 − 2) = 9 ÷ 3 = 3. Keep the points in the same order top and bottom — swapping both is fine, mixing them isn't.

What does the sign of the slope mean?

A **positive** slope means the line rises as you move right; a **negative** slope means it falls. A **zero** slope is a horizontal line (no rise). The steeper the line, the larger the slope's magnitude — a slope of 5 is steeper than a slope of 2.

Why is a vertical line's slope undefined?

Because the run (change in x) is zero, and dividing the rise by zero has no value. A vertical line is infinitely steep, so no finite number describes its slope. This calculator returns no value when the two points share the same x-coordinate.

Does the order of the points matter?

No, as long as you're consistent. If you subtract point A's coordinates from point B's on top, do the same on the bottom. Reversing both the rise and the run flips two minus signs, leaving the slope unchanged: (1,2)→(4,8) and (4,8)→(1,2) both give slope 2.

What's the connection between slope and the equation of a line?

In slope-intercept form, y = mx + b, the m is exactly this slope and b is where the line crosses the y-axis. So once you have the slope and one point, you can write the whole line's equation. Parallel lines share a slope; perpendicular lines have slopes that multiply to −1.

What does a slope of 1 or a percentage grade mean?

A slope of 1 rises one unit for each unit across — a 45° line. Roads and roofs often express slope as a **percentage grade**, which is the slope times 100: a slope of 0.08 is an 8% grade. So slope, grade and the tangent of the angle are all the same idea in different clothes.

How we know this is right

Last reviewed
Aug 5, 2026
Precision
Rounded to 4 decimal places.
Read our methodology

Sources