Skip to content
Tutorials Center
My learning

Topics

Lesson 12 of 37 ยท Linear Functions and Graphs

Slope of a Line

Understand slope as rate of change: rise over run, the slope formula, positive, negative, zero and undefined slopes, with examples and runnable code.

How steep is a hill, a roof or a road? Slope is the mathematical answer. It measures how much a line goes up or down for each step you move to the right. Slope is also a rate of change: how fast one quantity changes compared with another, such as kilometers per hour or dollars per month.

Rise over run

Pick two points on a line. Moving from the first to the second:

  • the rise is the vertical change (up is positive, down is negative),
  • the run is the horizontal change (right is positive).
Text
slope = rise / run

The letter m is traditionally used for slope.

Example 1. A line passes through (1, 2) and (4, 8). The rise is 8 - 2 = 6, the run is 4 - 1 = 3. Slope = 6/3 = 2. For each step right, the line goes up 2.

The slope formula

For points (xโ‚, yโ‚) and (xโ‚‚, yโ‚‚):

Text
m = (yโ‚‚ - yโ‚) / (xโ‚‚ - xโ‚)

Example 2. Points (-2, 5) and (3, -5).

m = (-5 - 5) / (3 - (-2)) = -10 / 5 = -2.

Take care with subtracting negatives: 3 - (-2) = 5. You can use either point first, but be consistent: both coordinates must go in the same order on top and bottom.

Four kinds of slope

Slope Direction of line (left to right) Example
Positive Rises m = 3
Negative Falls m = -1/2
Zero Horizontal m = 0
Undefined Vertical run = 0, division by zero

A horizontal line like y = 4 has rise 0 for any run, so m = 0. A vertical line like x = 3 has run 0, and we cannot divide by zero, so its slope is undefined.

Python Slope calculator for two points

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Slope as a rate of change

A cyclist rides at a steady speed. After 1 hour she has gone 18 km; after 3 hours, 54 km. The points are (1, 18) and (3, 54). Slope = (54 - 18) / (3 - 1) = 36 / 2 = 18 km per hour. The slope is the speed. Always include units: (change in y units) per (change in x units).

If the graph of a savings account has slope 25, the balance grows by 25 dollars per week. A negative slope, like -4, could be a tank losing 4 liters each minute.

Checking that points lie on one line

Three points are on the same line if the slope between the first two equals the slope between the next two. Test (0, 1), (2, 5), (5, 11): the first slope is 4/2 = 2; the second is 6/3 = 2. Same slope, so they are on one line.

Python Plot lines with different slopes

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

All four lines pass through the origin. The bigger the absolute value of the slope, the steeper the line.

Common mistakes

  1. Run over rise. It is rise over run: ฮ”y / ฮ”x.
  2. Subtracting in different orders. (yโ‚‚ - yโ‚) / (xโ‚ - xโ‚‚) gives the wrong sign.
  3. Mixing up zero and undefined. Horizontal means slope 0; vertical means undefined.
  4. Forgetting units in word problems.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

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

    Rise = 11 - 3 = 8; run = 6 - 2 = 4; slope = 2.
  2. 2. What is the slope through (1, 5) and (4, -1)?

    Rise = -1 - 5 = -6; run = 3; slope = -2.
  3. 3. What is the slope of the horizontal line y = 7?

    A horizontal line has no rise, so the slope is 0.
  4. 4. What is the slope of the vertical line x = -2?

    The run is 0, so the slope formula would divide by zero: undefined.

Summary

  • Slope m = rise / run = (yโ‚‚ - yโ‚) / (xโ‚‚ - xโ‚).
  • Positive slopes rise, negative fall, horizontal lines have slope 0, vertical lines have undefined slope.
  • Slope is a rate of change; write units with it.
  • Equal slopes between consecutive points show they are on one line.

Next: Slope-Intercept Form