0% found this document useful (0 votes)
48 views

Numerical Methods in Engineering With Python 3

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

Numerical Methods in Engineering With Python 3

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

216 Numerical Integration

18.  Write a function that computes the sine integral


4 x
Si(x) = t −1 sin t dt
0

for any given value of x. Test the program by computing Si(1.0), and compare the
result with the tabulated value 0.946 08.

6.4 Gaussian Integration


Gaussian Integration Formulas
3b
Newton-Cotes formulas for approximating a 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 integrals of the form

4 b
w(x)f (x)dx (6.15)
a

where w(x), called the weighting function, can contain singularities, as long as they
31
are integrable. An example of such integral is 0 (1 + x 2 ) ln x dx. Sometimes infinite
3 ∞ −x
limits, as in 0 e sin x dx, can also be accommodated.
Gaussian integration formulas have the same form as Newton-Cotes rules


n
I= A i f (xi ) (6.16)
i=0

where, as before, I represents the approximation to the integral in Eq. (6.15). The
difference lies in the way that the weights A i 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,

4 b 
n
w(x)Pm (x)dx = A i Pm (xi ), m ≤ 2n + 1 (6.17)
a i=0

One way of determining the weights and abscissas is to substitute P0 (x) = 1, P1 (x) =
x, . . . , P2n+1 (x) = x 2n+1 in Eq. (6.17) and solve the resulting 2n + 2 equations

4 b 
n
j
w(x)x j dx = A i xi , j = 0, 1, . . . , 2n + 1
a i=0

for the unknowns A i and xi .


217 6.4 Gaussian Integration

As an illustration, let w(x) = e−x , a = 0, b = ∞, and n = 1. The four equations


determining x0 , x1 , A 0 , and A 1 are as follows:
4 ∞
e−x dx = A 0 + A 1
0
4 1
e−x x dx = A 0 x0 + A 1 x1
0
4 1
e−x x 2 dx = A 0 x02 + A 1 x12
0
4 1
e−x x 3 dx = A 0 x03 + A 1 x13
0

After evaluating the integrals, we get these results:

A0 + A1 = 1

A 0 x0 + A 1 x1 = 1

A 0 x02 + A 1 x12 = 2

A 0 x03 + A 1 x13 = 6

The solution is

√ 2+1
x0 = 2 − 2 A0 = √
2 2

√ 2−1
x1 = 2 + 2 A1 = √
2 2
so that the integration formula becomes
4 ∞
1 √ 1 √ 2 √ 1 √ 2
e−x f (x)dx ≈ √ ( 2 + 1) f 2 − 2 + ( 2 − 1) f 2 + 2
0 2 2
Because of the nonlinearity of the equations, this approach does not work well
for large n. Practical methods of finding xi and A i require some knowledge of orthog-
onal 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 A i . If you do not intend to venture outside the
classical formulas, you can skip the next two topics.

*Orthogonal Polynomials
Orthogonal polynomials are employed in many areas of mathematics and numerical
analysis. They have been studied thoroughly, and many of their properties are known.
What follows is a very small compendium of a large topic.
218 Numerical Integration

The polynomials ϕn (x), n = 0, 1, 2, . . . (n is the degree of the polynomial) are said


to form an orthogonal set in the interval (a, b) with respect to the weighting function
w(x) if
4 b
w(x)ϕm (x)ϕn (x)dx = 0, m = n (6.18)
a

The set is determined, except for a constant factor, by the choice of the weighting
function and the limits of integration. That is, each set of orthogonal polynomials
is associated with certain w(x), a, and b. The constant factor is specified by stan-
dardization. Some of the classical orthogonal polynomials, named after well-known
mathematicians, are listed in Table 6.1. The last column in the table shows the stan-
dardization used.
3b  2
Name Symbol a b w(x) a w(x) ϕn (x) dx
Legendre pn (x) −1 1 1 2/(2n + 1)
Chebyshev Tn (x) −1 1 (1 − x 2 )−1/2 π/2 (n > 0)
Laguerre L n (x) 0 ∞ e−x 1
√ n
e−x
2
Hermite Hn (x) −∞ ∞ π2 n!

Table 6.1. Classical orthogonal polynomials

Orthogonal polynomials obey recurrence relations of the form

a n ϕn+1 (x) = (bn + cn x)ϕn (x) − dn ϕn−1 (x) (6.19)

If the first two polynomials of the set are known, the other members of the set can be
computed from Eq. (6.19). The coefficients in the recurrence formula, together with
ϕ 0 (x) and ϕ 1 (x) are given in Table 6.2.

Name ϕ 0 (x) ϕ 1 (x) an bn cn dn


Legendre 1 x n+1 0 2n + 1 n
Chebyshev 1 x 1 0 2 1
Laguerre 1 1−x n+1 2n + 1 −1 n
Hermite 1 2x 1 0 2 2

Table 6.2. Recurrence coefficients

The classical orthogonal polynomials are also obtainable from these formulas

(−1)n d n  n 
pn (x) = n n
1 − x2
2 n! dx
Tn (x) = cos(n cos−1 x), n > 0
e x d n  n −x 
L n (x) = x e (6.20)
n! dx n
n
2 d
(e−x )
2
Hn (x) = (−1)n e x
dx n
219 6.4 Gaussian Integration

and their derivatives can be calculated from


 
(1 − x 2 )pn (x) = n −xpn (x) + pn−1 (x)
 
(1 − x 2 )Tn (x) = n −xTn (x) + nTn−1 (x)
 
x L n (x) = n L n (x) − L n−1 (x) (6.21)

Hn (x) = 2nHn−1 (x)

Other properties of orthogonal polynomials that have relevance to Gaussian in-


tegration are as follows:

• ϕn (x) has n real, distinct zeros in the interval (a, b).


• The zeros of ϕn (x) lie between the zeros of ϕn+1 (x).
• Any polynomial Pn (x) of degree n can be expressed in the form

n
Pn (x) = ci ϕi (x) (6.22)
i=0

• It follows from Eq. (6.22) and the orthogonality property in Eq. (6.18) that
4 b
w(x)Pn (x)ϕn+m (x)dx = 0, m ≥ 0 (6.23)
a

*Determination of Nodal Abscissas and Weights


Theorem The nodal abscissas x0 , x1 , . . . , xn are the zeroes of the polynomial ϕn+1 (x)
that belongs to the orthogonal set defined in Eq. (6.18).
Proof We start the proof by letting f (x) = P2n+1 (x) be a polynomial of degree 2n + 1.
Because the Gaussian integration with n + 1 nodes is exact for this polynomial,
we have
4 b n
w(x)P2n+1 (x)dx = A i P2n+1 (xi ) (a)
a i=0

A polynomial of degree 2n + 1 can always be written in the form

P2n+1 (x) = Qn (x) + Rn (x)ϕn+1 (x) (b)

where Qn (x), Rn (x), and ϕn+1 (x) are polynomials of the degree indicated by the
subscripts.2 Therefore,
4 b 4 b 4 b
w(x)P2n+1 (x)dx = w(x)Qn (x)dx + w(x)Rn (x)ϕn+1 (x)dx
a a a

But according to Eq. (6.23) the second integral on the right-hand-side vanishes,
so that
4 b 4 b
w(x)P2n+1 (x)dx = w(x)Qn (x)dx (c)
a a

2 It can be shown that Qn (x) and Rn (x) are unique for a given P2n+1 (x) and ϕn+1 (x).
220 Numerical Integration

Because a polynomial of degree n is uniquely defined by n + 1 points, it is al-


ways possible to find A i such that
4 b 
n
w(x)Qn (x)dx = A i Qn (xi ) (d)
a i=0

To arrive at Eq. (a), we must choose for the nodal abscissas xi the roots of
ϕn+1 (x) = 0. According to Eq. (b) we then have

P2n+1 (xi ) = Qn (xi ), i = 0, 1, . . . , n (e)

which together with Eqs. (c) and (d) leads to


4 b 4 b 
n
w(x)P2n+1 (x)dx = w(x)Qn (x)dx = A i P2n+1 (xi )
a a i=0

This completes the proof.


Theorem
4 b
Ai = w(x) i (x)dx, i = 0, 1, . . . , n (6.24)
a

where i (x) are the Lagrange’s cardinal functions spanning the nodes at
x0 , x1 , . . . xn . These functions were defined in Eq. (4.2).
Proof Applying Lagrange’s formula, Eq. (4.1), to Qn (x) yields


n
Qn (x) = Qn (xi ) i (x)
i=0

which upon substitution in Eq. (d) gives us


* 4 b +
n 
n
Qn (xi ) w(x) i (x)dx = A i Qn (xi )
i=0 a i=0

or
* 4 +

n b
Qn (xi ) A i − w(x) i (x)dx = 0
i=0 a

This equation can be satisfied for arbitrary Q(x) of degree n only if


4 b
Ai − w(x) i (x)dx = 0, i = 0, 1, . . . , n
a

which is equivalent to Eq. (6.24).

It is not difficult to compute the zeros xi , i = 0, 1, . . . , n of a polynomial ϕn+1 (x)


belonging to an orthogonal set by one of the methods discussed in Chapter 4. Once
the zeros are known, the weights A i , i = 0, 1, . . . , n could be found from Eq. (6.24).
221 6.4 Gaussian Integration

However the following formulas (given without proof) are easier to compute:

2
Gauss-Legendre A i =   2
(1 − xi2 ) pn+1 (xi )
1
Gauss-Laguerre A i =  2 (6.25)

xi L n+1 (xi )

2n+2 (n + 1)! π
Gauss-Hermite Ai =  2

Hn+1 (xi )

Abscissas and Weights for Classical Gaussian Quadratures


Here we list some classical Gaussian integration formulas. The tables of nodal ab-
scissas 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.3 or use a subroutine to compute the abscissas and weights within
the integration program.4
The truncation error in Gaussian quadrature
4 b 
n
E= w(x)f (x)dx − A i f (xi )
a i=0

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
4 1 
n
f (ξ )dξ ≈ A i f (ξ i ) (6.26)
−1 i=0

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 A 0 = A 1 . The truncation error in Eq. (6.26) is
 4
22n+3 (n + 1)!
E=  3 f
(2n+2)
(c), −1<c <1 (6.27)
(2n + 3) (2n + 2)!

3 Abramowitz, M. and Stegun, I.A, Handbook of Mathematical Functions, Dover Publications, 1965;
Stroud, A.H.and Secrest, D., Gaussian Quadrature Formulas, Prentice-Hall, 1966.
4 Several such subroutines are listed in W.H. Press et al, Numerical Recipes in Fortran 90, Cambridge
University Press, 1996.

You might also like