Middle school

How to find the slope of a line from two points

· 3 min read

Quick answerSubtract the y-values, subtract the x-values in the same order, and divide: slope = (y₂ − y₁) / (x₂ − x₁). For the points (1, 2) and (4, 8), the slope is (8 − 2) / (4 − 1) = 6 / 3 = 2.

Slope tells you how steep a line is: how far it goes up (or down) for every step to the right. People call it “rise over run”.

The slope formula

For two points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2):

m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}

The top is the change in yy (the rise). The bottom is the change in xx (the run).

Example 1: a positive slope

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

m=8−24−1=63=2m = \frac{8 - 2}{4 - 1} = \frac{6}{3} = 2

The line goes up 2 for every 1 it moves to the right.

Example 2: negative numbers

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

m=−5−53−(−2)=−105=−2m = \frac{-5 - 5}{3 - (-2)} = \frac{-10}{5} = -2

Subtracting a negative is the step where most slips happen: 3−(−2)=3+2=53 - (-2) = 3 + 2 = 5. The slope is negative, so the line goes down from left to right.

Does it matter which point is first?

No, as long as you use the same order on the top and the bottom. Swapping the points in Example 1:

m=2−81−4=−6−3=2m = \frac{2 - 8}{1 - 4} = \frac{-6}{-3} = 2

Same answer. What you cannot do is start with one point on top and the other point on the bottom.

Horizontal and vertical lines

Horizontal line. Through (1,4)(1, 4) and (6,4)(6, 4):

m=4−46−1=05=0m = \frac{4 - 4}{6 - 1} = \frac{0}{5} = 0

A flat line has slope 0.

Vertical line. Through (3,1)(3, 1) and (3,7)(3, 7):

m=7−13−3=60m = \frac{7 - 1}{3 - 3} = \frac{6}{0}

You cannot divide by zero, so the slope of a vertical line is undefined.

What the number tells you

Slope The line
Positive Goes up from left to right
Negative Goes down from left to right
Zero Is horizontal
Undefined Is vertical
Bigger number (ignoring the sign) Is steeper

Common mistakes

  • Putting x on top. Slope is change in yy over change in xx, not the other way round.
  • Mixing the order, for example y2−y1y_2 - y_1 on top with x1−x2x_1 - x_2 underneath. This flips the sign.
  • Dropping a negative sign when subtracting a negative coordinate.
  • Calling a vertical line’s slope 0. Zero is for horizontal lines; vertical is undefined.

Practice problems

Check your answers with the slope calculator, which shows the same steps for any two points.

1. (0,1)(0, 1) and (2,7)(2, 7)

Answer

7−12−0=62=3\dfrac{7 - 1}{2 - 0} = \dfrac{6}{2} = 3

2. (−1,−3)(-1, -3) and (2,3)(2, 3)

Answer

3−(−3)2−(−1)=63=2\dfrac{3 - (-3)}{2 - (-1)} = \dfrac{6}{3} = 2

3. (4,9)(4, 9) and (8,7)(8, 7)

Answer

7−98−4=−24=−12\dfrac{7 - 9}{8 - 4} = \dfrac{-2}{4} = -\dfrac{1}{2}

4. (−5,2)(-5, 2) and (−5,10)(-5, 10)

Answer

The x-values are the same, so the run is 0. The line is vertical and the slope is undefined.

5. (2,−6)(2, -6) and (7,−6)(7, -6)

Answer

−6−(−6)7−2=05=0\dfrac{-6 - (-6)}{7 - 2} = \dfrac{0}{5} = 0. The line is horizontal.