Section 6.6 Gaussian Quadrature Key Terms: Method of undetermined coefficients Nonlinear systems Gaussian quadrature Error Legendre polynomials Inner product Adapted from http://pathfinder.scar.utoronto.ca/~dyer/csca57/book_p/node44.html
Most of the numerical integration methods described so far are based on a rather simple choice of evaluation points for the function f(x). Namely the points are equispaced. They are particularly suited for regularly tabulated data, such as one might measure in a laboratory, or obtain from computer software designed to produce tables. If one has the freedom to choose the points at which to evaluate f(x), a careful choice can lead to much more accuracy in evaluating the integral in question. In this case we must have an expression (formula) for the integrand f(x). We shall see that this method, called Gaussian or Gauss-Legendre integration, has one significant further advantage in many situations. In the evaluation of an integral on the interval [a, b], it is not necessary to evaluate f(x) at the endpoints, ie. at a or b, of the interval. This will prove valuable when evaluating various improper integrals, such as those with infinite limits. (So Gaussian quadrature formulas are open.) Portions adapted from http://pathfinder.scar.utoronto.ca/~dyer/csca57/book_p/node44.html
Previously we saw that the concept of Newton-Cotes quadrature was developed so that the value of the definite integral is approximated by the quadrature rule The x i are called abscissas and are selected as equally spaced points within the integration interval [a, b]. The weights, w i, are then found by integrating the polynomial which interpolates the integrand at the abscissas. The degree of precision of the resulting rule is n when n is odd and n + 1 when n is even. In the Gaussian quadrature approach to numerical integration, the abscissas and weights are selected so as to achieve the highest possible degree of precision. That means the abscissas and weights are both to be determined. Here we apply the method of undetermined coefficients like we did for some quadrature problems previously, but this time we encounter a nonlinear system to solve for the abscissas and weights.
For determining Gaussian quadrature rules with n > 1, it is to our advantage to replace the general integration interval of [a, b] with a standardized interval, the most common choice for which is [-1, 1]. With such an interval we can exploit the symmetries in the problem to simplify the solution of the nonlinear system of equations for the abscissas and weights. The conversion from the integral to an integral of the form is most easily accomplished by the change of variable The resulting relationship between the two integrals is then
The general case: Given a positive integer n, what is the largest integer k such that there exist abscissas x 1, x 2,..., x n and weights c 1, c 2,..., c n so that for every polynomial f(x) with degree k? We first consider the case n = 2. Determine the largest value of k so that there exist values x 1, x 2 and c 1, c 2 such that is true for all polynomials f(x) with degree k. We proceed by using the method of undetermined coefficients. {Notation: P k is the vector space of all polynomials of degree k or less.}
Since integration is a linear operation and P k is a vector space, we need only investigate this relation on a basis for P k. Let's take the standard basis {1, x, x 2,..., x k } for P k. This basis has k + 1 members; that is, dim(p k ) = k + 1. We look at the following cases: The expressions in (2) and (3) lead to the system of equations which is a nonlinear system with two equations in four unknowns x 1, x 2 and c 1, c 2. We suspect that such a system will have many solutions and that we should choose k so that we have a system with the same number of equations as unknowns. Since dim(p k ) = k + 1, we suspect that k + 1 = 4 = 2n, that is k = 3. Thus we will adjoin two more equations to those in (4) as follows:
We have the nonlinear system From MATLAB we have >> syms c1 c2 x1 x2; >> [Sx1,Sx2,Sc1,Sc2]=solve(c1+c2==2,c1*x1+c2*x2==0,c1*x1^2+c2*x2^2==2/3,c1*x1^3+c2*x2^3 ==0,x1,x2,c1,c2) Sx1 = Sx2 = Sc1 = Sc2 = 3^(1/2)/3-3^(1/2)/3 1 1-3^(1/2)/3 3^(1/2)/3 1 1 This tells us we have two solutions: Note the symmetry in the x-coordinates. Since we are in interval [-1, 1] we choose to use
Thus the Gaussian quadrature rule for the case n = 2 is It can be shown that the error term is Converting this rule back to the more general integration interval [a; b] produces We replace this integral by the approximation plus the error term. 1 So we replace t by - one function evaluation and 3 1 by in the other evaluation. 3
In the error terms we need to apply the chain rule to accommodate the change of variable 4 4 4 d d dx b - a d d b - a d = = ==> = dt dx dt 2 dx dt 2 dx 4 4 5 135 * 2 = 4320 b - a Note the 2 multiplier in front of the square bracket here.
Example: Approximate ln(2) One way to approximate the value of ln(2) is to approximate the value of the integral Using the two-point Gaussian quadrature rule and noting that for this problem a = 1, b = 2 and f(x) = 1/x, we obtain the approximation Even with only two function evaluations, the absolute error in this approximation is 8.394E-4. (ln(2) 0.6931471806)
It is interesting to compare the Trapezoidal rule and the two-point Gaussian rule geometrically, for f(x) over [-1, 1]. Trap line Gaussian line The Gaussian line goes through (-η, f(-η)) and (η, f(η)). Gray is the true area under the curve. Green is the Trapezoidal area. Pink is the Gaussian area.
We can develop composite Gaussian formulas in much the same way a we did for Newton-Cotes. The idea is to divide the interval [a, b] into subintervals of equal length h = (b a)/n and denote the end points of the subintervals by x j = a + jh for j = 1, 2,, n. Apply the basic Gaussian formula on each subinterval [x j-1, x j ]. For the 2-point Gaussian rule we get where a < ξ < b.
Example: Compare the approximation of π using composite Simpson s rule and composite Gaussian 2-point formula to 4 decimal place accuracy. For this we need 6 applications (or 12 subintervals) for Simpson s rule. For the Gaussian formula 5 subintervals are needed. Name of an mfile. SIMPSON 1/3 Rule for Integration The Simpson 1/3 Rule approximation to 1/(1+x^2) over [0,1] is The value of h used is 0.083333. 7.853981600763449e-01 Multiply this by 4 to approximate π. The absolute error is 1.3284E-8 and 13 function evaluations are used. >> y = gq2 ( 'Gaussfun', 0, 1, 5 ) y = 0.785398170446358 Multiply this by 4 to approximate π. The absolute error is 2.8196E-8, which is slightly larger that that obtained by Simpson s rule. But here we use only 10 function evaluations (2 per interval). pi/4 0.785398163397448 In MATLAB
>> help gq2 gq2 approximate the definite integral of an arbitrary function using the composite two-point Gaussian quadrature rule inputs: f a b n output: y calling sequences: y = gq2 ( 'f', a, b, n ) gq2 ( 'f', a, b, n ) string containing name of m-file defining integrand lower limit of integration upper limit of integration number of uniformly sized subintervals into which integration interval is to be divided (the resulting approximation will require 2*n function evaluations) approximate value of the definite integral of f(x) over the interval a < x < b NOTE: if gq2 is called with no output arguments, the approximate value of the definite integral of f(x) over the interval a < x < b will be displayed
Note that for values of n > 2 the method of undetermined coefficients leads to nonlinear systems which are significantly more difficult. An alternate approach uses a collection of orthogonal polynomials known as the Legendre polynomials. (By orthogonal polynomials we mean that a particular integral of the product of any two different polynomials is zero.)
The simplest form of Gaussian Integration is based on the use of an optimally chosen polynomial to approximate the integrand f(x) over the interval [-1, +1]. The details of the determination of this polynomial, meaning determination of the coefficients of x in this polynomial, are beyond the scope of this presentation. The particular points at which to evaluate f(x) are the roots of the Legendre polynomials. It can be shown that the best estimate of the integral is then: where x i is a designated evaluation point, and c i is the weight of that point in the sum. If the number of points at which the function f(x) is evaluated is n, the resulting value of the integral is of the same accuracy as a simple polynomial method (such as Simpson's Rule) using about twice as many quadrature points. Thus the carefully designed choice of function evaluation points in the Gauss-Legendre form results in the same accuracy for about half the number of function evaluations, and thus at about half the computing effort.
Gaussian quadrature formulas are evaluated using abscissas and weights from a table like that included here. The choice of value of n is not always clear, and experimentation is useful to see the influence of choosing a different number of points. When choosing to use n points, we call the method an n-point Gaussian method.
Example: Consider the evaluation of the integral: whose value is 1, as we can obtain by explicit integration. Applying the 2-point Gaussian method we can calculate an approximate value for the integral. The result is 0.998473, which is pretty close to the exact value of one. The calculation is simply: While this example is quite simple, the following table of values obtained for n ranging from 2 to 10 indicates how accurate the estimate of the integral is for only a few function evaluations. The table includes a column of values obtained from Simpson's rule for the same number of function evaluations. The Gauss-Legendre result is correct to almost twice the number of digits as compared to the Simpson's rule result for the same number of function evaluations.