Lecture 14: Qudrture This lecture is concerned with the evlution of integrls fx)dx 1) over finite intervl [, b] The integrnd fx) is ssumed to be rel-vlues nd smooth The pproximtion of n integrl by numericl method is commonly referred to s qudrture In Clculus one discusses mny techniques for determining n ntiderivtive of fx) The integrl is then computed by evluting the ntiderivtive t the endpoints of the intervl However, mny integrnds of interest in science nd engineering do not hve known ntiderivtive Moreover, in some pplictions the integrnd is only known t few points in the intervl We would like to be ble to determine ccurte pproximtions of integrls lso in these situtions We will pproximte integrls 1) by sums fx j )w j ) These sums re referred to s qudrture rules The x j re the nodes nd the w j the weights of the qudrture rule We re interested in determining weights so tht the qudrture rules gives ccurte pproximtions of the integrl 1 for lrge clsses of integrnds fx) The nodes often cnnot be chosen freely, becuse the integrnd my only be known t certin points For instnce, the function fx) might not be explicitly known, only mesured vlues fx j ) t the nodes x j my be vilble We remrk tht you lredy encountered the pproximtion of integrls by sums in Clculus There, however, one ws less concerned with how smll the error E N f) = fx)dx fx j )w j 3) is for smll vlues of N; it ws sufficient tht the error E N f) converged to zero s N incresed to infinity In this lecture, we would like the error E N f) to be smll lredy for smll to modest number of terms N in the qudrture rule ) Method of undetermined coefficients Let the nodes x j, 1 j N, be given Throughout this lecture the nodes will be ordered so tht x 1 < x < < x N b 4) We would like to determine the weights w j so tht qudrture rule is exct for polynomils of s high degree s possible, ie, we would like the weights be such tht px)dx = for ll polynomils px) of s high degree s possible px j )w j 5) 1
The powers {1, x, x, x 3, } form bsis for polynomils Our objective therefore cn be expressed s follows: We would like the equlity 5) to hold for s mny powers px) = x j, j =, 1,,, s possible This requirement gives rise to the liner system of equtions for the weights, px) = 1 : w 1 + w + + w N = px) = x : x 1 w 1 + x w + + x N w N = px) = x : x 1w 1 + x w + + x N w N = px) = x N 1 : x N 1 1 w 1 + x N 1 w + + w N x N 1 N This system conveniently cn be expressed in the form 1 1 1 x 1 x x N x N 1 1 x N 1 x N 1 N w 1 w w N = dx = b, xdx = 1 b ), x 1 dx = 3 b3 3 ), = xn 1 dx = 1 N bn N ) b 1 b ) 1 N bn N ) 6) 7) We recognize the mtrix s the trnspose of Vndermonde mtrix Vndermonde mtrices were encountered in the fll semester in connection with polynomil interpoltion, when we showed tht Vndermonde mtrices determined by distinct nodes re nonsingulr Determinnts re invrint under trnsposition This follows from the fct tht determinnts cn be expnded either by rows or by columns We conclude tht the mtrix in 7) is nonsingulr when the nodes x j re distinct Hence the bove liner system of equtions hs unique solution Thus, given n distinct nodes, we cn determine n unique weights w j, such tht the qudrture rule ) integrtes ll polynomils of degree strictly less thn n exctly Exmple 1 Consider the midpoint qudrture rule fx)dx fx 1 )w 1, x 1 = 1 + b) We only hve one weight to determine The liner system of equtions 6) reduces to px) = 1 : w 1 = dx = b This determines the weight w 1 Exmple Apply the midpoint rule to integrte the function fx) = exp 1 x/) ) 8) on the intervl [, 1] The midpoint rule pproximtes the integrnd by the constnt function f1/) = exp 7/8) on the intervl [, b] nd integrtes the ltter function exctly The blue grph of Figure 1 shows fx) nd the vlue of the integrl is the re below this grph The dshed red line displyes the constnt function tht is integrted exctly by the midpoint rule The vlue determined by the midpoint rule is the re below the dshed red line Sometimes N-node qudrture rules determined by solving the liner system of equtions 7) lso integrte powers x k for k N exctly The following exmple illustrtes this
75 7 65 6 55 5 45 4 35 1 3 4 5 6 7 8 9 1 Figure 1: Integrnd of Exmple nd pproximtion used by the midpoint rule Exmple 3 Consider the midpoint qudrture rule of Exmple 1 Appliction of this rule to fx) = x yields x 1 w 1 = 1 + b)b ) = 1 b ) The right-hnd side equls xdx, ie, the midpoint rule integrtes not only constnts but lso liner polynomils exctly Exercise 1 Determine the weights of the -node qudrture rule fx)dx fx 1 )w 1 + fx )w, x 1 =, x = b This rule is known s the trpezoidl rule By construction, it integrtes liner polynomils exctly Does it integrte polynomils of higher degree exctly? Justify your nswer Exercise Determine the weights of the 3-node qudrture rule 1 fx)dx fx 1 )w 1 + fx )w + fx 3 )w 3, x 1 =, x = 1/, x 3 = 1 This rule is known s Simpson s rule It integrtes qudrtic polynomils exctly by construction Does it integrte polynomils of higher degree exctly? Justify your nswer Wht is the nlogous qudrture rule for the intervl [1, ]? Hint: Do not recompute the qudrture rule, just mke chnge of vribles Integrting Lgrnge polynomils When discussing polynomil interpoltion lst fll, we considered different polynomil bses, such s monomils, Lgrnge polynomils, nd Newton polynomils We cn lso in the present context use bses different 3
from the monomil one For instnce, the nodes x 1, x,,x N determine the Lgrnge polynomils l k x) = N j k x x j x k x j, k = 1,,, N, 9) which form bsis for ll polynomils of degree t most N 1 We therefore my require tht n N-node qudrture rule integrtes the Lgrnge polynomils 9) exctly Substituting px) = l k x) into 5) yields l k x)dx = l k x j )w j = l k x k )w k = w k, k = 1,,,N, where the simplifictions of the right-hnd side follow from the fct tht { 1, k = j, l k x j ) =, k j Thus, the weights cn be obtined by integrting the Lgrnge polynomils However, the evlution of these integrls is tedious unless N is smll Composite qudrture rules nd Tylor expnsion Assume tht the midpoint rule of Exmple does not yield sufficiently ccurte pproximtion of the integrl We my then subdivide the intervl [, 1] into subintervls nd pply the midpoint rule on ech subintervl This defines the composite midpoint rule 75 7 65 6 55 5 45 4 35 1 3 4 5 6 7 8 9 1 Figure : Integrnd of Exmple 4 nd pproximtion used by the composite midpoint rule obtined by dividing the intervl [, 1] into two subintervls of equl length 4
Exmple 4 Divide the intervl [, 1] into the subintervls [, 1/] nd [1/, 1] nd pply the midpoint rule on ech subintervl to the integrnd fx) defined by 8) This yields the composite midpoint rule 1 fx)dx fx 1 )w 1 + fx )w with x 1 = 1/4, x = 3/4, nd w 1 = w = 1/ The integrl is pproximted by the re below the dshed curve of Figure Compring the grphs of Figures 1 nd suggests tht subdivision of the intervl should increse the ccurcy of the computed pproximtion While the computtion of the weights by solving the liner system of equtions 7) is esily done in MATLAB or Octve, this pproch does not shed ny light on how the error behves when we increse the number of nodes Further insight on the behvior of qudrture rules cn be gined by expnding the integrnd into Tylor series Consider the pproximtion of the integrl fx)dx by the midpoint rule nd use the Tylor expnsion of fx) t x = h/ Here x h/ should be thought of s firly smll, nd we ssume tht fx) is continuously differentible s mny times s required Then ) ) h h fx) = f + f x h ) + f ) h! x h ) + f ) h x h 3! Integrting the left-hnd nd right-hnd sides from to h yields ) h ) h fx)dx = f dx + f x h + f ) h x h ) 3 dx + f ) h 3! 4! ) dx + f h! ) 3 + f ) h x h 4 + 4! ) ) x h ) 4 dx + x h ) dx The integrl over odd powers of x h/ vnishes due to symmetry The right-hnd side therefore simplifies to ) h fx)dx = f h + f ) h x h ) dx + f ) h x h 4 dx +! 4! ) ) h = f h + f ) h h 3 + f ) h h 5 + 1 8 The midpoint rule pplied to the integrl on the left-hnd side gives the first term in the right-hnd side The remining terms express the qudrture error Hence, this error is given by ) h fx)dx f h = f ) h h 3 + f ) h h 5 + 1) 1 8 Since ll derivtives of order nd higher of liner function vnish, the right-hnd side vnishes for such functions It follows tht the midpoint rule is exct for liner functions We know this lredy, nd here it is consequence of the expnsion of the integrl in powers of h Exercise 3 Use Tylor expnsions round x = nd x = h to determine how the pproximtion of the integrl fx)dx determined by the trpezoidl rule depends on h Thus, express the qudrture error fx)dx h f) + fh)) 5
s function of h in similrly mnner s 1) Consider the pproximtion of the integrl 1) by the N-point composite midpoint rule with the nodes nd weights x j = + j 1 ) h, h = b N 1, w j = h, j = 1,,,N 11) Thus, the qudrture rule is given by M h f) = h fx j ) Anlogously to 1), we obtin for ech subintervl [x j h/, x j + h/] of length h the expression xj+h/ x j h/ nd summing over j = 1,,,N yields fx) M h f) = fx)dx fx j )h = f x j ) h 3 +, 1) 1 f x j ) h 3 + = 1 1 N f x j ) Nh3 1 + 13) The verge of the second derivtive vlues 1 N N f x j ) is not smller thn the smllest of the vlues f x j ) Similrly, the verge is not lrger thn lrgest of the vlues f x j ) This is expressed by the inequlities min 1 j N f x j ) 1 N f x j ) mx 1 j N f x j ) We ssumed f x) to be continuous Therefore there is vlue ξ in [, b], such tht f ξ) = 1 N f x j ) Substituting this expression into the right-hnd side of 13) yields Multiplying the expression for h in 11) by the denomintor gives fx) M h f) = f ξ) Nh3 1 + 14) which when substituted into 14) yields Nh = b + h, fx) M h f) = f ξ) b 1 h + 15) The right-hnd side indictes tht we cn expect the error to decrese by fctor 4 when h is hlved nd the number of nodes x j is doubled) 6
Generlly, one does not know in dvnce how mny nodes to use in order to chieve desired ccurcy We therefore my be interested in hlving h until consecutive pproximtions M h f), M h/ f), M h/4 f),, of the integrl do not vry much when h is further reduced Exercise 4 In pplictions with complicted functions, the evlution of the function vlues my dominte the rithmetic work required to evlute qudrture rules The computtion of M h f) requires the evlution of N function vlues How mny of these function vlues cn be used gin when evluting M h/ f)? Exercise 5 Consider the N-point composite trpezoidl rule for the pproximtion of 1), 1 T h f) = h fx 1) + fx ) + fx 3 ) + + fx N 1 ) + 1 ) fx N) with ) Use the representtion x j = + j 1)h, T h f) = N 1 h = b, j = 1,,, N N 1 h fx j) + fx j+1 )) nd the result of Exercise 3 to determine n expnsion of the qudrture error similr to 13) b) Wht is the nlog of formul 15)? How much is the error reduced when h is hlved? c) Assume tht T h f) hs been evluted, nd we would like to compute T h/ f) How mny dditionl function evlutions re required? Singulr integrnds, infinite intervls, nd dptive qudrture rules The composite midpoint nd trpezoidl rules cn be used lso for functions tht re not twice continuously differentible However, the error then my converge to zero slower when h is reduced nd mny nodes might be required to give smll qudrture error We discuss n pproch to remedy this sitution Consider the evlution of the integrl 1 fx) lnx)dx 16) where fx) is ssumed to be smooth function We note tht the trpezoidl rule cnnot be used since the integrnd is infinite t x = Nevertheless, the integrl exists for mny smooth functions fx) We therefore my consider using composite midpoint rule; see Exercise 6 Alterntively, the method of undetermined coefficients cn be pplied to the function fx) only Thus, we would like to determine qudrture rule of the form fx j )w j with given nodes, nd we seek to determine weights w j so tht the reltion px) lnx)dx = px j )w j 17) 7
holds for ll polynomils of s high degree s possible This yields the liner system of equtions, which is nlogous to 6), px) = 1 : w 1 + w + + w N = px) = x : x 1 w 1 + x w + + x N w N = px) = x : x 1w 1 + x w + + x N w N = px) = x N 1 : x N 1 1 w 1 + x N 1 w + + w N x N 1 N lnx)dx, b xlnx)dx, b x lnx)dx, = xn 1 lnx)dx The right-hnd side expressions cn be evluted by integrtion by prts Note tht the lloction of nodes x j is quite rbitrry; in prticulr, we my put node t the origin Exercise 6 Compute n pproximtion of 16) with fx) = expx ) by the -node composite midpoint rule Use the MATLAB function qud to determine the exct vlue Note tht the MATLAB function for the integrnd hs to written to llow vector rguments, eg, f=expx^)*logx); How lrge is the error? The MATLAB function qud pplies composite Simpson rule The MATLAB function qud is n exmple of n dptive qudrture rule Adptive rules re composite rules tht estimte the qudrture error by compring the result obtined with different mesh sizes h New nodes re llocted in subintervls [x j, x j+1 ] in which the qudrture error is deemed to be lrger thn prescribed tolernce Exercise 7 Determine -point qudrture rule with the sme nodes s in Exercise 6 by solving liner system of equtions of the form 18) Apply it to the function fx) of Exercise 6 Is this rule more ccurte thn the one in Exmple 6? Exercise 8 Evlute the integrl exp x 3 )dx with t lest 5 correct deciml digits using the MATLAB function qud This function requires the intervl of integrtion to be finite Therefore the integrl hs to be split, exp x 3 )dx = c exp x 3 )dx + c exp x 3 )dx, where the constnt c > is chosen lrge enough so tht the second integrl cn be neglected nd the first integrl is evluted with the function qud For instnce, we my choose c lrge enough so tht c exp x 3 )dx 5 1 6 Determine such vlue of c nd justify your choice The error bound for the integrl evluted with qud then should not be lrger thn 5 1 6 In this lecture, we hve fixed the nodes nd then determined the weights so tht we integrte polynomils of s high degree s possible A clever choice of nodes s well s weights in n N-point qudrture rule mkes it possible to integrte polynomils of degree up to N 1 exctly The midpoint rule is n exmple These rules re known s Gussin qudrture rules The nodes nd weights generlly re not known in closed form, but they cn be computed quite efficiently by solving n eigenvlue problem symmetric N N tridigonl mtrix This is often done with the QR-lgorithm or modifiction thereof 18) 8