Example 159 consider approximating the integral i f 1

This preview shows page 18 - 20 out of 39 pages.

Example 15.9. Consider approximating the integral I f = 1 0 e x x dx . The integral is well-de fi ned, even though the integrand is unde fi ned for x = 0 and e x x → ∞ as x 0. The fact that it is well-de fi ned can be observed upon using integration by parts, which gives I f = 2( e 1 0 xe x dx ). But let s approximate the given form of I f directly. Using the weighted Gaussian quadrature rule with w ( x ) = 1 x , the function f ( x ) = e x is well approximated by a polynomial. Thus, a weighted Gaussian quadrature suggests itself. For n = 1 we get in this way the value I f a 0 e t 0 + a 1 e t 1 = 2.9245 ... . See Exercise 9. The exact result is 2.9253 ... . So, we obtain three correct decimal digits: not bad for two function evaluations and a singular integrand! This is an example where weighted Gaussian quadrature fares better than composite closed Newton Cotes formulas, due to the singularity at the origin and the large values of the integrand in the immediate neighborhood of the origin. Composite Gaussian formulas As with the other basic rules we saw, the way to use Gaussian quadrature in practice is often as a composite method, as discussed in Section 15.2. However, here there is no apparent trick for saving on function evaluations: the given interval is divided into r subintervals, a = t 0 < t 1 < ··· < t r = b , and the n + 1 Gauss points are scaled and translated into each subinterval to form a set of ( n + 1) r distinct points where the integrand is evaluated. Thus, the distinct points where f gets evaluated are t i , k = t i 1 + t i t i 1 2 ( x k + 1). We have already mentioned in Section 15.1 how the composite midpoint method looks like. For the next ( n = 1) member of the Gaussian quadrature family of rules we have to evaluate the integrand at the points t i 1 + t i 2 ± t i t i 1 2 3 , i = 1, ... , r . (Recall Example 15.7 and verify that you know what the composite rule for n = 2 looks like.) Downloaded 12/08/18 to 132.174.255.3. Redistribution subject to SIAM license or copyright; see
15.3. Gaussian quadrature 459 Let the mesh be uniform, t i = ih , with h = b a r . The error in the obtained composite Gaussian rule is estimated by E n , h ( f ) = ( b a )(( n + 1)!) 4 (2 n + 3)!((2 n + 2)!) 2 f (2 n + 2) ( ξ ) h 2 n + 2 . Counting function evaluations, we see that the two-point composite Gaussian method is com- parable to the composite Simpson method, both in terms of order of accuracy and in terms of number of function evaluations. The Simpson method has the important added simplicity of equal subinter- vals. The Gauss method has a somewhat better error constant, requires one less function evaluation, and, most importantly, shows more flexibility with discontinuities in the integrand. The following, somewhat long, example demonstrates the latter point. Example 15.10. Consider the integral I f = 2 π 0 f ( x ) dx , where f ( x ) = sin( x ), 0 x π / 2, cos( x ), π / 2 < x 2 π .

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture