Work out numerical differentiation instantly with clear inputs, formula shown and shareable results.
The forward difference has error of order h, while the central difference cancels the leading error term and achieves order h². The second derivative uses the symmetric three-point stencil.
Central difference
f'(x) ≈ [f(x + h) − f(x − h)] / (2h), error O(h²)
Second derivative
f''(x) ≈ [f(x + h) − 2f(x) + f(x − h)] / h²
The central difference gives 12.0001 against the exact 12, while the forward difference gives 12.0601.
Subtracting nearly equal values loses precision, so very small h amplifies rounding error. There is an optimal middle ground.