Numerical differentiation is the process of finding the numerical value of a derivative of a given function at a given point. Computing a derivative from nearby approximate function values can amplify data errors and roundoff error. The choice of step size must balance approximation error against this amplification. Numerical differentiation is implemented as ND[f, x, x0, Scale -> scale] in the Wolfram Language package NumericalCalculus` .
There are many applications where derivatives need to be computed numerically. The simplest approach simply uses the definition of the derivative
|
(1)
|
by evaluating the difference quotient at a small nonzero step .
Nash (1990, p. 219) suggests
as a starting choice for
forward differences in floating-point arithmetic, where
is the machine precision.
Another approach differentiates a Lagrange interpolating polynomial. For distinct nodes ,
,
...,
, let
be the cardinal polynomial
of polynomial degree at most
equal to 1 at
and 0 at the other nodes. Then, for an integer
with
,
|
(2)
|
The approximation is exact for polynomials of polynomial degree at most .
Lyness and Moler (1966) adapt Neville's algorithm
to numerical derivatives. Fornberg (1998) gives recursions
for the corresponding weights on arbitrarily spaced distinct
nodes.
For a real-valued function with a suitable analytic complex extension, complex step differentiation estimates a derivative from the imaginary part of a complex function value, avoiding the subtraction in a real finite difference approximation (Squire and Trapp 1998).
For sufficiently smooth , Richardson extrapolation in
can eliminate successive error terms of the centered estimate
(Ridders 1982).
For
analytic on and inside the circle of radius
centered at
,
the Cauchy integral formula for derivatives
can be evaluated numerically by the periodic trapezoidal
rule. For derivative order
and
samples, this gives
|
(3)
|
where . The choice of radius affects both quadrature
error and roundoff sensitivity (Bornemann 2011, 2013).
Local polynomial least squares fits also give Savitzky-Golay filter estimates of derivatives, with weights computed from a basis of discrete orthogonal polynomials (Gorry 1990).
The available information determines which methods apply. When the operations that compute a function are accessible and differentiable, automatic differentiation applies the chain rule directly. For smooth sampled data, spectral differentiation differentiates a global approximation. The finite element method uses piecewise approximations on a mesh (Komarov et al. 2026).
When samples contain independent additive errors of common variance , the centered finite
difference
acquires error variance
. The variance grows as
decreases even though the truncation error for a sufficiently
smooth function decreases as
, where
denotes big-O notation.
Estimation from noisy samples thus uses assumptions about the underlying signal,
such as smoothness or a model for its evolution (Komarov et al. 2026).
Examples include fitting and differentiating a smoothing spline, or treating the derivative as a hidden component of the state in a Kalman filter or smoother. When the derivative is expected to have jumps, total variation regularization can penalize the sum of absolute differences between consecutive derivative estimates. This favors long runs of nearly constant slope, as in a noisy triangular waveform (Komarov et al. 2026).