Chapter 07.05 Gauss Quadrature Rule of Integration

After reading this chapter, you should be able to:

1. derive the Gauss quadrature method for integration and be able to use it to solve problems, and 2. use Gauss quadrature method to solve examples of approximate integrals.

What is integration? Integration is the process of measuring the area under a function plotted on a graph. Why would we want to integrate a function? Among the most common examples are finding the velocity of a body from an acceleration function, and displacement of a body from a velocity function. Throughout many engineering fields, there are (what sometimes seems like) countless applications for integral calculus. You can read about some of these applications in Chapters 07.00A-07.00G. Sometimes, the evaluation of expressions involving these integrals can become daunting, if not indeterminate. For this reason, a wide variety of numerical methods has been developed to simplify the integral. Here, we will discuss the Gauss quadrature rule of approximating integrals of the form b I   f xdx a where f (x) is called the integrand, a  lower limit of integration b  upper limit of integration

07.05.1 07.05.2 Chapter 07.05

Gauss Quadrature Rule Background: To derive the trapezoidal rule from the method of undetermined coefficients, we approximated b f (x)dx  c f (a)  c f (b)  1 2 (1) a Let the right hand side be exact for integrals of a straight line, that is, for an integrated form of b a  a x dx   0 1  a So b b  x 2  a  a x dx  a x  a   0 1   0 1  a  2  a  b 2  a 2     a0 b  a a1   (2)  2  But from Equation (1), we want b a  a x dx  c f (a)  c f (b)   0 1  1 2 (3) a to give the same result as Equation (2) for f (x)  a0  a1 x . b a  a x dx  c a  a a  c a  a b   0 1  1  0 1  2  0 1  a

 a0 c1  c2  a1 c1a  c2b (4) Hence from Equations (2) and (4),  b 2  a 2    a0 b  a a1   a0 c1  c2  a1 c1a  c2b  2 

Since a0 and a1 are arbitrary constants for a general straight line

c1  c2  b  a (5a) b 2  a 2 c a  c b  (5b) 1 2 2 Multiplying Equation (5a) by a and subtracting from Equation (5b) gives b  a c  (6a) 2 2

Substituting the above found value of c2 in Equation (5a) gives b  a c1  2 (6b) Therefore Gauss Quadrature Rule 07.05.3

b f (x)dx  c f (a)  c f (b)  1 2 a b  a b  a  f (a)  f (b) (7) 2 2

Derivation of two-point Gauss quadrature rule Method 1: The two-point Gauss quadrature rule is an extension of the trapezoidal rule approximation where the arguments of the function are not predetermined as a and b , but as unknowns x1 and x2 . So in the two-point Gauss quadrature rule, the integral is approximated as b I   f (x)dx a

 c1 f (x1 )  c2 f (x2 )

There are four unknowns x1 , x2 , c1 and c2 . These are found by assuming that the formula gives exact results for integrating a general third order polynomial, 2 3 f (x)  a0  a1 x  a2 x  a3 x . Hence b b f (x)dx  a  a x  a x 2  a x 3 dx    0 1 2 3  a a b  x 2 x3 x 4   a0 x  a1  a2  a3  2 3 4   a  b 2  a 2   b3  a 3   b 4  a 4         a0 b  a a1    a2    a3   (8)  2   3   4  The formula would then give b f (x)dx  c f (x )  c f (x )   1 1 2 2 a 2 3 2 3 c1 a0  a1x1  a2 x1  a3 x1  c2 a0  a1x2  a2 x2  a3 x2  (9) Equating Equations (8) and (9) gives  b2  a 2   b3  a 3   b4  a 4  a0 b  a  a1   a2    a3    2   3   4  2 3 2 3  c1 a0  a1x1  a2 x1  a3 x1  c2 a0  a1x2  a2 x2  a3 x2   a c  c  a c x  c x  a c x 2  c x 2  a c x 3  c x 3 0  1 2  1  1 1 2 2  2  1 1 2 2  3  1 1 2 2  (10)

Since in Equation (10), the constants a0 , a1 , a2 , and a3 are arbitrary, the coefficients of a0 , a1 , a2 , and a3 are equal. This gives us four equations as follows.

b  a  c1  c2 07.05.4 Chapter 07.05

b 2  a 2  c x  c x 2 1 1 2 2 b3  a 3  c x 2  c x 2 3 1 1 2 2 b 4  a 4  c x 3  c x 3 (11) 4 1 1 2 2

Without proof (see Example 1 for proof of a related problem), we can find that the above four simultaneous nonlinear equations have only one acceptable solution b  a c  1 2 b  a c  2 2  b  a  1  b  a x1       2  3  2  b  a  1  b  a x2      (12)  2  3  2

Hence b f (x)dx  c f x  c f x  1  1  2  2  a b  a  b  a  1  b  a  b  a  b  a  1  b  a   f       f      (13) 2  2  3  2  2  2  3  2 

Method 2: We can derive the same formula by assuming that the expression gives exact values for the b b b b individual integrals of 1dx,  xdx,  x 2dx, and  x 3dx . The reason the formula can also be a a a a derived using this method is that the linear combination of the above integrands is a general 2 3 third order polynomial given by f (x)  a0  a1 x  a2 x  a3 x . These will give four equations as follows b 1dx  b  a  c  c  1 2 a b b2  a 2 xdx   c x  c x  1 1 2 2 a 2 b b3  a 3 x 2dx   c x 2  c x 2  1 1 2 2 a 3 Gauss Quadrature Rule 07.05.5

b b4  a 4 x3dx   c x 3  c x 3  1 1 2 2 (14) a 4 These four simultaneous nonlinear equations can be solved to give a single acceptable solution b  a c  1 2 b  a c  2 2  b  a  1  b  a x1       2  3  2  b  a  1  b  a x2      (15)  2  3  2

Hence b b  a  b  a  1  b  a  b  a  b  a  1  b  a       f (x)dx  f       f      (16) a 2  2  3  2  2  2  3  2  Since two points are chosen, it is called the two-point Gauss quadrature rule. Higher point versions can also be developed.

Higher point Gauss quadrature formulas For example b f (x)dx  c f (x )  c f (x )  c f (x )  1 1 2 2 3 3 (17) a is called the three-point Gauss quadrature rule. The coefficients c1 , c2 and c3 , and the function arguments x1 , x2 and x3 are calculated by assuming the formula gives exact expressions for integrating a fifth order polynomial b a  a x  a x 2  a x3  a x 4  a x 5 dx   0 1 2 3 4 5  . a General n -point rules would approximate the integral b f (x)dx  c f (x )  c f (x )  ......  c f (x )  1 1 2 2 n n (18) a

Arguments and weighing factors for n-point Gauss quadrature rules In handbooks (see Table 1), coefficients and arguments given for n -point Gauss quadrature rule are given for integrals of the form 1 n g(x)dx  c g(x )   i i (19) 1 i1

Table 1 Weighting factors c and function arguments x used in Gauss quadrature formulas 07.05.6 Chapter 07.05

Weighting Function Points Factors Arguments

c1  1.000000000 x1  0.577350269

c2  1.000000000 x2  0.577350269

2 c1  0.555555556 x1  0.774596669

c2  0.888888889 x2  0.000000000

c3  0.555555556 x3  0.774596669 3

c1  0.347854845 x1  0.861136312

c2  0.652145155 x2  0.339981044

c3  0.652145155 x3  0.339981044 4 c4  0.347854845 x4  0.861136312

c1  0.236926885 x1  0.906179846

c2  0.478628670 x2  0.538469310

c3  0.568888889 x3  0.000000000 5 c4  0.478628670 x4  0.538469310

c5  0.236926885 x5  0.906179846

c1  0.171324492 x1  0.932469514

c2  0.360761573 x2  0.661209386

c3  0.467913935 x3  0.238619186 6 c4  0.467913935 x4  0.238619186

c5  0.360761573 x5  0.661209386

c6  0.171324492 x6  0.932469514

1 b So if the table is given for  g(x)dx integrals, how does one solve  f (x)dx ? 1 a The answer lies in that any integral with limits of a, b can be converted into an integral with limits 1, 1. Let x  mt  c (20) If x  a, then t  1 Gauss Quadrature Rule 07.05.7

If x  b, then t  1 such that a  m(1)  c b  m(1)  c (21) Solving the two Equations (21) simultaneously gives b  a m  2 b  a c  (22) 2 Hence b  a b  a x  t  2 2 b  a dx  dt 2 Substituting our values of x and dx into the integral gives us b 1  b  a b  a  b  a  f (x)dx   f  x   dx (23) a 1  2 2  2

Example 1

1 For an integral  f (x)dx, show that the two-point Gauss quadrature rule approximates to 1 1 f (x)dx  c f (x )  c f (x )  1 1 2 2 1 where

c1  1

c2  1 1 x1   3 1 x2  3 Solution Assuming the formula 1 f (x)dx  c f x  c f x  1  1  2  2  (E1.1) 1 1 1 1 1 gives exact values for integrals 1dx,  xdx,  x 2 dx, and  x3dx . Then 1 1 1 1 1 1dx  2  c  c  1 2 (E1.2) 1 07.05.8 Chapter 07.05

1 xdx  0  c x  c x  1 1 2 2 (E1.3) 1 1 2 x 2 dx   c x 2  c x 2  1 1 2 2 (E1.4) 1 3 1 x 3dx  0  c x 3  c x 3  1 1 2 2 (E1.5) 1 2 Multiplying Equation (E1.3) by x1 and subtracting from Equation (E1.5) gives 2 2 c2 x2 x1  x2  0 (E1.6) The solution to the above equation is

c2  0, or/and

x2  0, or/and

x1  x2 , or/and

x1  x2 .

I. c2  0 is not acceptable as Equations (E1.2-E1.5) reduce to c1  2, c1 x1  0, 2 c x 2  , and c x3  0 . But since c  2 , then x  0 from c x  0 , but x  0 1 1 3 1 1 1 1 1 1 1 2 conflicts with c x 2  . 1 1 3

II. x2  0 is not acceptable as Equations (E1.2-E1.5) reduce to c1  c2  2 , c1 x1  0, 2 c x 2  , and c x3  0 . Since c x  0 , then c or x has to be zero but this violates 1 1 3 1 1 1 1 1 1 2 c x 2   0 . 1 1 3

III. x1  x2 is not acceptable as Equations (E1.2-E1.5) reduce to c1  c2  2 , 2 c x  c x  0, c x 2  c x 2  , and c x 3  c x 3  0 . If x  0 , then c x  c x  0 1 1 2 1 1 1 2 1 3 1 1 2 1 1 1 1 2 1

gives c1  c2  0 and that violates c1  c2  2 . If x1  0 , then that violates 2 c x 2  c x 2   0 . 1 1 2 1 3

That leaves the solution of x1  x2 as the only possible acceptable solution and in fact, it does not have violations (see it for yourself)

x1  x2 (E1.7) Substituting (E1.7) in Equation (E1.3) gives

c1  c2 (E1.8) From Equations (E1.2) and (E1.8),

c1  c2  1 (E1.9) Equations (E1.4) and (E1.9) gives 2 x 2  x 2  (E1.10) 1 2 3 Gauss Quadrature Rule 07.05.9

Since Equation (E1.7) requires that the two results be of opposite sign, we get 1 x1   3 1 x2  3 Hence 1 f (x)dx  c f (x )  c f (x )  1 1 2 2 (E1.11) 1  1   1   f    f    3   3 

Example 2

b For an integral  f (x)dx, derive the one-point Gauss quadrature rule. a Solution The one-point Gauss quadrature rule is b f (x)dx  c f x  1  1  (E2.1) a 1 1 Assuming the formula gives exact values for integrals 1dx, and  xdx 1 1 b 1dx  b  a  c  1 a b b 2  a 2 xdx   c x  1 1 (E2.2) a 2

Since c1  b  a, the other equation becomes b 2  a 2 (b  a)x  1 2 b  a x  (E2.3) 1 2 Therefore, one-point Gauss quadrature rule can be expressed as b  b  a   f (x)dx  (b  a) f   (E2.4) a  2 

Example 3 What would be the formula for b f (x)dx  c f (a)  c f (b)  1 2 a 07.05.10 Chapter 07.05

b a x  b x 2 dx, if you want the above formula to give you exact values of   0 0  that is, a linear a combination of x and x 2 . Solution If the formula is exact for a linear combination of x and x 2 , then b b 2  a 2 xdx   c a  c b  2 1 2 a b b3  a 3 x 2dx   c a 2  c b 2  1 2 (E3.1) a 3 Solving the two Equations (E3.1) simultaneously gives b 2  a 2     a b  c1  2  2 2      3 3  a b  c 2  b  a   3  1  ab  b 2  2a 2 c   1 6 a 1 a 2  ab  2b 2 c   (E3.2) 2 6 b So b 1  ab  b 2  2a 2 1 a 2  ab  2b 2  f (x)dx   f (a)  f (b) (E3.3) a 6 a 6 b Let us see if the formula works. 5 Evaluate  2x 2  3xdx using Equation(E3.3) 2 5 2x 2  3x dx  c f (a)  c f (b)    1 2 2 1  (2)(5)  52  2(2)2 1 22  2(5)  2(5) 2   2(2)2  3(2) [2(5) 2  3(5)] 6 2 6 5  46.5 5 The exact value of  2x 2  3xdx is given by 2 5 3 2 5 2 2x 3x   2x  3xdx     2  3 2  2  46.5 Any surprises? 5 Now evaluate  3dx using Equation (E3.3) 2 Gauss Quadrature Rule 07.05.11

5 3dx  c f (a)  c f (b)  1 2 2 1  2(5)  52  2(2) 2 1 22  2(5)  2(5) 2   (3)  (3) 6 2 6 5  10.35 5 The exact value of  3dx is given by 2 5 3dx 5   3x2 2  9 Because the formula will only give exact values for linear combinations of x and x 2 , it does 5 not work exactly even for a simple integral of  3dx . 2

Do you see now why we choose a0  a1x as the integrand for which the formula b f (x)dx  c f (a)  c f (b)  1 2 a gives us exact values?

Example 4 Use two-point Gauss quadrature rule to approximate the distance covered by a rocket from t  8 to t  30 as given by 30  140000   x   2000ln   9.8t dt 8  140000  2100t   Also, find the absolute relative true error. Solution First, change the limits of integration from 8, 30 to 1, 1 using Equation(23) gives 30 30  8 1  30  8 30  8   f (t)dt   f  x  dx 8 2 1  2 2  1  11 f 11x 19dx 1 Next, get weighting factors and function argument values from Table 1 for the two point rule,

c1  1.000000000 .

x1  0.577350269

c2  1.000000000

x2  0.577350269 Now we can use the Gauss quadrature formula 07.05.12 Chapter 07.05

1 11 f 11x 19 dx  11 c f 11x 19  c f 11x 19     1  1  2  2  1  11 f 11(0.5773503) 19 f 11(0.5773503) 19  11 f (12.64915)  f (25.35085)  11(296.8317)  (708.4811)  11058.44 m since  140000  f (12.64915)  2000ln   9.8(12.64915) 140000  2100(12.64915)  296.8317  140000  f (25.35085)  2000ln   9.8(25.35085) 140000  2100(25.35085)  708.4811

The absolute relative true error, t , is (True value = 11061.34 m) 11061.34 11058.44   100 t 11061.34  0.0262%

Example 5 Use three-point Gauss quadrature rule to approximate the distance covered by a rocket from t  8 to t  30 as given by 30  140000   x   2000ln   9.8t dt 8  140000  2100t   Also, find the absolute relative true error. Solution First, change the limits of integration from 8, 30 to 1, 1 using Equation (23) gives 30 30  8 1  30  8 30  8   f (t)dt   f  x  dx 8 2 1  2 2  1  11 f 11x 19dx 1 The weighting factors and function argument values are

c1  0.555555556

x1  0.774596669

c2  0.888888889

x2  0.000000000

c3  0.555555556

x3  0.774596669 Gauss Quadrature Rule 07.05.13 and the formula is 1 11 f 11x 19 dx  11 c f 11x 19  c f 11x 19  c f 11x 19     1  1  2  2  3  3  1 0.5555556 f 11(.7745967) 19 0.8888889 f 11(0.0000000) 19  11   0.5555556 f 11(0.7745967) 19   110.55556 f (10.47944)  0.88889 f (19.00000)  0.55556 f (27.52056)  110.55556 239.3327  0.88889 484.7455  0.55556 795.1069  11061.31 m since  140000  f (10.47944)  2000ln   9.8(10.47944) 140000  2100(10.47944)  239.3327  140000  f (19.00000)  2000ln   9.8(19.00000) 140000  2100(19.00000)  484.7455  140000  f (27.52056)  2000ln   9.8(27.52056) 140000  2100(27.52056)  795.1069

The absolute relative true error, t , is (True value = 11061.34 m) 11061.34 11061.31   100 t 11061.34  0.0003%

INTEGRATION Topic Gauss quadrature rule Summary These are textbook notes of Gauss quadrature rule Major General Engineering Authors Autar Kaw, Michael Keteltas Date 2018 年 4 月 5 日 Web Site http://numericalmethods.eng.usf.edu