Allday Education

Calculating Slope from Two Points

You do not need a graph to find the slope of a line — two points are enough. If a line passes through (2,3)(2, 3) and (5,9)(5, 9), the slope formula turns those four numbers into the slope in one fraction.

The formula is m=y2y1x2x1\displaystyle m = \frac{y_2 - y_1}{x_2 - x_1}: the difference of the yy-values on top, the difference of the xx-values on the bottom. It is rise over run written with subtraction — the top is the rise between the points, the bottom is the run. One rule keeps it honest: subtract in the same order on top and bottom.

How the formula works

Label one point (x1,y1)(x_1, y_1) and the other (x2,y2)(x_2, y_2). The slope is m=y2y1x2x1\displaystyle m = \frac{y_2 - y_1}{x_2 - x_1}.

The subtraction y2y1y_2 - y_1 measures how far the line rises between the two points, and x2x1x_2 - x_1 measures how far it runs. So the formula is not something new — it is the rise-over-run idea, computed from coordinates instead of counted on a grid.

The graph shows the line through (2,3)(2, 3) and (5,9)(5, 9). The horizontal dashed step is the run and the vertical dashed step is the rise.

-112345678912345678910xy
(2,3)(2, 3)
(5,9)(5, 9)

Keep the order consistent

Whichever point you call second must come first in both subtractions. Computing y2y1y_2 - y_1 on top but x1x2x_1 - x_2 on the bottom flips the sign of the answer — the single most common slope mistake.

It does not matter which point you label first. Using (2,3)(2, 3) and (5,9)(5, 9): one order gives 9352=63=2\dfrac{9 - 3}{5 - 2} = \dfrac{6}{3} = 2, and the other gives 3925=63=2\dfrac{3 - 9}{2 - 5} = \dfrac{-6}{-3} = 2. Both signs flip together, so the slope survives.

Watch the negatives

Negative coordinates put double signs into the fraction, and subtracting a negative becomes addition: 2(3)=52 - (-3) = 5. Write the substitution out with parentheses before simplifying anything.

A slope of 00 is also worth recognizing on sight: if both points have the same yy-value, the top of the fraction is 00 and the line is horizontal.

Worked examples

Example 1: positive slope

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

Write the slope formulam=y2y1x2x1\displaystyle m = \frac{y_2 - y_1}{x_2 - x_1}
Substitute the coordinatesm=9352m = \dfrac{9 - 3}{5 - 2}
Simplifym=63=2m = \dfrac{6}{3} = 2

Answer: m=2m = 2

Example 2: negative slope

Find the slope of the line through (1,4)(1, 4) and (3,2)(3, -2).

Write the slope formulam=y2y1x2x1\displaystyle m = \frac{y_2 - y_1}{x_2 - x_1}
Substitute, keeping parentheses around negativesm=2431m = \dfrac{-2 - 4}{3 - 1}
Simplifym=62=3m = \dfrac{-6}{2} = -3

Answer: m=3m = -3

Example 3: a horizontal line

Find the slope of the line through (2,5)(-2, 5) and (4,5)(4, 5).

Substitute into the formulam=554(2)m = \dfrac{5 - 5}{4 - (-2)}
Simplify the top and bottomm=06m = \dfrac{0}{6}
Zero divided by anything is zero — the line is horizontalm=0m = 0

Answer: m=0m = 0

Try one yourself

Common questions

Does it matter which point I call (x1,y1)(x_1, y_1)?

No — as long as you keep the order the same on top and bottom. Swap both and the two sign changes cancel. Mix the orders and your slope comes out with the wrong sign.

What if the bottom of the fraction is 0?

Then the two points have the same xx-value and the line through them is vertical. Division by zero is not allowed, so a vertical line has an undefined slope — that is different from a slope of 00.

What if the answer is a fraction?

Leave it as a reduced fraction. A slope of 23\dfrac{2}{3} is a perfectly good answer: it means the line rises 22 for every 33 it runs.

How is this the same as rise over run?

The top, y2y1y_2 - y_1, is exactly the rise between the two points, and the bottom, x2x1x_2 - x_1, is exactly the run. The formula just does the counting with subtraction.

Want the video version?

Allday Everyday Math has video lessons, practice, and an AI tutor for every topic, Pre-Algebra through Algebra 2.

Try it for $1