Numerical Differentiation
Numerical Differentiation: Forward, Backward, and Central Differences
When a function is only known at discrete points (from a table, an experiment, or a computer program), we cannot use differentiation rules directly. Instead we approximate the derivative using finite differences built from nearby function values.
Secant-line approximations to the tangent slope at x0 using points at x0−h, x0, and x0+h.
Position of a Moving Object over Time
The three basic formulas
- Forward difference: f′(x0)≈hf(x0+h)−f(x0), error O(h)
- Backward difference: f′(x0)≈hf(x0)−f(x0−h), error O(h)
- Central difference: f′(x0)≈2hf(x0+h)−f(x0−h), error O(h2)
For sufficiently smooth functions with equally spaced, sufficiently accurate values, the central difference is usually preferred when both neighbours are available and truncation error dominates noise and roundoff, because its truncation error is O(h2): in that regime halving h roughly quarters the error, instead of only halving it.
The qualifications matter. Smoothness and equal spacing are what make the O(h2) term the right description; with noisy readings, or with h driven very small in floating-point arithmetic, subtractive cancellation can swamp that term so that a larger h does better.
And at one particular h a one-sided formula can simply happen to be closer: for f(x)=x3 sampled at x0=−h/3, the forward difference is exact while the central difference is off by h2.
Worked example
Let f(x)=x3, x0=2, h=0.1. Then f(2.1)=9.261, f(1.9)=6.859, and f(2)=8.
Central difference: 0.29.261−6.859=12.01, very close to the exact value f′(2)=12. A forward difference gives 0.19.261−8=12.61, noticeably less accurate for the same h.
Using the data in the graph, estimate the velocity at t=1.0 s with the forward difference formula and h=0.5 s, given s(1.0)=2.5 m and s(1.5)=4.1 m. Give your answer in m/s.
Secant-line approximations to the tangent slope at x0 using points at x0−h, x0, and x0+h.
Position of a Moving Object over Time
Using the data shown in the graph, estimate the instantaneous velocity at t=1.5 s with the central difference formula and h=0.5 s, using s(1.0)=2.5 m and s(2.0)=6.0 m.
Secant-line approximations to the tangent slope at x0 using points at x0−h, x0, and x0+h.
Position of a Moving Object over Time