letx=

Coordinate geometry

Slope formula

The steepness of the line through two points: rise over run.

m=y2−y1x2−x1

Calculator

The live calculator needs JavaScript. The worked example below shows the same steps it would.

See it move

−12−10−8−6−4−224681012−6−4−2246Δx = 4Δy = 8ABM
  • Distance AB = √(16 + 64) ≈ 8.9443
  • Midpoint M = (0, 1)
  • Slope = Δy/Δx = 2

What the symbols mean

m
the slope (gradient): how much y changes for each 1 that x increases
x1
x-coordinate of the first point
y1
y-coordinate of the first point
x2
x-coordinate of the second point
y2
y-coordinate of the second point

When to use it

Use it to find the gradient of a line through two known points, the first step to writing its equation. It also tells you the direction: positive slopes rise to the right, negative slopes fall, zero is horizontal, and a vertical line has no slope at all because the run is 0. Equal slopes mean parallel lines. In real data the slope is a rate: metres per second, pounds per item.

Worked example

Find the slope of the line through (−2, −3) and (2, 5).

  1. Start from the formula.

    m=y2−y1x2−x1
  2. Substitute x1 = −2, y1 = −3, x2 = 2, y2 = 5 and work it out.

    m=5−(−3)2−(−2)
    =84
    =2
  3. m > 0: the line rises from left to right; y goes up 2 for every 1 across.

Answer m = 2

Why it works

The slope of a straight line is the same everywhere along it, so any two points give the same ratio of vertical change to horizontal change. Swapping the two points flips the sign of both differences, which leaves the ratio unchanged.

Common mistakes

  • Putting run over rise: the y difference goes on top.
  • Subtracting in a different order on top and bottom, (y2−y1)/(x1−x2), which flips the sign.
  • Calling a vertical line's slope 0. A horizontal line has slope 0; a vertical line's slope is undefined.