SEMINAR REPORT Numericl qudrture bsed on interpolting functions: A MATLAB implementtion by Venkt Ayylsomyjul A seminr report submitted in prtil fulfillment for the degree of Mster of Science (M.Sc) in Computtionl Mechnics of Mterils nd Structures to the Institute for Non-Liner Mechnics University of Stuttgrt December 2016
Contents 1 Introduction 1 2 Description 3 2.1 Composite-Trpezoidl method............................ 3 2.2 Composite-Simpson method.............................. 4 2.3 Generlized Closed Newton-Cotes qudrture method............... 5 2.4 Gussin Qudrture.................................. 6 2.4.1 Guss-Chebyshev qudrture......................... 7 2.4.2 Guss-Hermite qudrture........................... 8 2.4.3 Guss-Lguerre qudrture.......................... 8 2.4.4 Guss-Legendre qudrture.......................... 9 2.4.5 Guss-Lobtto qudrture........................... 9 i
Chpter 1 Introduction Computtion of closed-form ntiderivtives tht re encountered in mny engineering phenomen, is not lwys possible. The lck of n nlyticl solution motivtes numericl pproximtion of the integrl. Numericl integrtion or qudrture is the computtion of n pproximte solution to the definite integrl b f(x)dx to considerble degree of ccurcy. Depending on the behviour of f(x) in the rnge of integrtion, vrious methods my be pplied. In this work, methods pertining to one-dimensionl integrls re described. The function f(x) is known s the integrnd. Numericl qudrture methods cn be defined in generl s the weighted sum of evlutions of the integrnd t finite set of points clled integrtion points or nodes. b f(x)dx k w i f(x i ) i=1 The nodes(x i ) nd weights(w i ) vry ccording to the method nd desired ccurcy. The present work focuses on qudrture rules tht re built on interpolting functions tht re computtionlly efficient to integrte. Polynomils re suitble choice for the interpolting function. The methods tht re described in this document re: Composite-Trpezoidl method Composite-Simpson method Generlized Closed Newton-Cotes method Guss-Chebyshev method Guss-Hermite method Guss-Legendre method 1
Introduction 2 Guss-Lguerre method Guss-Lobtto method The corresponding methods hve been implemented in MATLAB in n intuitive mnner. The im of this implementtion is to compute the nodes nd weights ccording to the user input t run-time. This document explins the underlying theory of the bove mentioned methods.
Chpter 2 Description In this chpter, the description of methods mentioned in Chpter 1, long with the underlying theory nd necessry mthemticl preliminries re presented. 2.1 Composite-Trpezoidl method The Composite-Trpezoidl method, n extension of the 2-point Trpezoidl rule, pproximtes the re under the grph of the function f(x) s series of trpezoids nd computes the re (Fig 2.1). This is chieved by dividing the given intervl into n sub-intervls, pply the 2-point trpezoidl rule for ech sub-intervl nd perform summtion over the results. f(x) b Figure 2.1: Illustrtion of Composite-trpezoidl rule This enhnces the ccurcy of the result considerbly. Also, this rule converges fster when the integrnd is periodic function. The interpolting function is polynomil of degree 1. 3
Description 4 To compute the numericl integrl of function f(x) from to b using the Composite-Trpezoidl method, the following procedure cn be dopted: Divide the rnge of integrtion into n sub-intervls, tht gives step size h = (b )/n The integrtion points or nodes (excluding the limits) cn be written s x k = + kh (k = 1, 2, 3,..., n 1) The integrl cn now be evluted s b f(x)dx (b ) n ( ) n 1 f() + f(x k ) + f(b) 2 2 k=1 (2.1) This method is implemented in the MATLAB function CTrp. 2.2 Composite-Simpson method This is n extension of the 3-point Simpson method. If the integrnd is non-smooth function (oscilltory, discontinuous t few points) over the given rnge, the ccurcy of the result gretly reduces. A solution for such problems is dividing the given rnge into n even number of sub-intervls, pply the 3-point rule on ech sub-intervl nd perform summtion over the results. To compute the numericl integrl of function f(x) from to b using the Composite-Simpson s method, the following procedure cn be dopted: Divide the rnge of integrtion into n sub-intervls, giving step size h = (b )/n. Mke sure tht n is even. The integrl cn be now evluted s b f(x)dx h f() + 2 3 (n 2)/2 k=1 n/2 f(x 2k ) + 4 f(x 2l 1 ) + f(b) (2.2) l=1 The interpolting function is polynomil of degree 2 which is essentilly prbol. This in fct motivtes n to be even. The bove method is implemented in the MATLAB function CSimp.
Description 5 2.3 Generlized Closed Newton-Cotes qudrture method This is generlized formul tht encompsses lot of other methods like Trpezoidl, Simpson s, Boole s rule etc for evluting the pproximte vlue of definite integrls. To compute the numericl integrl of function f(x) from to b using Newton-Cotes qudrture rule where the interpolting function is polynomil of degree m, the following procedure cn be dopted: The Closed Newton-Cotes rule of degree m cn be written s b f(x)dx m A i f(x i ) (2.3) i=0 where x i re the nodes nd A i re the corresponding coefficients. Without loss of generlity, polynomils x 0, x 1, x 2,...,x m cn be chosen s f(x) which will led to liner system of equtions in A i A 0 + A 1 + + A m = b A 0 x 0 + A 1 x 1 + + A m x m = (b 2 2 )/2. A 0 x m 0 + A 1x m 1 + + A mx m m = (b m+1 m+1 )/(m + 1) The coefficients when divided by the step size h = (b )/m provide the corresponding weights of the qudrture. Substituting b = +mh nd x i = +ih into the bove system of equtions nd simplifying further gives liner system of equtions in w i w 0 + w 1 + + w m = m w 1 + 2w 2 + + mw m = m 2 /2. w 1 + 2 m w 2 + + m m w m = m m+1 /(m + 1) This system cn be written in mtrix form VW = M. Here V is the trnspose of the Vndermonde mtrix, W is the vector of unknowns w i nd M is the vector of constnt terms. This system cn be solved for w i With the nodes nd weights in hnd, the qudrture vlues cn be clculted nlogous to the bove methods. This method hs been implemented s composite rule in the MATLAB function NC.
Description 6 The limittion of this generlized formul is, however, tht the integrtion points re to be eqully spced for ny degree. This is becuse polynomil interpoltion using high degree cuses oscilltion t the ends of the intervl (Runge s phenomenon). Also, the vndermonde mtrix is ill-conditioned. Though, for degree m 10 the system is firly stble. 2.4 Gussin Qudrture Until now, procedures contined eqully spced bscisss t which function evlutions tke plce. However, in Gussin qudrture, this is not true. There is freedom in the choice of nodes s well, consequently llowing to perform higher order qudrture with the sme number of function evlutions (compred to Newton-Cotes method). Regrdless of the type of method, the integrnd is desired to be smooth over the intervl which llows well-pproximted polynomil s well. But, in prctice the integrnd is seldom smooth. This issue is ddressed in Gussin qudrture using so-clled weighing function using which integrble singulrities re removed. Conventionlly, the domin of integrtion is tken s [-1,1]. The Gussin qudrture cn be represented s, 1 1 f(x)dx = 1 1 n 1 W (x)g(x)dx w i g(x i ) (2.4) Also, it hs been well estblished tht the nodes x i cn be evluted from the roots of n orthogonl polynomil. In this context, the inner product of two functions p(x) nd q(x) over weight function W (x) is defined s p, q = b i=0 W (x)p(x)q(x)dx (2.5) With this definition in mind, using the Grm-Schmidt process, set of orthogonl polynomils p j (x) cn be generted s, n 1 p n (x) := x n x n, p k p k, p k p k(x) (2.6) k=0 However, (2.6) is numericlly unstble. Hence, to construct the orthogonl polynomils for our purpose, the following theorem is used. Theorem 2.1. Monic orthogonl polynomils re given by the three term recurrence reltion, p 1 (x) 0 p 0 (x) 1 p n+1 (x) = (x n )p n (x) b n p n 1 (x)
Description 7 where (for,n 1) n := p n, xp n p n, p n b n := p n, p n p n 1, p n 1 (2.7) (2.8) Bsed on bove definitions, the nodes x i nd weights w i cn be computed from eigenvlue nlysis of the tridigonl Jcobi mtrix given by, 0 b1 b1 1 b2 J n =. b2........ n 2 bn 1 bn 1 n 1 (2.9) The nodes x i re nothing but the eigenvlues of the bove mtrix. Let V = V ij be the mtrix of eigen vectors. The weights re given by where S R is the domin of integrtion. w i = V1j 2 W (x)dx (2.10) S In the present work, Gussin qudrture bsed on the clssicl orthogonl polynomils hve been implemented. 2.4.1 Guss-Chebyshev qudrture This method uses the Chebyshev polynomils of the first kind. Using the recurrence reltion, they cn be written s, T 0 (x) = 1 T 1 (x) = x (2.11) T n+1 (x) = 2xT n (x) T n 1 (x) This method is used for evluting the pproximte vlue of the integrl of the kind: 1 1 f(x) 1 x 2 (2.12) where, the weighing function is 1/ 1 x 2
Description 8 The chebyshev nodes in the intervl (-1,1) re given by ( ) 2j 1 x j = cos 2n π, j = 1, 2,..., n (2.13) nd the weights re ll the sme nd equl to π/n The implementtion of this method cn be found in the MATLAB function GCheby 2.4.2 Guss-Hermite qudrture The Guss-Hermite qudrture is used to evlute the pproximte vlue of the integrl of the kind e x2 f(x)dx (2.14) where the weighing function is W (x) = e x2 This method uses the physicist s Hermite polynomils tht re given by, The recurrence reltion cn be written s, dn H n (x) = ( 1) n e x2 dx n e x2 (2.15) H n+1 (x) = 2xH n (x) 2nH n 1 (x) (2.16) Note tht, the leding coefficient of H n is 2 n. In order to mke the polynomil monic, it hs to be divided by the sme mount writing it in the form similr to Theorem 2.1, H n+1 (x) 2 n+1 = x H n(x) 2 n n H n 1 (x) 2 2 n 1 (2.17) p n+1 (x) = (x 0)p n (x) n 2 p n 1(x) (2.18) Hence, n = 0 nd b n = n/2. With these vlues, the tridigonl Jcobi mtrix cn be generted nd the nodes nd weights cn be computed s shown in (2.7) nd (2.8). The implementtion of this procedure cn be seen in the MATLAB function GHerm.
Description 9 2.4.3 Guss-Lguerre qudrture The Guss-Lguerre qudrture is used to evlute the pproximte vlue of the integrl of the kind where the weighing function is W (x) = e x This method uses the Lguerre polynomils defined by the formul, 0 e x f(x)dx (2.19) L n (x) = ex d n n! dx n (e x x n ) (2.20) The recurrence reltion cn be written s (n + 1)L n+1 (x) = (2n + 1 x)l n (x) nl n 1 (x) (2.21) The leding coefficient is gin not 1. Mking the relevnt chnges nd rewriting it in the form of Theorem 2.1, we get n = 2n + 1 nd b n = n 2. The corresponding Jcobi mtrix cn be constructed nd the nodes nd weights cn be computed from (2.7) nd (2.8). This method hs been implemented in the MATLAB function GLgu 2.4.4 Guss-Legendre qudrture The Guss-Legendre qudrture is the simplest form where the weighing function, W (x) = 1. The relted polynomils re clled Legendre polynomils. They my be written using the formul, P n (x) = 1 d n ( (x 2 2 n n! dx n 1) n) (2.22) The recurrence reltion cn be written s, (n + 1)P n+1 (x) = (2n + 1)xP n (x) np n 1 (x) (2.23) From (2.18) it is cler tht the leding coefficient is not 1. After rewriting the polynomils in monic form we get n = 0 nd b n = n 2 /(4n 2 1). The corresponding Jcobi mtrix cn be constructed nd the nodes nd weights cn be computed from (2.7) nd (2.8). This method hs been implemented in the MATLAB function GLege
Description 10 2.4.5 Guss-Lobtto qudrture This procedure is similr to Guss-Legendre with the key difference being, the intervl end points re lso considered s nodes. This leds to slight modifiction in the tridigonl Jcobi mtrix s shown below. 0 b1 b1 1 b2. b2..... J n =... n 2 bn 1 bn 1 n 1 bn bn n bn+1 bn+1 n+1 (2.24) Compred to (2.7), few extr terms cn be observed. Also, b n+1 = (n + 1)/(2n + 1) cn be obtined. The rest of the procedure is s explined bove. This method hs been implemented in the MATLAB function GLob