Numerical Differentiation and Integration
Open in the Padhaiko app4.1 Numerical differentiation
When a function is known only as a discrete table of values (or is too complicated to differentiate analytically), numerical differentiation approximates by differentiating an interpolating polynomial fitted to the tabulated points.
4.1.1 Differentiation using polynomial interpolation formulae for equally spaced intervals
For equally spaced nodes with constant step size , let so that . Applying the chain rule and to Newton's forward, backward, and Stirling's central interpolation polynomials produces the standard differentiation formulas.
Derivatives from Newton's Forward and Backward Formulas
- Using Newton's Forward Difference Formula (best near the beginning of the table, close to , ):
At (), these simplify to:
- Using Newton's Backward Difference Formula (best near the end of the table, close to , ):
At (), these simplify to:
For points near the middle of the table, differentiating Stirling's central difference formula at () gives central formulas with truncation error even from two differences:
4.1.2 Local maxima and minima from equally spaced data
To locate a local maximum or minimum of from an equally spaced table :
- Construct the finite difference table and write Newton's forward (or backward/Stirling) polynomial in terms of .
- Differentiate with respect to and apply the first-derivative stationarity condition:
- Solve this algebraic equation for (retaining up to gives a linear equation in ; retaining up to gives a quadratic equation in ).
- Recover , evaluate using the same interpolation polynomial, and classify the extremum via the second-derivative test:
- local maximum
- local minimum
4.2 Numerical integration
Numerical integration (quadrature) approximates a definite integral when an antiderivative cannot be found analytically or when is known only at discrete points.
4.2.1 Newton Cote’s general quadrature formula
Divide into equal sub-intervals of width with nodes () and values . Substituting Newton's forward difference polynomial into yields the Newton–Cotes general quadrature formula:
Newton–Cotes General Quadrature Formula
Setting and truncating differences above order generates all classical closed Newton–Cotes rules.
4.2.2 Trapezoidal rule, Simpson’s 1/3 and 3/8 rules, Boole’s rule, Weddle’s rule
Applying the basic -panel Newton–Cotes formula repeatedly over sub-intervals of width produces the composite rules:
| Rule | Degree ( Condition) | Composite Formula | Global Error Order | Exact For Degree |
|---|---|---|---|---|
| Trapezoidal | Any | (linear) | ||
| Simpson's | even () | (cubic) | ||
| Simpson's | multiple of | (cubic) | ||
| Boole's Rule | multiple of (for ) | (per -panel) | (quintic) | |
| Weddle's Rule | multiple of (for ) | (per -panel) | (quintic) |
4.2.3 Romberg integration
Romberg integration applies Richardson extrapolation systematically to composite Trapezoidal estimates computed at successively halved step sizes , , , , eliminating leading error terms to achieve high accuracy.
Romberg Integration Table
- First column (Composite Trapezoidal Rule): For row , use panels with :
(Recursive halving shortcut: .)
- Richardson Extrapolation columns ():
- Column () matches composite Simpson's rule with error.
- Column () matches Boole's rule with error.
4.2.4 Gauss-Legendre integration (up to 3-point formula)
Unlike Newton–Cotes rules (which use fixed equally spaced nodes), Gauss–Legendre quadrature chooses both the nodes (roots of Legendre polynomials ) and weights on to maximize the degree of exactness: an -point Gauss–Legendre formula integrates all polynomials up to degree exactly.
To integrate over an arbitrary interval , first map to using the linear transformation:
so that:
| Points () | Nodes () | Weights () | Exact Up to Degree |
|---|---|---|---|
| -point | |||
| -point | |||
| -point | , , | , , |
Worked Out Examples
4.1
From the equally spaced table below, find , , and the value of at which attains a local maximum, along with the maximum value of :
Constructing the forward difference table ():
| — | ||||
| — | — | |||
| — | — | — |
Here .
Computing and using Newton's forward differentiation formulas: With and :
Finding the local maximum:
Substituting the differences:
(We take the positive root inside .) Checking the second derivative:
confirming a local maximum at . Evaluating :
At :
, , and attains a local maximum of at .
4.2
Evaluate using sub-intervals () by:
- Trapezoidal rule
- Simpson's rule
- Simpson's rule
Compare with the exact value .
Tabulating for ():
Applying the three composite quadrature rules:
- Trapezoidal rule:
- Simpson's rule ( is even):
- Simpson's rule ( is a multiple of ):
With exact value :
- Trapezoidal rule:
- Simpson's rule:
- Simpson's rule:
4.3
Use Romberg integration to evaluate up to (using ), and compare with the exact value .
Computing the Trapezoidal estimates : Let on :
- :
- :
- :
Applying Richardson extrapolation:
| () | () | () | |
|---|---|---|---|
| — | — | ||
| — | |||
The Romberg approximation is , agreeing closely with the exact value (error ).
Exercises
Exercise — Numerical Differentiation and Integration
Derive the Trapezoidal rule and Simpson's rule from Newton–Cotes general quadrature formula. Also explain why Gauss–Legendre -point quadrature is exact for polynomials up to degree , whereas a Newton–Cotes -point rule is only exact up to degree (or when is odd).
Deriving Trapezoidal and Simpson's rules from Newton–Cotes: Recall Newton–Cotes general quadrature on :
- Trapezoidal rule (, neglecting and higher):
- Simpson's rule (, neglecting and higher):
(Notice the coefficient vanishes automatically at , giving Simpson's rule cubic exactness!)
Why Gauss–Legendre achieves degree : An -point Newton–Cotes rule fixes equally spaced nodes in advance and solves only for weights , giving degrees of freedom (exactness up to degree , or by symmetry for odd ). In contrast, an -point Gauss–Legendre rule treats both the weights and the node positions as free parameters—providing degrees of freedom, which makes the quadrature exact for all polynomials up to degree .
Setting and in Newton–Cotes general quadrature gives and . Gauss–Legendre -point quadrature optimizes parameters ( nodes and weights), achieving exactness up to degree .
Given the values of below, compute and using Newton's backward difference differentiation formula:
Constructing the backward difference table ():
| — | — | — | ||
| — | — | |||
| — | ||||
At (): .
Applying Newton's backward differentiation formulas at :
At , and (exact ).
Evaluate using:
- Boole's rule with ()
- Weddle's rule with ()
Compare both results with the exact value .
Computing by Boole's rule (): Ordinates at :
Applying Boole's formula:
Computing by Weddle's rule (): Ordinates at :
Applying Weddle's formula:
Compared with :
- Boole's rule ():
- Weddle's rule ():
Use Romberg integration up to to evaluate (exact value ).
Computing the Trapezoidal column ():
- :
- :
- :
Extrapolating columns and :
Romberg integration gives , matching the exact integral to five decimal places.
Evaluate using:
- -point Gauss–Legendre quadrature
- -point Gauss–Legendre quadrature
Compare with the exact value .
Transforming the interval to : With and :
So:
Applying the -point and -point Gauss–Legendre formulas:
- -point formula (, ):
- -point formula (; ):
Compared with :
- -point Gauss–Legendre:
- -point Gauss–Legendre: