Sub topic 1
Quick review: slope as rate of change
Slope is the number that tells you how steeply a line rises or falls. This chapter reviews it before the tutorial builds point-slope and standard forms on top of it. You will see slope as a ratio, as a rate of change, and as a number you can compute from two points.
Prerequisites
This chapter assumes you can already do the following:
- Plot points on the coordinate plane and read coordinates as (x, y).
- Describe slope as rise over run.
- Recognize slope-intercept form y = mx + b.
- Solve a linear equation for one variable.
- Do arithmetic with fractions and negative numbers.
If any of these feel shaky, fix them first. Nearly every later step uses fraction and sign arithmetic.
Slope as a ratio
The slope of a line is the change in y divided by the change in x between any two points on the line. It is usually written m:
m = (y2 - y1) / (x2 - x1)
The numerator is the rise, and the denominator is the run. For the points (1, 3) and (4, 9):
- Rise: 9 - 3 = 6
- Run: 4 - 1 = 3
- Slope: 6 / 3 = 2
A slope of 2 means that every time x increases by 1, y increases by 2.
A line has one slope, so any two points on it give the same answer. Take (1, 3) and (2, 5) from the same line. The rise is 2 and the run is 1, so the slope is again 2. This is what "straight" means: the ratio of rise to run never changes.
Slope as rate of change
Slope compares how fast y changes relative to x. The units of the slope are the units of y per unit of x.
Suppose a taxi charges a flat fee plus a price per kilometer. The cost is 4 dollars at 0 km and 16 dollars at 6 km.
- Rise: 16 - 4 = 12 dollars
- Run: 6 - 0 = 6 kilometers
- Slope: 12 / 6 = 2 dollars per kilometer
The slope is the price of each extra kilometer. Reading slope as a rate of change gives it meaning in a real problem. It is not only a number from a formula.
What the sign and size of slope tell you
The sign tells you the direction of the line when you read left to right. The size tells you how steep it is.
| Slope | Direction of the line | Example |
|---|---|---|
| Positive | Rises | m = 2 |
| Negative | Falls | m = -3 |
| Zero | Flat (horizontal) | m = 0 |
| Undefined | Straight up and down (vertical) | x1 = x2 |
A larger absolute value means a steeper line. A slope of -3 is steeper than a slope of 1, and it falls instead of rising. A slope of 1/2 is gentler than a slope of 1.
The order of subtraction
You can subtract in either order, but you must be consistent. Use the same order for the top and the bottom.
For (1, 3) and (4, 9):
- Point 2 minus point 1: (9 - 3) / (4 - 1) = 6 / 3 = 2
- Point 1 minus point 2: (3 - 9) / (1 - 4) = -6 / -3 = 2
Both orders give 2. The common error is mixing the orders, for example (9 - 3) / (1 - 4) = -2. That gives the wrong sign.
Vertical lines have no slope
If x1 = x2, the run is 0. Division by zero is undefined, so a vertical line has no slope. This matters later: point-slope form needs a slope, so it cannot describe a vertical line. A later chapter covers vertical lines in detail.
A horizontal line is different. Its rise is 0 and its run is not 0, so the slope is 0 / run = 0. A horizontal line has a slope of zero, and that slope is a valid number.
Computing slope in code
The function below computes the slope from two points. It uses exact fractions so results such as 1/3 are not rounded. It raises an error for a vertical line.
from fractions import Fraction
def slope_through(p, q):
(x1, y1), (x2, y2) = p, q
if x1 == x2:
raise ValueError(f"vertical line: x = {x1}")
return Fraction(y2 - y1, x2 - x1)
print(slope_through((1, 3), (4, 9))) # 2
print(slope_through((0, 4), (6, 16))) # 2
print(slope_through((2, 5), (5, 4))) # -1/3
print(slope_through((0, 7), (5, 7))) # 0
try:
slope_through((3, 1), (3, 8))
except ValueError as err:
print(err) # vertical line: x = 3Python prints 2 for Fraction(6, 3) because the fraction reduces automatically.
How slope connects to the forms ahead
The next chapters use slope in three ways. The diagram shows how this chapter feeds them.
- Slope-intercept form y = mx + b uses the slope m directly, together with the y-intercept b.
- Point-slope form y - y1 = m(x - x1) uses the slope together with any one known point.
- Writing an equation from two points starts by computing the slope with the ratio above.
Common slope errors
- Swapping rise and run. Slope is change in y over change in x. Putting x on top gives the reciprocal.
- Mixing the subtraction order. Use the same point first on the top and on the bottom.
- Dropping a negative sign. Subtracting a negative number adds. For (-2, 1) and (3, -4), the rise is -4 - 1 = -5 and the run is 3 - (-2) = 5, so the slope is -1.
- Reading the graph backward. Read from left to right. A line that falls as you move right has a negative slope.
- Calling a vertical line slope 0. Slope 0 is horizontal. A vertical line has an undefined slope.
A quick check catches most of these. Sketch the two points. If the line rises to the right, the slope must be positive.
Worked example
Find the slope of the line through (-2, 1) and (3, -4), and say what it means.
- Choose the order: point 1 is (-2, 1) and point 2 is (3, -4).
- Rise: -4 - 1 = -5.
- Run: 3 - (-2) = 5.
- Slope: -5 / 5 = -1.
The slope is -1. The line falls 1 unit for every 1 unit it moves to the right. This matches the sketch: the second point is lower and to the right of the first.
Exercise
A line passes through (2, 5) and (6, 13). Find its slope, then state in one sentence what it means for y when x increases by 1.
Show answer
Rise = 13 - 5 = 8 and run = 6 - 2 = 4, so the slope is 8 / 4 = 2. When x increases by 1, y increases by 2.
Exercise
Why does the line through (3, 1) and (3, 8) have no slope, while the line through (0, 7) and (5, 7) has slope 0?
Show answer
The first line is vertical. Its run is 3 - 3 = 0, and dividing by zero is undefined. The second line is horizontal. Its rise is 7 - 7 = 0 and its run is 5, so the slope is 0 / 5 = 0.