What is a rate of change?
A rate of change says how fast one measurement changes when another one changes. A bike shop asks it every day: for each extra degree of warmth, how many more bikes are hired?
In this lesson you will estimate a rate of change from a table of numbers. You will also see why a small step gives a better estimate than a big one.
By the end of this lesson
Note
I can estimate how fast something changes from numbers.
Key words
| Word | What it means | Example |
|---|---|---|
| Function | a rule that turns one number into another number | f(x) = x * x |
| Slope | how steeply a line or curve rises at a point | |
| Rate of change | the change in the output for one unit of change in the input | |
| Step | a small change in the input, written h | |
| Difference quotient | the change in the output divided by the step |
The cells students fill in are left blank in this preview.
A straight line has one slope everywhere
The shop notes how many bikes were hired at three temperatures. For each step of 5 degrees, the hires rise by 55.
The slope is the rise divided by the run. Here the rise is the change in hires and the run is the change in temperature. The slope of this line is 11 hires for each degree, and it is the same wherever you measure it.
Worked example: the slope of a line
| Temperature (degrees) | Hires | Run from the row above | Rise from the row above | Rise divided by run |
|---|---|---|---|---|
| 10 | 250 | |||
| 15 | 305 | 5 | 55 | 11 |
| 20 | 360 | 5 | 55 | 11 |
The cells students fill in are left blank in this preview.
A curve's slope changes at every point
Most real relationships bend. On a curve, rise over run depends on where you stand and how big a step you take.
To estimate the slope of f(x) = x * x at x = 3, take a small step h to the right. The difference quotient is (f(3 + h) - f(3)) / h. Shrink h and watch the answer settle.
Worked example: smaller steps settle on 6
| Step h | f(3 + h) | f(3 + h) minus f(3) | Divided by h |
|---|---|---|---|
| 1 | 16 | 7 | 7 |
| 0.1 | 9.61 | 0.61 | 6.1 |
| 0.01 | 9.0601 | 0.0601 | 6.01 |
| 0.001 | 9.006001 | 0.006001 | 6.001 |
The cells students fill in are left blank in this preview.
Run the steps in the lab
docker exec jupyter python3 -c "for h in [1, 0.1, 0.01, 0.001]: print(h, round(((3 + h) ** 2 - 9) / h, 3))"Shown here, not run. Create a free account to press Run and type it into your own lab’s terminal.
Stepping both ways gives a better estimate
The forward estimate is always a little off, because the curve bends away over the step. Stepping one way and the other cancels most of that.
The centred estimate is (f(x + h) - f(x - h)) / (2 * h). For x * x at 3 with a step of 1, it is (16 - 4) / 2, which is exactly 6. The forward estimate with the same step gave 7.
Try small steps in Python
# The slope of x squared at 3 is 6. How close does each step get?
def square(x):
return x * x
for h in [0.1, 0.0001, 0.00000001, 0.0000000000000001]:
forward = (square(3 + h) - square(3)) / h
print(h, round(forward, 4))
# Now change the line that finds forward to
# (square(3 + h) - square(3 - h)) / (2 * h)
# and run it again. Which steps give 6.0 now?
A common mistake
Warning
Many people think the smaller the step, the better the estimate, with no limit. A computer keeps only about 16 digits. When h is tiny, f(x + h) and f(x) look the same, and the answer collapses to 0. Use a step near 0.0001.
Going further
In your own notebook, estimate the slope of x * x * x at 2 with steps of 1, 0.1 and 0.01, using the centred estimate.
The true slope is 12. Work out how far each estimate is from 12, and say which step you would trust.