Lines & Graphs

Slope Formula: How to Find the Slope of a Line

The slope formula is m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}: the change in yy divided by the change in xx between two points on a line.

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

Try it with your numbers

Show every step

Subtract the yy-values on top and the xx-values on the bottom, in the same order, then simplify. That one habit of keeping the order consistent saves more points than any other, and the sections below show why it works, how it behaves with negatives and fractions, and when it fails.

What is the slope formula and why does it work?

Slope is steepness turned into a single number: how far a line moves up or down for every one unit it moves to the right. Pick two points on the line and draw a right triangle between them. The horizontal leg has length x2−x1x_2 - x_1 (the run), the vertical leg has length y2−y1y_2 - y_1 (the rise), and the slope is the ratio of the two legs.

Here is the one idea that explains everything else. On a straight line, every such triangle is similar to every other, no matter which two points you pick or how far apart they are. Similar triangles have equal leg ratios, so the answer never changes. That is why you can use any two points, and why the formula fails to mean anything on a curve, where the ratio depends on which points you choose.

m=y2−y1x2−x1=riserunm = \frac{y_2 - y_1}{x_2 - x_1} = \frac{\text{rise}}{\text{run}}

The small numbers are labels, not exponents. x1x_1 means “the xx-coordinate of the first point.” If reading coordinates still feels shaky, review plotting points on the coordinate plane first, because every slope problem is secretly a picture.

Quick check

A line passes through (2,1)(2, 1) and (6,4)(6, 4). What is its slope?

How to use the slope formula, step by step

The method is the same every time, and the labeling step is the one people skip.

  1. Label the points: call one (x1,y1)(x_1, y_1) and the other (x2,y2)(x_2, y_2).
  2. Subtract the yy-values: y2−y1y_2 - y_1.
  3. Subtract the xx-values in the same order: x2−x1x_2 - x_1.
  4. Divide, and reduce the fraction.

Take the points (2,3)(2, 3) and (5,11)(5, 11). Label (x1,y1)=(2,3)(x_1, y_1) = (2, 3) and (x2,y2)=(5,11)(x_2, y_2) = (5, 11).

m=11−35−2=83m = \frac{11 - 3}{5 - 2} = \frac{8}{3}

The slope is 83\frac{8}{3}. Leave it as an improper fraction: it says “up 8 for every 3 across,” which is more useful than 2.672.67. Once you have mm, you are one step from the full equation, which is covered in the equation of a line through two points.

Does the order of the points matter in the slope formula?

Forward, backward and mixed subtraction order for points (1, 2) and (4, 8) compared
Reversing both the top and bottom gives 2 again, but mixing the orders turns the slope into -2.

The order of the points does not matter, but mixing the order does. Swap the two points and both the numerator and the denominator change sign, and the two negatives cancel. With (1,2)(1, 2) and (4,8)(4, 8), going forward gives 8−24−1=63=2\frac{8 - 2}{4 - 1} = \frac{6}{3} = 2, and going backward gives 2−81−4=−6−3=2\frac{2 - 8}{1 - 4} = \frac{-6}{-3} = 2.

The trap is subtracting in one order on top and the other order on the bottom. Writing 8−21−4\frac{8 - 2}{1 - 4} gives 6−3=−2\frac{6}{-3} = -2, a clean-looking answer with the wrong sign. Nothing flags the error, because the arithmetic is fine. Only the setup is broken.

Label before you subtract

Write (x1,y1)=(1,2)(x_1, y_1) = (1, 2) and (x2,y2)=(4,8)(x_2, y_2) = (4, 8) above your work. With the labels in view, you copy subscripts instead of choosing an order twice.

Quick check

Points A(5,2)A(5, 2) and B(1,−6)B(1, -6) lie on a line. Start with BB as the first point and find the slope.

Slope formula with negatives and fractions

Negative coordinates cause one specific error: forgetting that subtracting a negative adds. Find the slope through (−3,4)(-3, 4) and (5,−2)(5, -2).

m=−2−45−(−3)=−68=−34m = \frac{-2 - 4}{5 - (-3)} = \frac{-6}{8} = -\frac{3}{4}

The denominator is 5+3=85 + 3 = 8, not 22. Put parentheses around any negative coordinate before subtracting, and the sign error mostly disappears. As a sanity check, (−3,4)(-3, 4) sits in the second quadrant and (5,−2)(5, -2) in the fourth (see the four quadrants). A line that runs from upper left to lower right must fall, so a negative slope is exactly right.

Fractions look worse than they are if you split the work. Find the slope through (12,13)\left(\frac{1}{2}, \frac{1}{3}\right) and (52,−23)\left(\frac{5}{2}, -\frac{2}{3}\right). Compute the top and bottom separately first:

Δy=−23−13=−1Δx=52−12=2\Delta y = -\frac{2}{3} - \frac{1}{3} = -1 \qquad \Delta x = \frac{5}{2} - \frac{1}{2} = 2

Then divide: m=−12=−12m = \frac{-1}{2} = -\frac{1}{2}. Handling each difference on its own avoids a tower of fractions inside fractions. If a difference is itself a fraction, divide by it by multiplying by its reciprocal.

Zero slope vs undefined slope: when the formula breaks

The formula needs x2≠x1x_2 \neq x_1, because the denominator cannot be zero. That leaves two special cases, and they are easy to confuse.

For the points (−5,2)(-5, 2) and (3,2)(3, 2), the yy-values match, so the rise is 00:

m=2−23−(−5)=08=0m = \frac{2 - 2}{3 - (-5)} = \frac{0}{8} = 0

For (3,−4)(3, -4) and (3,7)(3, 7), the xx-values match, so the run is 00:

m=7−(−4)3−3=110m = \frac{7 - (-4)}{3 - 3} = \frac{11}{0}

That is undefined. Zero on top is fine and gives a slope of 00 (a flat line). Zero on the bottom is never fine (a vertical line). Avoid the phrase “no slope,” which sounds like zero but means undefined. Horizontal and vertical lines have equations y=cy = c and x=cx = c, and the second form is why vertical lines cannot be written as y=mx+by = mx + b at all.

How to find slope from an equation in standard form

When the line is given as an equation, you do not need two points. If it is already in slope-intercept form, y=mx+by = mx + b, the slope is the number multiplying xx. For an equation in standard form, Ax+By=CAx + By = C, solve for yy:

By=−Ax+C⇒y=−ABx+CBBy = -Ax + C \quad \Rightarrow \quad y = -\frac{A}{B}x + \frac{C}{B}

So the slope is m=−ABm = -\frac{A}{B}. For 3x+4y=123x + 4y = 12, that gives m=−34m = -\frac{3}{4}. You can confirm it with the slope formula by using the intercepts, (4,0)(4, 0) and (0,3)(0, 3) (the method is in finding x and y intercepts):

m=3−00−4=−34m = \frac{3 - 0}{0 - 4} = -\frac{3}{4}

Both routes agree. The most common slip is forgetting the minus sign in −AB-\frac{A}{B}, which flips the line’s direction.

Why the minus sign appears

Move one unit right and AxAx grows by AA, so ByBy must shrink by AA to keep the total at CC. That makes yy change by −AB-\frac{A}{B} per unit.

Slope formula vs distance formula and midpoint formula

Three formulas all start with the same two subtractions, which is why they get mixed up. Each one answers a different question about a pair of points.

Formula Question it answers Result
Slope How steep is the line? y2−y1x2−x1\frac{y_2 - y_1}{x_2 - x_1} (a ratio)
Distance How far apart are the points? (x2−x1)2+(y2−y1)2\sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} (a length)
Midpoint What point is exactly halfway? (x1+x22,y1+y22)\left(\frac{x_1 + x_2}{2}, \frac{y_1 + y_2}{2}\right) (a point)

For (2,3)(2, 3) and (5,11)(5, 11), the legs of the triangle are 33 and 88. The slope divides them, 83\frac{8}{3}. The distance combines them with Pythagoras, 32+82=73≈8.54\sqrt{3^2 + 8^2} = \sqrt{73} \approx 8.54. The midpoint averages the coordinates, (72,7)\left(\frac{7}{2}, 7\right). Same triangle, three different questions.

A quick tell: slope has a division bar and no square root, distance has the root, and midpoint is the only one that returns an ordered pair.

How to check a slope answer in ten seconds

Most wrong answers can be caught without redoing the work. Run through these checks:

  • Direction: a line rising left to right has a positive slope, and one falling has a negative slope.
  • Size: a slope above 11 in size means the rise beats the run, so the line is steeper than 45∘45^\circ.
  • Reverse: redo it with the points swapped. You must get the identical fraction.
  • Third point: use your slope to step from one point to a new point, then test that point with the formula.

The slope also checks other lines. Parallel lines have equal slopes, and perpendicular lines have slopes that multiply to −1-1, as laid out in slopes of parallel and perpendicular lines. If a homework problem says two lines are perpendicular and your slopes multiply to +1+1, one sign is wrong.

Try this: Find the slope through (0,−1)(0, -1) and (6,2)(6, 2). Use it to predict the point 4 units to the right of (6,2)(6, 2), then confirm that (0,−1)(0, -1) and your new point give the same slope.

Where the slope formula shows up in real life

Slope is a rate, so it carries units. If you earn $30 after 2 hours and $75 after 5 hours, the slope between (2,30)(2, 30) and (5,75)(5, 75) is 75−305−2=453=15\frac{75 - 30}{5 - 2} = \frac{45}{3} = 15 dollars per hour. That reading is the heart of average rate of change, and the same ratio gives speed on a distance-time graph or cost per item on a price chart.

Builders use slope as grade and pitch. A road with a 6% grade rises 6 feet for every 100 feet of horizontal distance. The common accessibility limit for ramps is a rise of 1 for every 12 of run, which is 112≈8.3%\frac{1}{12} \approx 8.3\%. A roof pitched 6 in 12 has a slope of 612=12\frac{6}{12} = \frac{1}{2}.

Slope also links to the angle of a line: m=tan⁡θm = \tan\theta, so θ=tan⁡−1(m)\theta = \tan^{-1}(m). A slope of 34\frac{3}{4} means an angle of about 36.87∘36.87^\circ with the horizontal. And when a line passes through the origin, its slope is the constant in direct variation, y=kxy = kx, which is why proportional relationships always graph as straight lines through (0,0)(0, 0).

Quick check

A ramp rises 3 feet over a horizontal distance of 36 feet. What is its slope as a percent grade?

Practice problems

0 of 5 solved

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

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

  3. Find the slope of the line through (−4,9)(-4, 9) and (−4,−3)(-4, -3).

  4. Find the slope of the line through (14,2)\left(\frac{1}{4}, 2\right) and (34,−1)\left(\frac{3}{4}, -1\right).

  5. The line through (2,k)(2, k) and (6,9)(6, 9) has slope 34\frac{3}{4}. Find kk.

Common questions

What is the slope formula?

The slope formula is m=y2−y1x2−x1m = \frac{y_2 - y_1}{x_2 - x_1}, where (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2) are two points on the line. It divides the vertical change by the horizontal change.

Does it matter which point is first in the slope formula?

No. Swapping the two points flips the sign of both the top and the bottom, so the fraction keeps its value. What matters is using the same order for the yy values and the xx values.

Why is the slope of a vertical line undefined?

Every point on a vertical line has the same xx-value, so the run is 00. The formula then asks you to divide by zero, which has no answer.

What is the difference between zero slope and undefined slope?

Zero slope belongs to a horizontal line: the rise is 00, so m=0m = 0. Undefined slope belongs to a vertical line: the run is 00, so the division cannot be done.

How do you find the slope from an equation like 3x + 4y = 12?

For Ax+By=CAx + By = C, the slope is −AB-\frac{A}{B}. Here that gives −34-\frac{3}{4}. You can also solve for yy and read off the coefficient of xx.

How do you find slope from a graph without the formula?

Pick two points where the line crosses grid corners, count the units up or down (rise), then the units across (run), and divide. Going down or left makes that count negative.

Up next