Slopes from data and from black-box functions: forward, backward and central differences from Taylor series, derivative formulas from Newton's interpolation, Richardson extrapolation, and why differentiation is the one operation that amplifies noise.
A delivery robot is braking. Its position (metres) is logged every 0.1 s. What are its speed and deceleration at s?
| (s) | (m) |
|---|---|
| 1.0 | 7.989 |
| 1.1 | 8.403 |
| 1.2 | 8.781 |
| 1.3 | 9.129 |
| 1.4 | 9.451 |
| 1.5 | 9.750 |
| 1.6 | 10.031 |
Interpolation: values between table entries.
Slopes and curvature from the same tables, and from functions we can only evaluate.
input y[0..n] (step h), i # point x_i
build differences d[k] = Δᵏ y_i
d1 ← 0; sign ← +1
for k = 1 … n−i:
d1 ← d1 + sign·d[k] / k
sign ← −sign
d2 ← d[2] − d[3] + 11/12·d[4]
− 5/6·d[5] # if present
return d1/h, d2/h²For a point in the middle of the table, the two-point central formulas are usually enough.
There is no formula for to differentiate, only seven numbers. The same holds when is the output of a simulation or a trained model: finite differences work on values alone (and in ML they check the gradients computed by backpropagation).
Rule of thumb: central differences with ; Richardson for more accuracy; smooth before differentiating data.
| Formula | Points used | Order | Estimate | Error | Use |
|---|---|---|---|---|---|
| Forward | 2 | 0.497364 | start of a table | ||
| Backward | 2 | 0.581441 | end of a table, real-time data | ||
| Central | 2 | 0.539402 | default inside | ||
| Five-point / Richardson | 4 | 0.540301 | high accuracy, smooth | ||
| Newton forward series | many | up to | — | — | tables, written problems |
True value . More points buy higher order, but also more sensitivity to noise in the data.
Differentiation works well for smooth functions and badly for noisy data. Its siblings fix or avoid the weaknesses:
Click a card to see where a difference formula is applied.
Where exactly: debugging neural-network code. Backpropagation computes analytically; a bug gives wrong gradients that still train badly. The check: compare with a central difference for a few weights.
Andrew Ng's deep-learning course and PyTorch's torch.autograd.gradcheck use exactly this test.
Where exactly: medical signal processing. The Pan–Tompkins QRS detector (1985), still the reference algorithm, differentiates the filtered ECG to emphasise the steep QRS slopes, then squares and averages.
Notice the order: smooth first, then differentiate. That is the remedy from the limitations slide.
Where exactly: engineering simulation of heat and diffusion, . Replace the second derivative in space by the central formula and step forward in time.
The same discrete Laplacian gave the plate equations of Lectures 12–14.
Where exactly: navigation. GPS gives positions once per second; differences give speed. Inertial sensors (IMU) give acceleration, which is integrated instead (Lecture 20). Fusion filters combine both.
Real-time systems must use backward differences: the next sample has not arrived yet.
Forward series from the table: speed 3.952 m/s and acceleration −3.74 m/s² at s. Central formulas give 3.35 m/s and −2.6 m/s² at 1.3 s: the robot is braking.
Numerical integration. Areas, distances and probabilities from the same kind of tables: trapezoidal, Simpson, Romberg and Gauss.