III.4 · Calculus
How far can a tangent line predict?
Read the derivative as a velocity, then use the tangent line to predict a nearby value. Move the prediction farther away and watch its error grow — faster than the distance itself near the point, without bound far away.
Use the tangent line as a local model
Tangent model of f(x) = (1/6)x³ − x at x₀ = 1
Graph of f(x) = (1/6)x³ − x, tangent line at x₀ = 1 with slope −0.5. At x₀ + Δx = 2 the model gives −4/3 and the function gives −2/3; the caution segment is the error 2/3.
Model error e(Δx) = f(x₀ + Δx) − L(Δx)
The error curve touches zero at Δx = 0 and is flat there: it shrinks faster than Δx. The dashed parabola (f″(x₀)/2)Δx² with f″(x₀) 1 matches it near 0. Current error 2/3 at Δx = 1.
- Expansion point
- 1
- Displacement
- 1
- Value
- −5/6−0.833333…
- Instantaneous rate
- −0.5
- Average rate over [x₀, x₀ + Δx]
- 1/60.166667…
- Linear model at x₀ + Δx
- −4/3−1.333333…
- True value
- −2/3−0.666667…
- Model error f − L
- 2/30.666667…
- Error per unit displacement
- 2/30.666667…
- Curvature coefficient
- 0.5
Exact values use =; binary64 approximations use ≈. Undefined values state their reason.
Near x₀ the model is close: error 2/3 at Δx = 1. Halving Δx roughly quarters the error when f″(x₀) is nonzero — it shrinks faster than Δx.
| Δx | error e | e / Δx | e / Δx² |
|---|---|---|---|
| 1 | 2/3 | 2/3 | 2/3 |
| 0.5 | 7/48 | 7/24 | 7/12 |
| 0.25 | 13/384 | 13/96 | 13/24 |
| 0.125 | 25/3072 | 25/384 | 25/48 |
| 0.0625 | 49/24576 | 49/1536 | 49/96 |
| 0.03125 | 97/196608 | 97/6144 | 97/192 |
| 0.015625 | 193/1572864 | 193/24576 | 193/384 |
Δx = 1
Model −4/3, true value −2/3, error 2/3, error/Δx 2/3.
from −2.5 to 2.5, up to 2 decimal places
from −3 to 3, up to 2 decimal places
The tangent line at predicts with error . Drag the displaced point toward : the error shrinks, and the error per unit of displacement shrinks too. Then choose Far away: at the error is . A tangent line knows only what happens at one point.
Intuition: rate and prediction
If is a position, the secant slope is the average velocity over the interval, and the derivative is the instantaneous velocity. Knowing where you are and how fast you are going, you can predict where you will be shortly:
The same reading applies to any quantity: a cost per extra unit, a temperature change per second, a loss change per parameter step.
Definition
The local linear model (linearization, tangent-line approximation) of a differentiable at is
Its error is . Differentiability at means exactly that the error is small compared with the displacement:
Mechanics: what the explorer computes
For the cubic every quantity is exact: , the derivative, the model value, the true value and the error. For and the values are binary64 and marked . The error plane draws from the same model, together with the dashed parabola that describes it near . The table halves and lists , and .
Derivation: why the error is second order
For a polynomial, expanding around gives exactly
so the error starts with . Dividing by leaves , which tends to . Halving therefore roughly quarters the error when . When (an inflection) the error is even smaller, of order . Far from the higher terms dominate and nothing keeps the error small.
Worked example
Take , , . Then and , so the model predicts
The true value is , so . With , ; with , . The ratio approaches .
Replay the worked derivation
Δx = 1
Model −4/3, true value −2/3, error 2/3, error/Δx 2/3.
When there is no linear model
At a corner, such as at , no single slope works on both sides. Any line through the origin misses one side by an amount proportional to , so cannot tend to . The explorer reports the one-sided slopes and refuses to draw a model.
Executable reference code
The reference computes exact model errors of with Fraction and shows that exactly. The NumPy version linearizes and checks that .
"""The tangent-line model and its exact error (III.4)."""
from fractions import Fraction as F
def linear_model(f, fprime, x0, dx):
return f(x0) + fprime(x0) * dx
f = lambda x: x * x
fprime = lambda x: 2 * x
x0 = F(3)
for dx in [F(1), F(1, 10), F(-1, 100)]:
error = f(x0 + dx) - linear_model(f, fprime, x0, dx)
assert error == dx * dx # for x**2 the error is exactly dx**2
assert linear_model(f, fprime, x0, F(1, 10)) == F(96, 10)
# error/dx -> 0: the model is accurate to first order.
ratios = [(f(x0 + d) - linear_model(f, fprime, x0, d)) / d for d in (F(1, 2**k) for k in range(10))]
assert ratios == [F(1, 2**k) for k in range(10)]"""Linearize sin at x0 and watch e/dx**2 approach f''(x0)/2 = -sin(x0)/2 (III.4)."""
import numpy as np
x0 = 0.5
dx = 2.0 ** -np.arange(1, 12)
error = np.sin(x0 + dx) - (np.sin(x0) + np.cos(x0) * dx)
ratio = error / dx**2
assert abs(ratio[-1] + np.sin(x0) / 2) < 1e-3
# Far away the model is poor: at dx = 3 the error is larger than 1.
assert abs(np.sin(x0 + 3) - (np.sin(x0) + np.cos(x0) * 3)) > 1Explore
Put at an inflection ( for the cubic) and compare the error curve with the flat dashed parabola. On at , the model always underestimates. Make negative: the model also predicts the past.
Common mistakes
Evaluating the derivative at instead of mixes two different models. An average rate over a long interval is not the instantaneous rate. “Small ” is not a fixed number: it is small relative to how quickly the slope changes ().
Numerical considerations
The model is often used in binary64 to predict tiny changes, and the error of the prediction can be much smaller than the rounding error of computing directly. That is why linearized error propagation (VIII.3) is a practical tool, and why finite differences (III.14) need care.
Engineering and ML connections
Gradient descent (VI.4) trusts the local linear model to choose a downhill step; a too-large learning rate leaves the region where the model is accurate, exactly like Far away. Sensitivity analysis, uncertainty propagation and Newton’s method all start from .
Exercises
Summary and checkpoints
The derivative is an instantaneous rate and the slope of the best local linear model. Its error shrinks faster than the displacement near and can grow without bound farther away. Next, III.5 derives rules that compute derivatives of sums, products and quotients without returning to limits each time.