Numerical Differentiation and Integration
Numerical Differentiation
The derivative represents the rate of change of a dependent variable
There are three basic ways to estimate derivatives: Forward, Backward and Center finite divided difference All based on the Taylor Series
Another form of this result is the following, where
Rearranging this last equation gives
We will estimate the derivative by dropping the last term. If we can bound the second derivative by some constant, then this last term is
Thus,
This formula is called the first forward divide difference formula and the error in this formula is of order
The error in this approximating is due to truncation of the last term (the second derivative term).
The truncation error can be made small by making
The error in calculation for small
EXAMPLE:
use first forward divide difference formula with
SOLUTION:
the error is
Compare this to the error predicted by the formula, which is
More precise solution
Consider the Taylor Series
Rearranging this last equation gives
Or,
This is called the backward divide difference formula for
Consider the Taylor series expansions for the forward and backward approximations, extended to the degree 3 terms:
If we subtract these two and solve for
THEOREM Generalized intermediate value theorem
Let
Based on Generalized intermediate value theorem, we have
where
This is called the centered divide difference formula for
EXAMPLE
use centered divide difference formula with
SOLUTION:
the error is
Second derivative
Consider the Taylor series expansions for the forward and backward approximations, extended to the degree 4 terms:
If we add these two and solve for
Try to Improve
The forward difference formula for
Consider again the Taylor expansions:
Let
where
Also,
We can use
Note: This approximation for
Richardson Extrapolation
We can use the Richardson method to increase the accuracy of numerical estimates to any series-based quantity. Suppose we want to calculate some quantity
Let
THEOREM: (Richardson Extrapolation).
There are constants
COROLLARY:
EXAMPLE:
Consider
Then, we compute
| 0 | 1 | 2 | |
|---|---|---|---|
| 0 | 0.333339506181068 | ||
| 1 | 0.333334876543723 | 0.333333333331274 | |
| 2 | 0.333333719135820 | 0.333333333333186 | 0.333333333333313 |
Numerical Integration
Trapezoidal rule
The need often arises for evaluating the definite integral of a function that has no explicit antiderivative or whose antiderivative is not easy to obtain. In this section, we will discuss some numerical method to approximating
Let
Integrating both sides on the interval of interest
Computing the first integral gives
where we have defined
The error term is
where
Simpson Rule
We replace degree 1 interpolant by parabola.
Integrating gives
where
where
The error term can be computed (proof omitted) as
for some
Simpson’s Rule
where
EXAMPLE
Apply the Trapezoid rule and Simpson’s rule to approximate
and find an upper bound for the error in your approximations.
SOLUTION
The error for the Trapezoid rule is
In other words,
The error for the Simpson’s rule is
In other words,
The integral can be computed exactly by using integration by parts:
The Trapezoid rule and Simpson’s rule error bounds are both consistent with this result.
Composite Trapezoidal Rule
Consider an evenly spaced grid
Along the horizontal axis, where
Assuming that
The error term can be written
Since
Composite Trapezoid Rule
where
Consider an evenly spaced grid
Along the horizontal axis, where
Composite Simpson’s Rule
Consider an evenly spaced grid
Along the horizontal axis, where
This time, the overlapping is over even-numbered
The error term can be written
Since
Composite Simpson’s Rule
where
EXAMPLE
Carry out four-panel approximations of
Using the composite Trapezoid rule and composite Simpson’s rule.
SOLUTION For composite Trapezoid rule on
The error is at most
For four-panel Simpson’s rule set
The error is at most
EXAMPLE
Find the number of panels
within six correct decimal places.
SOLUTION
We require the error to satisfy
Since the fourth derivative of
or
Romberg integration
In this section, let’s use the Richardson Extrapolation technique to improve integral approximations.
Consider the Trapezoidal Rule using
We know that this approximation has error
This is exactly the kind of expression we had for Richardson Extrapolation. Let
Compute the table of values:
This is called Romberg Integration
EXAMPLE
Approximate
SOLUEION
| Trapezoid | Simpson's | ||
|---|---|---|---|
| 0.3466 | |||
| 0.3760 | 0.3858 | ||
| 0.3837 | 0.3863 | 0.3863 | |
| error | |||