How to find the slope of a line

To find the slope of a line, take two points on it and divide the change in y (the rise) by the change in x (the run): slope = (y₂ − y₁) ÷ (x₂ − x₁). For (1, 1) and (5, 4), the slope is (4 − 1) ÷ (5 − 1) = 3/4. If the equation is written as y = mx + b, the slope is m.

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

The slope m is the change in y, y₂ − y₁, divided by the change in x, x₂ − x₁, for any two points (x₁, y₁) and (x₂, y₂) on the line.

Updated

A blue line rising from left to right on a grid through the points (1, 1) and (5, 4). An amber run of 4 units goes right from (1, 1) and an amber rise of 3 units goes up to (5, 4); the slope is labeled 3/4.
Between (1,1)(1, 1) and (5,4)(5, 4) the line runs 4 units right and rises 3 units, so its slope is 34\frac{3}{4}.

Key ideas

  1. 01

    Slope is rise over run: the change in y divided by the change in x between two points on a line, m = (y₂ − y₁) ÷ (x₂ − x₁).

  2. 02

    A straight line has the same slope everywhere, so any two of its points give the same answer, and either point can go first if you subtract in the same order on top and bottom.

  3. 03

    On a graph, pick two points where the line crosses grid corners, count the rise (up is positive, down is negative) and the run to the right, then divide.

  4. 04

    In slope-intercept form, y = mx + b, the slope is m, the number multiplying x once y is alone. In standard form, Ax + By = C, the slope is −A/B, as long as B is not 0.

  5. 05

    A positive slope rises from left to right, a negative slope falls, a horizontal line has slope 0, and a vertical line has an undefined slope because its run is 0.

  6. 06

    Parallel lines have equal slopes. Perpendicular lines, if neither is vertical, have slopes that are negative reciprocals, such as 2 and −1/2, which multiply to −1.

  7. 07

    Slope is a rate of change: its units are y-units per x-unit, so the slope of a distance-time graph is a speed, such as 60 miles per hour.

How do you find slope on a graph?

To find slope on a graph, pick two points on the line, count how many units the line rises between them and how many units it runs to the right, then divide the rise by the run. Count up as positive and down as negative.

  1. 1Find two points where the line crosses grid corners exactly, so you can read both coordinates without guessing.
  2. 2From the left point, count the rise: the units up (positive) or down (negative) to the height of the other point.
  3. 3Count the run: the units right to reach the other point.
  4. 4Divide: slope =riserun= \frac{\text{rise}}{\text{run}}. Simplify the fraction.
  5. 5Check with another pair of points. A straight line gives the same slope every time.
A line falling from left to right on a grid through (2, 5), (5, 3) and (8, 1), with an amber staircase along it: right 3, down 2, right 3, down 2. The slope is labeled −2/3.
From (2,5)(2, 5) the line steps right 3 and down 2 to (5,3)(5, 3), then right 3 and down 2 again to (8,1)(8, 1). Every step gives the same slope, −23=−23\frac{-2}{3} = -\frac{2}{3}.

Read the numbers on the axes before you count squares. If each square stands for 2 or 5 units, the number of squares is not the rise or the run.

How do you find slope with two points?

To find slope from two points, subtract the y-coordinates, subtract the x-coordinates in the same order, and divide. This is the slope formula, rise over run written with coordinates:

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

m equals y₂ minus y₁, divided by x₂ minus x₁: the change in y over the change in x between the points (x₁, y₁) and (x₂, y₂).

  1. 1Label the points (x1,y1)(x_1, y_1) and (x2,y2)(x_2, y_2). Either point can be first.
  2. 2Rise: subtract the y-values, y2−y1y_2 - y_1.
  3. 3Run: subtract the x-values in the same order, x2−x1x_2 - x_1.
  4. 4Divide the rise by the run and simplify. A negative answer means the line falls.

For (−1,3)(-1, 3) and (2,−3)(2, -3): m=−3−32−(−1)=−63=−2m = \frac{-3 - 3}{2 - (-1)} = \frac{-6}{3} = -2. Swapping the points gives 3−(−3)−1−2=6−3=−2\frac{3 - (-3)}{-1 - 2} = \frac{6}{-3} = -2, the same slope.

Put parentheses around negative coordinates before you subtract: 2−(−1)=32 - (-1) = 3, not 11.

The rise and run between two points are the legs of a right triangle, so the distance between the points is rise2+run2\sqrt{\text{rise}^2 + \text{run}^2}, by the Pythagorean theorem.

How do you find slope from an equation?

To find slope from an equation, solve it for y. Once it reads y=mx+by = mx + b, the slope is mm, the number multiplying xx, and bb is the y-intercept, where the line crosses the y-axis. This is called slope-intercept form.

The line y = ½x + 2 on a grid. A purple dot marks the y-intercept (0, 2), labeled b = 2, and amber steps of right 2, up 1 climb along the line from it, labeled m = 1/2.
y=12x+2y = \frac{1}{2}x + 2 crosses the y-axis at b=2b = 2 and rises 1 unit for every 2 units it runs right, so m=12m = \frac{1}{2}.
Reading the slope from each form of a line's equation
FormExampleSlope
Slope-intercept, y=mx+by = mx + by=−3x+5y = -3x + 5−3-3
Point-slope, y−y1=m(x−x1)y - y_1 = m(x - x_1)y−4=5(x+1)y - 4 = 5(x + 1)55
Standard, Ax+By=CAx + By = C2x+3y=62x + 3y = 6−AB=−23-\frac{A}{B} = -\frac{2}{3}
Horizontal, y=cy = cy=4y = 400
Vertical, x=cx = cx=−2x = -2undefined

Standard form needs one more step, because the slope is not the number in front of xx. To find the slope of 2x+3y=62x + 3y = 6:

  1. 1Subtract 2x2x from both sides: 3y=−2x+63y = -2x + 6.
  2. 2Divide every term by 3: y=−23x+2y = -\frac{2}{3}x + 2.
  3. 3Read the number multiplying xx: m=−23m = -\frac{2}{3}.

The slope is the number multiplying xx only when yy stands alone. In 2y=6x+42y = 6x + 4, divide by 2 first: y=3x+2y = 3x + 2, so the slope is 3, not 6.

What do positive, negative, zero and undefined slopes look like?

Read a line from left to right: a positive slope rises, a negative slope falls, a zero slope stays flat, and a vertical line has an undefined slope. The farther the slope is from 0, in either direction, the steeper the line.

Four small graphs. A line rising steeply labeled m = 2, a line falling gently labeled m = −½, a horizontal line labeled m = 0, and a vertical line labeled m undefined.
Read left to right, slope 22 rises, slope −12-\frac{1}{2} falls, slope 00 stays flat, and a vertical line's slope is undefined.
The four kinds of slope
SlopeThe lineExampleWhy
PositiveRisesy=2x+1y = 2x + 1Rise and run have the same sign
NegativeFallsy=−12x+3y = -\frac{1}{2}x + 3Rise and run have opposite signs
ZeroHorizontaly=4y = 4The rise is 0, and 0run=0\frac{0}{\text{run}} = 0
UndefinedVerticalx=−2x = -2The run is 0, and you cannot divide by 0

Why a vertical line's slope is undefined: between (3,1)(3, 1) and (3,5)(3, 5) the rise is 4 and the run is 3−3=03 - 3 = 0, so the slope would be 40\frac{4}{0}. No number times 0 makes 4, so the division has no answer. A horizontal line is the opposite case: its rise is 0, and 0 divided by any run is 0.

Slope also sets a line's angle: a line at an angle θ\theta measured counterclockwise from the positive x-axis has slope m=tan⁡θm = \tan\theta, the tangent from the unit circle. A slope of 1 rises at 45°, and a slope of −1-1 falls at 45°.

Zero slope and undefined slope are not the same: zero is flat, undefined is vertical.

How do you find slope from a table?

To find slope from a table of values, take any two rows and divide the change in y by the change in x. When the table describes a line, every pair of rows gives the same slope.

A table of values for a line
xy
110
37
54
71

From the first two rows, m=7−103−1=−32=−32m = \frac{7 - 10}{3 - 1} = \frac{-3}{2} = -\frac{3}{2}. Each row adds 2 to xx and takes 3 from yy, so any two rows give −32-\frac{3}{2}. If two pairs of rows give different slopes, the points do not lie on one line.

Divide by the real change in xx. Here xx goes up by 2 from row to row, so the slope is −32-\frac{3}{2}, not −3-3.

What are the slopes of parallel and perpendicular lines?

Parallel lines have equal slopes. Perpendicular lines, if neither is vertical, have slopes that are negative reciprocals of each other: flip the fraction and change its sign, and the two slopes multiply to −1-1.

Two perpendicular lines crossing at (3, 3): a blue line with slope ½ and a purple line with slope −2. The blue line's rise-run triangle (right 2, up 1) and the purple line's (down 2, right 1) are the same triangle turned a quarter turn.
The blue line has slope 12\frac{1}{2}: run 2, rise 1. Turned a quarter turn about the crossing point, its triangle becomes the purple line's: down 2, run 1, a slope of −2-2.

For example, y=23x−1y = \frac{2}{3}x - 1 has slope 23\frac{2}{3}. Every line parallel to it has slope 23\frac{2}{3}, and every line perpendicular to it has slope −32-\frac{3}{2}, because 23⋅(−32)=−1\frac{2}{3} \cdot \left(-\frac{3}{2}\right) = -1.

One exception: a horizontal line and a vertical line are perpendicular, but slope 0 and an undefined slope cannot multiply to −1-1.

What does slope mean in real life?

In real life, slope is a rate of change: how much the quantity on the y-axis changes for each one unit of the quantity on the x-axis. Its units are y-units per x-unit.

A car driving away from home on a straight highway is 150 miles from home after 3 hours and 270 miles from home after 5 hours. The slope between those two points on its distance-time graph is 270−1505−3=1202=60\frac{270 - 150}{5 - 3} = \frac{120}{2} = 60 miles per hour: the car's average speed over those 2 hours.

Roads and ramps give slope as a percent, called the grade: the slope times 100%. A ramp that rises 1 foot over a run of 12 feet has slope 112≈0.083\frac{1}{12} \approx 0.083, a grade of about 8.3%. A 100% grade is a slope of 1, a 45° incline, not a vertical wall.

The slope between two points is an average rate. The car's speed at a single instant, the number on its speedometer, is the slope of its distance-time graph at that one moment, which the derivative finds.

Worked examples

Slope from two points with negative coordinates

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

  1. 1Take (x1,y1)=(−3,4)(x_1, y_1) = (-3, 4) and (x2,y2)=(5,−2)(x_2, y_2) = (5, -2).
  2. 2Rise: y2−y1=−2−4=−6y_2 - y_1 = -2 - 4 = -6.
  3. 3Run: x2−x1=5−(−3)=8x_2 - x_1 = 5 - (-3) = 8.
  4. 4Divide and simplify: m=−68=−34m = \frac{-6}{8} = -\frac{3}{4}.
  5. 5Check in the other order: 4−(−2)−3−5=6−8=−34\frac{4 - (-2)}{-3 - 5} = \frac{6}{-8} = -\frac{3}{4}.

Answer: m=−34m = -\frac{3}{4}: the line falls 3 units for every 4 units it runs right.

Slope from a graph whose squares are not 1 unit

Find the slope of the line on the graph. Each square is 1 unit wide but 2 units tall.

A line through (1, 2) and (4, 8) on a grid whose x-axis counts by 1 and whose y-axis counts by 2. An amber run of 3 and an amber rise of 6, which covers 3 squares, connect the points.
The line passes through (1,2)(1, 2) and (4,8)(4, 8). The rise covers 3 squares, but each square is 2 units tall, so the rise is 6.
  1. 1Read the axes first: xx counts by 1 per square and yy counts by 2 per square.
  2. 2Pick two points on grid corners: (1,2)(1, 2) and (4,8)(4, 8).
  3. 3Rise: 8−2=68 - 2 = 6. That is 3 squares, but 6 units.
  4. 4Run: 4−1=34 - 1 = 3.
  5. 5Divide: m=63=2m = \frac{6}{3} = 2.

Answer: m=2m = 2. Counting squares alone would give 33=1\frac{3}{3} = 1, which is wrong.

Slope from standard form

Find the slope of the line 2x−5y=102x - 5y = 10.

  1. 1Subtract 2x2x from both sides: −5y=−2x+10-5y = -2x + 10.
  2. 2Divide every term by −5-5: y=25x−2y = \frac{2}{5}x - 2.
  3. 3Read the number multiplying xx: m=25m = \frac{2}{5}.
  4. 4Check with the shortcut m=−ABm = -\frac{A}{B}, where A=2A = 2 and B=−5B = -5: −2−5=25-\frac{2}{-5} = \frac{2}{5}.

Answer: m=25m = \frac{2}{5}

Slope and y-intercept from two points

Write the equation of the line through (2,1)(2, 1) and (6,7)(6, 7) in slope-intercept form.

  1. 1Slope: m=7−16−2=64=32m = \frac{7 - 1}{6 - 2} = \frac{6}{4} = \frac{3}{2}.
  2. 2Put the slope and one point, (2,1)(2, 1), into y=mx+by = mx + b: 1=32(2)+b1 = \frac{3}{2}(2) + b.
  3. 3Solve for bb: 1=3+b1 = 3 + b, so b=−2b = -2.
  4. 4Check the other point: 32(6)−2=9−2=7\frac{3}{2}(6) - 2 = 9 - 2 = 7, which matches (6,7)(6, 7).

Answer: y=32x−2y = \frac{3}{2}x - 2, with slope 32\frac{3}{2} and y-intercept −2-2.

Slope of a vertical line and a horizontal line

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

  1. 1First line: the rise is 4−(−1)=54 - (-1) = 5 and the run is 3−3=03 - 3 = 0.
  2. 250\frac{5}{0} has no value, so the slope is undefined. Both points have x=3x = 3, so the line is the vertical line x=3x = 3.
  3. 3Second line: the rise is 5−5=05 - 5 = 0 and the run is 6−(−2)=86 - (-2) = 8.
  4. 408=0\frac{0}{8} = 0, so the slope is 0. Both points have y=5y = 5, so the line is the horizontal line y=5y = 5.

Answer: The vertical line x=3x = 3 has an undefined slope; the horizontal line y=5y = 5 has slope 0.

Slope of a perpendicular line

Find the slope of a line perpendicular to 6x+2y=76x + 2y = 7.

  1. 1Solve for yy: 2y=−6x+72y = -6x + 7, so y=−3x+72y = -3x + \frac{7}{2}.
  2. 2The given line has slope −3-3.
  3. 3Take the negative reciprocal: the reciprocal of −3-3 is −13-\frac{1}{3}, and changing its sign gives 13\frac{1}{3}.
  4. 4Check: −3⋅13=−1-3 \cdot \frac{1}{3} = -1.

Answer: 13\frac{1}{3}

Check yourself

  1. 1.What is the slope of the line through (2, 3) and (6, 11)?Show answer

    2. The rise is 11 − 3 = 8 and the run is 6 − 2 = 4, so the slope is 8 ÷ 4 = 2.

  2. 2.What is the slope of the line through (−1, 4) and (3, −4)?Show answer

    −2. The rise is −4 − 4 = −8 and the run is 3 − (−1) = 4, so the slope is −8 ÷ 4 = −2.

  3. 3.What is the slope of the line through (0, −2) and (5, 0)?Show answer

    2/5. The rise is 0 − (−2) = 2 and the run is 5 − 0 = 5.

  4. 4.A line rises 6 units for every 4 units it runs to the right. What is its slope?Show answer

    3/2, because 6/4 simplifies to 3/2.

  5. 5.What is the slope of y = −4x + 7?Show answer

    −4, the number multiplying x.

  6. 6.What is the slope of y = 5 − 2x?Show answer

    −2. The slope is the number multiplying x, wherever the x term is written.

  7. 7.What is the slope of 3x + 2y = 8?Show answer

    −3/2. Solving for y gives y = −(3/2)x + 4.

  8. 8.What is the slope of the line y = 5?Show answer

    0. The line is horizontal.

  9. 9.What is the slope of the line x = −3?Show answer

    Undefined. The line is vertical, so its run is 0.

  10. 10.A line has slope 2/3. What is the slope of a line perpendicular to it?Show answer

    −3/2, the negative reciprocal. Check: (2/3) × (−3/2) = −1.

Common mistakes

  • Dividing the run by the rise: x2−x1y2−y1\frac{x_2 - x_1}{y_2 - y_1}.Slope is rise over run. The change in y goes on top: y2−y1x2−x1\frac{y_2 - y_1}{x_2 - x_1}.
  • Subtracting in different orders, such as y2−y1x1−x2\frac{y_2 - y_1}{x_1 - x_2}, which flips the sign.Start from the same point on top and bottom. If y2y_2 comes first on top, x2x_2 comes first on the bottom.
  • Losing a sign with a negative coordinate, such as writing 5−(−3)5 - (-3) as 22.Put negative numbers in parentheses, then subtract: 5−(−3)=5+3=85 - (-3) = 5 + 3 = 8.
  • Reading the slope of 2x+3y=62x + 3y = 6 as 22.Solve for yy first: y=−23x+2y = -\frac{2}{3}x + 2, so the slope is −23-\frac{2}{3}.
  • Saying a vertical line has slope 0.A horizontal line has slope 0. A vertical line has an undefined slope, because its run is 0.
  • Counting grid squares without checking what each square is worth.Read the numbers on the axes. If each square is 2 units tall, a rise of 3 squares is 6 units.
  • Counting from the right-hand point to the left and calling the run positive.Start at the left point and count the run to the right, so the run is positive and the sign of the rise is the sign of the slope.

Questions students ask

Does it matter which point is (x₁, y₁)?

No. Either point can be first, as long as you use the same order on the top and the bottom of the slope formula. Swapping the points changes the sign of both the rise and the run, and the two sign changes cancel. Mixing the orders, such as y₂ − y₁ over x₁ − x₂, gives the right size with the wrong sign.

Can slope be a fraction, a decimal or bigger than 1?

Yes. A slope can be any real number, such as 3/4, −2.5 or 7. A slope above 1 or below −1 means the line is steeper than 45° when both axes use the same scale. Fractions are usually left as fractions, because a slope of 3/4 also reads as rise 3, run 4.

Is a slope of 0 the same as an undefined slope?

No. A slope of 0 belongs to a horizontal line: its rise is 0, and 0 divided by any run is 0. An undefined slope belongs to a vertical line: its run is 0, and division by 0 has no answer. Zero is a number; an undefined slope is not a number at all.

Why is slope called m?

No one knows. The earliest known use is by the Italian mathematician Vincenzo Riccati, who wrote a line as y = mx + n in 1757, and English textbooks were writing y = mx + c and y = mx + b by the 1840s. Historians of math notation say the choice may have been arbitrary. The popular story that m comes from the French word monter, to climb, has no evidence behind it.

Can you find the slope with only one point?

No. Infinitely many lines pass through a single point, each with a different slope. You also need a second point, the line's equation, or a fact such as the line being parallel or perpendicular to a line whose slope you know. The y-intercept counts as a second point: it is the point (0, b).

Does slope have units?

Yes, whenever the axes measure quantities with units. The units of slope are the y-axis units per x-axis unit: a graph of miles against hours has a slope in miles per hour, and a graph of cost against tickets has a slope in dollars per ticket. On a plain x-y grid, slope is just a number.

How do you find the slope of a curve or a tangent line?

A curve has no single slope, because its steepness changes from point to point. Its slope at one point is the slope of the tangent line there, the straight line that runs in the same direction as the curve at that point. Calculus finds it with the derivative: for example, the slope of y = x² at x = 3 is 6.

Is slope the same as gradient?

Yes, for a straight line. Gradient is the usual word for slope in British and Australian schools, and both mean rise over run, the change in y divided by the change in x.

Is slope y over x?

Slope is the change in y over the change in x, (y₂ − y₁) ÷ (x₂ − x₁), not one point's y divided by its x. The two agree only for a line through the origin, such as y = 3x, where every point except (0, 0) gives y ÷ x = 3. On y = 2x + 4, the point (1, 6) gives y ÷ x = 6, but the slope is 2. It is never x over y: the change in y always goes on top.

Sources