f(x) = 1 implies 2 = 2A1 + A2 f(x) = x implies 0 = A1x1 - A1x1 = 0 (automatic) f(x) = x2 implies f(x) = x3 implies 0 = A1x31 - A1x31 = 0 (automatic) f(x) = x4 implies
At this point we have three equations in the three unknowns A1, A2, and x1. The last two equations require that x21 = 3/5, A1 = 5/9 and the first that A2 = 8/9. To find the
error, we try f(x) = x5 implies 0 = A1x 5 1 - A1x 5 1 + E(x 5 ) = E(x5). This implies that d > 5. Finally
f(x) = x6 implies
This says that d = 5 and c = Collecting the results,
On [a, b] the resulting quadrature rule is called the three-point Gaussian quadrature formula,
(5.15) and its error is
(5.16)
See Figure 5.3 for an illustration. n
For larger N the method of undetermined coefficients is impractical for deriving Gaussian quadrature rules. Besides, the questions of the existence of formulas and the best possible degree of precision are left open in this approach. Gauss used the theory of orthogonal polynomials to answer these questions. We cannot develop the theory here (see [8, pp. 327-331]), but it is possible to see how high degrees of precision can
Figure 5.3 Three-point Gaussian quadrature.
be achieved. With reasonable conditions on w(x) and [a,b], it is known that there is a sequence of polynomials θN+1 (x), N = 0, 1, . . . , such that θN+1 (x) is of degree N and
(5.17) When w(x) = 1, a = -1, and b = 1, these polynomials are the Legendre polynomials (see [8, p. 202]). It is also known that the N distinct roots of θN+1 (x) are real and lie in
(a, b). Suppose that an interpolatory quadrature formula (5.2) is based on interpolation at the roots of θN+1 (x). If f(x) is any polynomial of degree 2N - 1, it can be written
as
f(x) = q(x)θθN+l (x) + r(x),
where the quotient q(x) and remainder r(x) polynomials are of degree at most N - 1. Then
where the first integral vanishes because of (5.17). For any choice of the nodes {xi} ,
the formula of (5.2) integrates a polynomial of degree N exactly, so
5.1 BASIC QUADRATURE RULES 181
Now we use the fact that the xi are roots of θn(x) to see that
Since any polynomial f(x) of degree 2N - 1 is integrated exactly, this formula has a degree of precision that is at least 2N - 1.
There are computationally convenient ways to derive Gaussian quadrature rules, and formulas may be found in specialized books. Gaussian formulas are valuable be- cause they provide the highest degree of precision for the number of values of f(x). An important fact about Gaussian formulas is that the Ai are all positive. As discussed
in connection with the error bounds, this means that we can use formulas of a very high degree of precision, even for integrands that are not smooth. Gaussian formulas incor- porating weight functions are especially valuable tools for dealing with integrands that are singular and intervals that are infinite. Whether or not there is a weight function, the nodes of a Gaussian formula all lie in the interior of [a, b]. This means that the formula does not use f(a) or f(b). We shall see that this is quite helpful in dealing with singular integrands.
So far we have been considering procedures based on approximating f(x) over the whole interval [a,b]. Just as with polynomial interpolation, the error depends strongly on the length of the interval. This suggests that we break up the interval and so approx- imate the function by a piecewise polynomial function rather than a single polynomial. The simplest approach is to split the interval into pieces specified in advance. If we partition [a,b] into a = x1 < x2 < ··· < xn+1 = b, then
and we can apply standard quadrature rules to each of the n integrals. The resulting formula is known as a composite or compound rule. Traditionally the {xi} have been
chosen to be equally spaced in [a,b] and the same formula used on each piece, but this is not necessary.
Example 5.5. Composite Trapezoid Rule. The composite trapezoid rule approxi-
mates I = by splitting [a,b] into n pieces of length h = (b - a)/n and apply-
ing the trapezoid rule to each piece. With the definition xi = a + ih, this is
which simplifies to
Figure 5.4 illustrates the composite trapezoid rule. n
An ingenious use of repeated integration by parts establishes the Euler-Maclaurin sum formula. It states that if f(2v)(x) is continuous on [a,b], then
Figure 5.4 Composite trapezoid rule.
for some x in [a,b]. The coefficients B2k appearing here are known as the Bernoulli numbers. The first few terms of the error expansion are
The basic trapezoid rule applied to an interval of length h has an error that goes to zero like h3. When the n = 1/h terms are combined, the error of the approximation to the integral goes to zero like h2. However, notice that if it should happen that f(1)(b) = f(1)(a), the formula is more accurate than usual. If in addition other derivatives have the same values at the ends of the interval, the formula is still more accurate. When integrating a periodic function over a multiple of a period, all the derivatives at the ends of the interval are equal and this formula is extraordinarily accurate. In fact, if the periodic function is analytic, so that it has derivatives of all orders, Tn I faster
than any power of h! Although rather special, this is extremely important in the context of Fourier analysis.
The error of Tn can be estimated by comparing it to the more accurate result T2n obtained by halving each subinterval. A convenient way to evaluate the formula is
where
It is important to note that all the evaluations of f made in forming Tn are reused in
T2n.
There is a way of exploiting the error expansion of the composite trapezoid rule due to Romberg that is popular for general integrands. The idea is to combine Tn and
5.1 BASIC QUADRATURE RULES 183
T2n in such a way as to obtain a higher order result. According to the error expansion,
A little manipulation then shows that
The formula
is of higher order than each of the individual formulas. As it turns out, this formula is the composite Simpson’s rule. Romberg developed a computationally convenient way of successively combining results so as to increase the order by two with each computation of a composite trapezoid rule. The process is called extrapolation.
Romberg integration can be very effective. It adapts the order of the method to the problem. It does, however, depend on the integrand being smooth throughout the interval. Also, it evaluates at the ends of the interval, which is sometimes inconvenient. MATHCAD uses Romberg integration for quadrature. If there is a singularity at an end of an interval or if the process does not converge, the code switches to a variant based on the midpoint rule that does not evaluate at the ends of the intervals and divides
intervals by 3 rather than 2. n
E X E R C I S E S
5.1 Use the method of undetermined coefficients to derive Newton’s
Calculate A1, A2, A3, A4, d, and c in the usual manner.
5.2 Use the method of undetermined coefficients to find the two-point Gaussian quadrature formula with its as- sociated error. Begin with
and calculate A1 and x1 in the usual manner. Assum-
ing E(f) = cf(d+1)(ξ), find d and c. What is the cor- responding formula and associated error on the gen- eral interval [a,b]?
5.3 Implement the composite trapezoid rule and apply it to
Of course, you must choose h small enough that sam- ples are taken in each period. Approximate the inte- gral for a number of values of h that tend to 0. Accord- ing to the theory of Example 5.5, the approximations Tn ought to converge extremely fast. Is that what you find?