4.14 Gaussian Integration
4.14 Gaussian Integration
14 Gaussian Integration
Gaussian Integration Formulas
b
Newton-Cotes formulas for approximating ∫ f (x) dx work best if f(x) is a smooth function, such as a polynomial. This is also true for Gaussian quadrature. However, Gaussian formulas are also good at estimating
a
b
∫ w (x) f (x) dx
a
(6.15)
1 ∞
where w(x), called the weighting function, can contain singularities, as long as they are integrable. An example of such integral is ∫ 2
(1 + x ) ln x dx . Sometimes infinite limits, as in ∫ e
−x
sin x dx , can also be
0 0
accommodated.
(6.16)
where, as before, I represents the approximation to the integral in Eq. (6.15). The difference lies in the way that the weights Ai and nodal abscissas xi are determined. In Newton-Cotes integration, the nodes were evenly
spaced in (a, b) (i.e., their locations were predetermined). In Gaussian quadrature the nodes and weights are chosen so that Eq. (6.16) yields the exact integral if f(x) is a polynomial of degree 2n + 1 or less; that is,
(6.17)
One way of determining the weights and abscissas is to substitute P0(x) = 1, P1(x) = x, . . . , P2n+1(x) = x2n+1 in Eq. (6.17) and solve the resulting 2n + 2 equations
for the unknowns Ai and xi.
As an illustration , let w(x) = e−x, a = 0, b = ∞, and n = 1. The four equations determining x0, x1, A0, and A1 are as follows:
The solution is
Because of the nonlinearity of the equations, this approach does not work well for large n. Practical methods of finding xi and Ai require some knowledge of orthogonal polynomials and their relationship to Gaussian
quadrature. There are, however, several “classical” Gaussian integration formulas for which the abscissas and weights have been computed with great precision and then tabulated. These formulas can be used without
knowing the theory behind them because all one needs for Gaussian integration are the values of xi and Ai.
Here we list some classical Gaussian integration formulas. The tables of nodal abscissas and weights, covering n = 1 to 5, have been rounded off to six decimal places. These tables should be adequate for hand
computation, but in programming, you may need more precision or a larger number of nodes. In that case, you should consult other references or use a subroutine to compute the abscissas and weights within the
integration program.
has the form E = K(n) f(2n+2)(c), where a < c < b (the value of c is unknown; only its bounds are given). The expression for K(n) depends on the particular quadrature being used. If the derivatives of f(x) can be evaluated,
the error formulas are useful in estimating the error bounds.
Gauss-Legendre Quadrature
(6.26)
Gauss-Legendre quadrature is the most often used Gaussian integration formula. As seen in Table 6.3, the nodes are arranged symmetrically about ξ = 0, and the weights associated with a symmetric pair of nodes are
equal. For example, for n = 1 we have ξ0 = −ξ1 and A0 = A1. The truncation error in Eq. (6.26) is
(6.27)
Table 6.3. Nodes and weights for Gauss–Legendre quadrature.
b
To apply the Gauss-Legendre quadrature to the integral ∫ f (x) dx , we must first map the integration range (a, b) into the “standard” range (−1, 1˙). We can accomplish this by the transformation
(6.28)
(6.29)
where the abscissas xi must be computed from Eq. (6.28). The truncation error here is
(6.30)
Gauss-Chebyshev Quadrature
(6.31)
Note that all the weights are equal: Ai = π/ (n + 1). The abscissas of the nodes, which are symmetric about x = 0, are given by
(6.32)
(6.33)
Gauss-Laguerre Quadrature
(6.34)
Table 6.4. Nodes and weights for Gauss–Laguerre quadrature (Multiply
(6.35)
Gauss-Hermite Quadrature
(6.36)
Table 6.5. Nodes and weights for Gauss–Hermite quadrature (Multiply
(6.37)
Gauss Quadrature with Logarithmic Singularity
Table 6.6. Nodes and weights for quadrature with a logarithmic singularity (Multiply
(6.39)
where k(1) = 0.00 285, k(2) = 0.000 17, and k(3) = 0.000 01.
Illustrative Example:
3
1
Evaluate ∫ 2
(1 − x )
2
dx as accurately as possible with Gaussian integration.
−1
Solution. Because the integrand is smooth and free of singularities, we could use the Gauss-Legendre quadrature. However, the exact integral can be obtained with the Gauss-Chebyshev formula. We write
The numerator f(x) = (1 − x2)2 is a polynomial of degree four so that Gauss-Chebyshev quadrature is exact with three nodes.
The abscissas of the nodes are obtained from Eq. (6.32). Substituting n = 2, we get
Therefore,
and Eq. (6.31) yields
Illustrative Example:
0.5
Use Gaussian integration to evaluate ∫ cos πx ln x dx .
The first integral on the right-hand-side, which contains a logarithmic singularity at x = 0, can be computed with the special Gaussian quadrature in Eq. (6.38). Choosing n = 3, we have
Thus
The second integral is free of singularities so that it can be evaluated with the Gauss-Legendre quadrature. Choosing n = 3, we have
from which
Therefore
Illustrative Example:
Evaluate as accurately as possible
Solution. In its present form, the integral is not suited to any of the Gaussian quadratures listed in this section. But using the transformation
x = t2
dx = 2t dt
which can be evaluated exactly with the Gauss-Hermite formula using only two nodes (n = 1). Thus
F = A0(t20 + 3) + A1(t21 + 3)
= 6. 203 59
Illustrative Example:
3
Evaluate numerically ∫ , where f(x) is represented by the following unevenly spaced data:
f (x) dx
1.5
Knowing that the data points lie on the curve f(x) = − cos x, evaluate the accuracy of the solution.
3 3
Solution. We approximate f(x) by the polynomial P5(x) that intersects all the data points and then evaluate with ∫ f (x) dx ≈ ∫ P5 (x) dx with the Gauss-Legendre formula. Because the polynomial is of degree
1.5 1.5
From Eq. (6.28) and Table 6.6, we obtain the abscissas of the nodes
We now compute the values of the interpolant P5(x) at the nodes. The results are
P5(x0) = 0.098 08
P5(x1) = 0.628 16
P5(x2) = 0.952 16
we g e t
I = 0.75 [0.555 556(0.098 08) + 0.888 889(0.628 16) + 0.555 556(0.952 16)]
= 0.856 37
3
Comparison with −∫ cos (x) dx = 0.85638 shows that the discrepancy is within the
1.5
roundoff error.
Reference:
Kiusalaas, J. (2013). Numerical Methods in Engineering with Python 3. USA: Cambridge University Press.