Numerical Differentiation and Integration
5.1 Numerical Differentiation
1) Numerical Differentiation
Numerical Differentiation: The approximation of a derivative using function values at a finite set of points.
It is required when a function is given by measured data, tabulated values, or a simulation instead of an explicit formula.
2) Finite Difference
Finite Difference: A difference between function values used to approximate a derivative.
The derivative definition is
Numerical differentiation replaces the limit with a small finite step size .
3) Forward-Difference Formula
Forward Difference: A first-derivative approximation using and .
Its error formula is
where .
Therefore, the truncation error is
The forward difference is a first-order method.
4) Backward-Difference Formula
Backward Difference: A first-derivative approximation using and .
Its truncation error is
Backward differences are useful near the right endpoint of an interval.
5) Centered-Difference Formula
Centered Difference: A first-derivative approximation using points on both sides of .
The error formula is
where .
Therefore, the truncation error is
The centered formula is more accurate than the forward or backward formula for the same step size.
6) Second-Derivative Formula
The three-point centered approximation to the second derivative is
Its error formula is
Therefore, the truncation error is
7) Order of Accuracy
Order of Accuracy: A numerical approximation has order if its truncation error satisfies
This means that, for sufficiently small ,
for some constant independent of .
If is halved, an order- error is approximately reduced by
8) Truncation Error
Truncation Error: The error caused by replacing an exact mathematical process with a finite approximation.
For the centered-difference formula,
Truncation error generally decreases as becomes smaller.
9) Rounding Error in Differentiation
Finite-difference formulas subtract nearly equal function values.
For very small , this causes cancellation and loss of significant digits.
The rounding-error contribution is approximately
Rounding error increases as becomes smaller.
10) Total Differentiation Error
For the centered-difference formula, the total error can be modeled by
The first term is truncation error, and the second is rounding error.
Therefore, decreasing indefinitely does not indefinitely improve accuracy.
11) Optimal Step Size
For the centered-difference approximation, if
the estimated optimal step size is
Ignoring the scale factor, this is approximately
For double precision, this is typically near
12) Richardson Extrapolation
Richardson Extrapolation: A method that combines approximations with different step sizes to cancel the leading error term.
Suppose
Then
Eliminating the term gives
The extrapolated approximation has a higher order than the original formula.
13) Five-Point Centered Difference
Applying extrapolation to the second-order centered difference gives
This formula has truncation error
An equivalent form using points spaced by is
5.2 Newton-Cotes Formulas for Numerical Integration
1) Numerical Integration
Numerical Integration: The approximation of a definite integral using a weighted sum of function values.
A quadrature rule has the form
where:
- are quadrature nodes.
- are quadrature weights.
2) Quadrature
Quadrature: Another name for numerical integration.
Quadrature rules approximate the area under a function using values at selected points.
3) Newton-Cotes Formula
Newton-Cotes Formula: A quadrature formula obtained by integrating an interpolating polynomial through equally spaced nodes.
A closed Newton-Cotes formula includes both endpoints.
An open Newton-Cotes formula excludes the endpoints.
4) Trapezoid Rule
Trapezoid Rule: A quadrature rule obtained by integrating the line through and .
Let
Then
The error is
for some .
The Trapezoid Rule has degree of precision .
5) Simpson’s Rule
Simpson’s Rule: A quadrature rule obtained by integrating the quadratic interpolating polynomial through the endpoints and midpoint.
Let
Then
Equivalently,
The error is
for some .
Simpson’s Rule has degree of precision .
6) Midpoint Rule
Midpoint Rule: An open Newton-Cotes formula that evaluates the function at the interval midpoint.
Its error is
for some .
The Midpoint Rule has degree of precision .
7) Degree of Precision
Degree of Precision: The largest integer such that a quadrature method integrates every polynomial of degree at most exactly.
For example:
- Trapezoid Rule: degree
- Midpoint Rule: degree
- Simpson’s Rule: degree
8) Composite Quadrature
Composite Quadrature: Applying a quadrature rule separately over several subintervals and adding the results.
Composite rules improve accuracy without requiring a single high-degree interpolating polynomial.
9) Composite Trapezoid Rule
Divide into equal subintervals:
Then
The error is
Therefore, the Composite Trapezoid Rule has global error
10) Composite Simpson’s Rule
Divide into equal subintervals:
Then
The error is
Therefore, the Composite Simpson’s Rule has global error
11) Composite Midpoint Rule
Divide into panels of width
Then
Its global error is
5.3 Romberg Integration
1) Romberg Integration
Romberg Integration: A method that applies Richardson extrapolation repeatedly to Composite Trapezoid Rule approximations.
It produces a triangular table of increasingly accurate approximations.
2) First Romberg Column
Let
The first-column value
is the Composite Trapezoid Rule using step size .
The first value is
3) Incremental Trapezoid Update
The next trapezoid approximation can reuse the previous function values:
Only newly introduced midpoint values must be evaluated.
4) Romberg Extrapolation
Higher columns are computed by
where
Equivalently,
5) Romberg Error Order
The first column has error
Successive columns cancel the leading even powers of :
- First column:
- Second column:
- Third column:
- th column:
6) Romberg Stopping Criterion
A common stopping criterion is
The difference between successive diagonal entries estimates convergence.
5.4 Adaptive Quadrature
1) Adaptive Quadrature
Adaptive Quadrature: A numerical integration method that automatically uses smaller subintervals where the integrand is difficult and larger subintervals where it is smooth.
It concentrates computation where the estimated error is largest.
2) Local Error Estimation
Let be a quadrature approximation on .
Split the interval at
and compute
The difference
estimates the local error.
3) Adaptive Trapezoid Rule
The Trapezoid Rule has second-order composite error.
When an interval is divided into two halves, the error is approximately reduced by a factor of .
The difference between the coarse and refined approximations is approximately three times the refined error.
Thus,
Accept the refined result when its estimated error is below the local tolerance.
4) Adaptive Simpson’s Rule
Let
be Simpson’s Rule over the full interval, and let
be the sum of Simpson’s Rule over the two halves.
Because Simpson’s Rule is fourth order,
A common acceptance condition is
A more conservative implementation may use
5) Corrected Simpson Estimate
When the interval is accepted, Richardson correction gives
This is more accurate than using alone.
6) Recursive Subdivision
If the estimated error is too large:
- Divide into and .
- Assign half the tolerance to each subinterval.
- Apply the same test recursively.
- Add the accepted subinterval results.
Adaptive quadrature should include a maximum recursion depth or minimum interval width.
7) Advantages of Adaptive Quadrature
Adaptive quadrature is effective for functions with:
- Localized peaks
- Rapid changes
- High curvature
- Uneven smoothness
- Expensive function evaluations
It avoids wasting evaluations in smooth regions.
5.5 Gaussian Quadrature
1) Orthogonal Functions
Orthogonal Functions: Nonzero functions and satisfying
A set of functions is orthogonal if every distinct pair is orthogonal.
2) Orthogonal Polynomials
Orthogonal Polynomials: Polynomials that form an orthogonal set under an integral inner product.
If
then
forms a basis for the polynomial space of degree at most .
3) Legendre Polynomials
Legendre Polynomials: A sequence of polynomials orthogonal on .
They can be defined by Rodrigues’ formula:
The first Legendre polynomials are
4) Legendre Roots
The degree- Legendre polynomial has distinct roots in
These roots are used as the nodes of Gauss-Legendre Quadrature.
5) Gauss-Legendre Quadrature
Gauss-Legendre Quadrature: A quadrature rule using the roots of a Legendre polynomial as optimally selected nodes.
On ,
where:
- are the roots of .
- are the corresponding quadrature weights.
6) Gaussian Weights
If is the Lagrange basis polynomial associated with node , then
The weights are positive and symmetric.
7) Two-Point Gauss-Legendre Rule
For ,
and
Therefore,
8) Three-Point Gauss-Legendre Rule
For ,
and
Thus,
9) Degree of Precision of Gaussian Quadrature
An -point Gauss-Legendre rule has degree of precision
It integrates every polynomial of degree at most exactly.
This is the highest possible degree of precision for a quadrature rule using nodes.
10) Change of Interval
To transform an integral over to , use
Then
so
The Gaussian approximation becomes
Comparison of Numerical Integration Methods
| Method | Nodes | Degree of Precision | Global Error |
|---|---|---|---|
| Composite Midpoint | Midpoints | 1 | |
| Composite Trapezoid | Equally spaced | 1 | |
| Composite Simpson | Equally spaced | 3 | |
| Romberg | Reused equally spaced nodes | Increasing | in column |
| Adaptive Simpson | Adaptive nodes | 3 locally | Controlled by tolerance |
| -point Gaussian | Legendre roots | Depends on higher derivatives |
Essential Concepts
- Numerical Differentiation: Approximates derivatives using finite function differences.
- Forward Difference: A first-order one-sided derivative formula.
- Centered Difference: A second-order symmetric derivative formula.
- Second-Derivative Difference: Uses three centered function values.
- Order of Accuracy: Describes how quickly truncation error decreases with .
- Truncation Error: Results from replacing an exact process with a finite formula.
- Rounding Error: Grows in differentiation when nearly equal values are subtracted.
- Optimal Step Size: Balances truncation and rounding errors.
- Richardson Extrapolation: Cancels the leading error term using two step sizes.
- Quadrature: Numerical approximation of a definite integral.
- Newton-Cotes Formula: Integrates a polynomial through equally spaced nodes.
- Trapezoid Rule: Integrates a linear interpolant.
- Simpson’s Rule: Integrates a quadratic interpolant.
- Degree of Precision: The highest polynomial degree integrated exactly.
- Composite Rule: Applies a quadrature rule across multiple panels.
- Romberg Integration: Repeatedly extrapolates Composite Trapezoid approximations.
- Adaptive Quadrature: Refines only intervals with large estimated errors.
- Orthogonal Polynomial: Is orthogonal to other basis polynomials under an integral inner product.
- Legendre Polynomial: Provides the nodes for Gauss-Legendre Quadrature.
- Gaussian Quadrature: Achieves degree of precision using nodes.