Sub topic 1
Points and lines on the coordinate plane
Prerequisites
This chapter assumes you can plot points on a coordinate plane, subtract signed numbers, and simplify fractions. You should know that an ordered pair (x, y) gives a horizontal position and a vertical position.
Points and lines on the coordinate plane
A coordinate plane is a grid formed by two perpendicular number lines. The horizontal line is the x-axis, and the vertical line is the y-axis. They meet at the origin, (0, 0). Every point is an ordered pair (x, y). Two distinct points determine exactly one straight line, so any two points on a line describe it.
Rate of change: how much y changes per unit of x
A rate of change compares how much one quantity changes to how much another changes. On a straight line, the rate is the change in y for each unit change in x. If y rises by 2 every time x rises by 1, the rate is 2. This fixed rate is the slope.
Slope as rise over run
The slope of a line is rise divided by run. Rise is the vertical change between two points. Run is the horizontal change. Moving from (1, 2) to (3, 6) gives a rise of 4 and a run of 2, so the slope is 4 / 2 = 2.
Reading direction from slope
The sign and size of the slope show how the line moves from left to right:
| Slope | Direction | Example |
|---|---|---|
| Positive | Rises | Slope 2 |
| Negative | Falls | Slope -1 |
| Zero | Horizontal | Slope 0 |
| Undefined | Vertical | Run is 0 |
Computing slope from two points
Use the slope formula:
m = (y2 - y1) / (x2 - x1)
def slope(x1, y1, x2, y2):
if x1 == x2:
raise ValueError("A vertical line has undefined slope")
return (y2 - y1) / (x2 - x1)
print(slope(1, 2, 3, 6)) # 2.0
print(slope(0, 5, 4, 1)) # -1.0Exercise
What is the slope of the line through (2, 1) and (6, 9)?
Show answer
The rise is 9 - 1 = 8 and the run is 6 - 2 = 4, so the slope is 8 / 4 = 2.