Slopes and Rates
How fast it changes.
Machine learning models learn by asking one question over and over. If I nudge this weight a little, does the error go up or down, and by how much? That's a question about rates of change. And calculus is the maths of change.

- Nudge a weight
- Does the error go up or down?
- Calculus: the maths of change
Slope of a line
For a straight line, the rate of change is its slope. Rise over run. How much Y changes, divided by how much X changes. A slope of two means Y goes up two for every one step in X. A negative slope means Y goes down. And a slope of zero means a flat line.
| key | value |
|---|---|
| Slope | rise ÷ run |
| 2 | up 2 per step |
| −1 | down 1 per step |
| 0 | flat |
Average rate of change
A car's distance, in metres, after T seconds is T squared. That's a curve, not a line, so the speed keeps changing. We can compute the average speed between two times. Run it. Between one and three seconds, four metres per second. Between three and five, eight. The car is speeding up.
def distance(t):
return t ** 2
def average_rate(f, a, b):
return (f(b) - f(a)) / (b - a)
print("1s to 3s:", average_rate(distance, 1, 3), "m/s")
print("3s to 5s:", average_rate(distance, 3, 5), "m/s")1s to 3s: 4.0 m/s 3s to 5s: 8.0 m/s
Summary
Slope is rise over run, and the average rate of change is the slope between two points. Curves have changing slopes. Next, the slope at a single point, the derivative.
Key takeaways- rise / run
- Average rate between points
- Curves keep changing