What a slope measures
A straight line changes at a steady rate. Every step of 1 to the right changes by the same amount, and that amount is the line's slope. Its units are units of per unit of .
A candle is 24 cm tall when it is lit, and it burns down 1.5 cm every hour. Here is its height after hours.
| (hours) | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| (cm) | 24 | 22.5 | 21 | 19.5 | 18 |
Each hour takes off the same 1.5 cm, so the points lie on a straight line. Its slope is cm per hour, negative because the height falls. The starting height, 24 cm at , is where the line meets the vertical axis.
Slope from two points: rise over run
Usually you are not told the rate. You have two points on the line instead. Going from the first point to the second, the run is the change in and the rise is the change in .
Rule: Slope from two points
The slope of the line through and is the rise divided by the run. Any two points of the line give the same slope, in either order, as long as top and bottom use the same order.
For and , the run is and the rise is , so .
Two other points of the same line, and , give again. In reverse order, .
Rising, falling and flat
The sign of the rise, over a positive run, gives the sign of the slope.
Rise over run on three lines, each with a run of 3. The dot marked is where each line crosses the -axis.
- Positive: the line climbs from left to right. From to the slope is 2.
- Negative: the line falls. From to the rise is , so the slope is .
- Zero: the line is flat. From to the rise is 0, so the slope is 0.
The size of the slope is the steepness. A slope of is as steep as 3, but falls. A slope of climbs 1 for every 2 steps to the right.
Vertical lines have no slope
Through and the run is , so rise over run would divide by zero. A vertical line has no slope at all, which is not the same as a slope of 0. Its equation is , and it fails the vertical line test of lesson 1.1.1, so it is not the graph of a function.
Try it
slope is the rule above, with each point written as a pair (x, y). The cell checks every case in this section, including both orders for the first line.
The vertical line raises ZeroDivisionError, which the try block catches. Each slope prints as a decimal (2.0, not 2) because / in Python always gives one.
The equation of a line
Every line that is not vertical can be written as
where is the slope and is the intercept: the value of where the line crosses the -axis, at . Lesson 1.1.1 called it , and it is in the units of . The candle is : slope cm per hour, intercept 24 cm.
Rule: Line through two points
Find the slope first. Then put one point into and solve for the intercept: gives .
Example 1, by a table and by algebra. Take and again, with slope 2. Each step of 1 in adds 2 to , so one step back from gives at . The table steps forward from there and lands on :
| 0 | 1 | 2 | 3 | 4 | |
|---|---|---|---|---|---|
| 1 | 3 | 5 | 7 | 9 |
The algebra agrees: , so the line is . Check it with the other point: .
Example 2, a falling line. Through and , the slope is . Then , so . Check: .
From one point and a slope
Sometimes you know one point and the slope . Then you can write the line down at once, without finding first.
Rule: Point and slope
At the bracket is 0, so : the line passes through the point. Each step of 1 to the right adds . Multiplying out gives , the same line as before.
Slope 3 through gives , which multiplies out to . Write (read "delta ") for a change in . A change of moves by : from to 2.5, rises , to 6.5.
Lines written another way
A line may come as , and its slope is not 3. Make the subject first, as in lesson 0.3.2: , so , with slope and intercept 3.
An equation with no in it, such as , is the vertical line .
Try it
line_through returns the slope and the intercept from two points, using the rule above. It recovers both examples.
np.polyfit(x, y, 1) does the same from a list of values and a list of values; the 1 means a straight line. Given four points that are not quite on a line, it returns the line that fits them best, here . Module 5.10 explains how.
Where a line crosses the -axis
On the -axis, . So the crossing, the line's zero from lesson 1.1.1, solves , which gives .
For the crossing is at . For the candle, gives : the candle burns out after 16 hours.
A flat line breaks the formula, because would put zero on the bottom. The line never meets the -axis, and is the axis itself.
Try it
crossing returns , or None for a flat line.
It gives 5.5 for and 16.0 for the candle.
Where two lines meet
Two lines meet where they give the same for the same . So set the two right-hand sides equal and solve, as in lesson 0.3.2. For and :
Then , so they meet at . The other line agrees: .
Lines with different slopes cross at one point. Lines with the same slope stay the same distance apart, here 3, so they never meet.
Rule: Where two lines meet
Different slopes: exactly one meeting point. Same slope and different intercepts: parallel lines, which never meet. Same slope and same intercept: one line written twice, so every point is shared.
For the parallel lines and , the equation is . Taking from both sides leaves , which is false for every , so there is no meeting point.
Try it
meet solves , which gives , then finds from the first line.
It returns None when the slopes are equal, because the bottom would be 0.
Lesson 1.6.1 joins data points with lines, and lesson 2.2.1 uses rise over run to measure how fast a curve changes. Case study 1.2.4 meets a line in finance.
Common mistakes
- Use the same order on top and bottom. has the wrong sign.
- Rise over run, not run over rise. For and , is upside down; the slope is 2.
- Watch the signs in . With and the point , , not .
- The intercept is on the -axis, at . The crossing of the -axis is .
- Make the subject before reading the slope. The slope of is , not 3.
- Flat and vertical are different. A flat line has slope 0. A vertical line has no slope and cannot be written as .
- Equal slopes mean parallel lines. Solving gives a false statement such as , so the lines never meet.
Lines
0 of 12 correct
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
How to type answers
- Powers with
^:x^7,2^(1/3),a^-2. - Multiply with
*or by writing side by side:3x^2,2(x+1). ln(x)is the natural log,log(x, 2)is log base 2,eis Euler's number,sqrt(x)is a square root.sin(x),cos(x)andtan(x)take radians; writepifor π andsin(x)^2for sin²x.- Your first answer to each question is saved: it counts towards your score and brings the question back for review.
- Exact answers like
ln(20)/ln(3)are best. Decimals need about 4 significant figures.
Summary card
- Slope : the change in for each step of 1 in , in units of per unit of . Positive rises, negative falls, 0 is flat; a vertical line has no slope.
- A line is , with intercept the value of at . From two points: find , then .
- From one point and the slope: . A change moves by .
- A line crosses the -axis at ; a flat line never does, unless it is the axis.
- Two lines meet where : once if the slopes differ, never if they are parallel.