f = x² at 3, h = 0.1
(f(3.1) − f(2.9))/0.2 = 6
Exact for quadratics.
Numerical derivatives: and . Both have error of order .
This page is easier if you are comfortable with:
For at , : against the exact (error ). The second derivative: against the exact . For at 2 with : vs the exact 12; the error is .
The error term comes from Taylor expansions of (Taylor series): the odd powers of cancel in the central difference, so the error is , better than the one-sided with error (derivative from first principles). Too small causes rounding errors from subtracting nearly equal numbers.
These formulas are used in difference schemes for differential equations: the second difference is the building block of the five-point stencil and the schemes of explicit heat schemes and the CFL condition. The derivatives approximated are those of sine and powers.
Central differences approximate derivatives from values on either side of a point, with error of order h squared.
The error grows like h², so halving h cuts it by four.
These examples are worked by hand, step by step, so you can compare your own working.
Estimate for with .
Estimate with .
Estimate for with .
A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.
(f(3.1) − f(2.9))/0.2 = 6
Exact for quadratics.
(sin 0.1 − sin(−0.1))/0.2 ≈ 0.99833
True value 1.
≈ 1.00167
True value 1.
O(h²): error ≈ h² f‴/6
sin: 0.00167.
The central difference f′(x) ≈ (f(x + h) − f(x − h))/(2h) has error about h² f‴(x)/6, so halving h cuts the error by about four.
Estimate d/dx x² at x = 3 with h = 0.1.
Estimate d/dx sin x at 0 with h = 0.1 to 5 decimal places.
Find the error for sin x at 0, h = 0.1.
Estimate with h = 0.05 and compare.
(f(x + h) − f(x − h))/h ✗
divide by 2h ✓
The step is 2h wide.
h = 10⁻¹⁶ ✗
rounding error dominates ✓
Use h ≈ 10⁻⁵.
(f(x + h) − f(x))/h ✗
error O(h) not O(h²) ✓
Central is more accurate.
sin in degrees ✗
radians ✓
Use radians.
Try each one on paper, then open the answer. Use the solver above to see the full working.
4
3.01
1.00167
0
0.999983
1.0034
Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.
Solve: …
(f(x + h) − f(x − h))/(2h).
About h² f‴/6.
Yes, O(h²) versus O(h).
Quadratics.
five-point Laplacian stencil.
More in Numerical methods and optimisation and the formula sheets.