Numericl pproximtion of definite integrls You should lredy be fmilir with the left nd right-hnd Riemnn sums used in the definition of the definite integrl: MATH 50 A I f (x) dx = lim f ( ) x = lim n n where x =(b )/n nd = + i x. n f ( ) x, The left nd right rules respectively pproximte the integrl I with LEFT(n) nd RIGHT(n), where i=1 LEFT(n) = f ( ) x, RIGHT(n) = n f ( ) x, i=1 with x nd defined s bove. Link to Geogebr Numericl pproximtion of definite integrls (continued) The midpoint rule consists in pproximting the definite integrl by evluting f t the midpoint between nd +1 : ( ) xi + +1 MID(n) = f x. The trpezoid rule pproximtes the re under the grph of f between nd +1 with the re of the corresponding trpezoid: ( ) f (xi )+f(+1 ) TRAP(n) = x. From the bove formul, one cn see tht TRAP(n) = 1 (LEFT(n)+RIGHT(n)). Overestimtes nd underestimtes 1 Assume tht f is incresing between nd b nd tht we pproximte I = f (x) dx with LEFT(n). Which of the following sttements is correct? 1 LEFT(n) is n underestimte LEFT(n) is n overestimte 3 LEFT(n) isexct If f is incresing on [, b], then LEFT(n) f (x) dx RIGHT(n). 3 Similrly, if f is decresing on [, b], then RIGHT(n) f (x) dx LEFT(n).
Overestimtes nd underestimtes (continued) In order to ensure tht TRAP(n) isnoverestimte,whichof the following requirements do we need? 1 f is incresing f is concve up 3 f is concve down 4 f is decresing If f is concve up on [, b], then MID(n) f (x) dx TRAP(n). Similrly, if f is concve down on [, b], then TRAP(n) f (x) dx MID(n). Exmple of ppliction Assume tht the function f is positive, decresing, nd concve down on [, b]. Let I = f (x) dx. Assume tht the vlues of LEFT(10), RIGHT(10), TRAP(10), nd MID(10) re, in rndom order, given by 0.703, 0.74, 0.735, 0.745. Use the bove to ssign vlue to ech of LEFT(10), RIGHT(10), TRAP(10), nd MID(10). Then, indicte which of the sttements below is correct: 1 0.703 I 0.74 0.74 I 0.735 3 0.735 I 0.745 Approximtion errors If we use numericl method, sy the left rule, to pproximte definite integrl I, we define the bsolute error E L (n), s E L (n) =I LEFT(n). One cn show tht E L (n) nd E R (n) re liner functions of 1/n. Similrly, E T (n) nd E M (n) decrese qudrticlly s n is incresed. This cn be improved by using Simpson s rule, given by SIMP(n) = 1 ( MID(n)+TRAP(n)). 3 One cn show tht the error E S (n) decreses like 1/n 4. Numericl integrtion of ODEs dy = g(x, y) dx The bove differentil eqution my formlly be integrted s y(x + h) y(x) = x+h x g(t, y(t)) dt. If we know y(x), numericl pproximtion of y(x + h) my thus be obtined by finding n estimte of the integrl in the right-hnd-side of the bove eqution. Euler s method consists in ssuming tht g(t, y(t)) is constnt on the intervl [x, x + h], nd equl to g(x, y(x)), where s the left end-point of the intervl. We thus hve y(x + h) y(x)+hg(x, y(x)).
Numericl integrtion of ODEs (continued) Numericl error dy dx = g(x, y) If we use the midpoint rule, then we obtin the modified Euler method mentioned in the lb, y(x + h) y(x)+hg (x + h ), y(x)+h g(x, y(x)). If we use the trpezoid rule, we obtin Heun s method (sometimes lso clled improved Euler s method) y(x+h) y(x)+ h (g(x, y(x)) + g(x + h, y(x)+hg(x, y(x)))). Numericl simultions re very powerful tools, but if we wnt to trust their predictions, it is essentil to know their limittions. In prticulr, we need to be ble to understnd nd control numericl errors. All of the bove methods re susceptible to two types of error: 1 The discretiztion error is due to pproximtion errors in the numericl method. The round-off error is due to the fct tht computer does not perform exct clcultions. For instnce, in MATLAB, eps returns the distnce from 1.0 to the next lrgest double-precision number. Discretiztion error Tylor polynomils The discretiztion error hs two sources: 1 The locl discretiztion error e n, which is the error mde t ech time step due to the fct tht we pproximte n integrl on the right-hnd side of the eqution: e n =ỹ n y(x n ), where y(x n ) is the exct solution, nd ỹ n is the numericl pproximtion of y(x n ) ssuming tht y(x n 1 )isknown exctly. The globl discretiztion error E n, which is the error mde on y(x n ) when it is evluted from n initil condition y 0 fter n numericl integrtion steps: E n = y n y(x n ), where y n is the numericl solution obtined fter n steps. We now turn to the question of pproximting function of one vrible by polynomils. The Tylor polynomil of degree n of the function f ner x = is polynomil tht mtches the vlue of f nd of its first n derivtives t the point x =. The figure bove shows the grph of cos(x) nd of the Tylor polynomils of degree up to 8 ner x =0.
Tylor polynomils (continued) The Tylor polynomil of degree n, centered t x =, of function f is given by P n (x) =f ()+(x )f ()+ (x ) f ()+ +! (x )n f (n) (). n! Of course, the bove ssumes tht f hs is t lest n times differentible ner. In wht follows, we ssume tht f is smooth, for simplicity. One cn show tht the error mde by replcing f by its Tylor polynomil of degree n is given by f (x) =P n (x)+r n (x), where ξ (, x). R n (x) = (x )n+1 f (n+1) (ξ), (n + 1)! Link to d Arbeloff Tylor Polynomils softwre Numericl pproximtion of definite integrls revisited f (x) dx = f (x) dx, = + i x, x = b n. For the left rule, for ech x [, +1 ], we hve f (x) =f ( )+(x ) f (ξ(x)), ξ(x) (, x). From this formul, we see tht if f is positive nd bounded by M between nd +1,then 0 f (x) f ( ) M(x ), which gives tht LEFT is n underestimte nd f (x) dx f ( ) x M (x ) dx = M ( x). Approximtion errors For the midpoint rule, we hve, with m = + +1, f (x) =f (m)+(m x) f (m)+ 1 (x m) f (ξ(x)), We cn check tht ( f (m)+(m x) f (m) ) dx = f (m) x, ξ(x) (, x). so tht if f is positive ndboundedbymbetween nd +1,then 0 f (x) [ f (m)+(m x) f (m) ] M (x m), which gives tht MID is n underestimte nd tht the lrger f, the lrger the error. Approximtion errors (continued) Finlly, for the trpezoid rule, we hve (by integrtion by prts) f (x) dx =[(x m)f (x)] +1 (x m) f (x) dx. We cn use Tylor expnsion for f (x) nerx = m to see tht if f is positive between nd +1, then TRAP gives n overestimte. Moreover, the error over n intervl of length s bounded by M( x) 3 /1, where M is the mximum of f over tht intervl. For ll of these methods, if the error on the integrl between nd +1 is of order ( x) p+1,thenthe error on the integrl between nd b is of order 1/n p,wheren is the number of sub-intervls.
Numericl integrtion of ODEs revisited A numericl method is consistent if the locl discretiztion error goes to zero s h 0. A numericl method is convergent if the globl discretiztion error goes to zero s h 0. Typiclly, one uses Tylor expnsions to decide whether numericl method is consistent nd convergent. A numericl method my lso be unstble, in the sense tht numericl solution to y = λy with λ<0 cn disply growth. These re topics typiclly discussed in n introductory course on numericl nlysis, such s MATH 475. Finlly, one should keep in mind tht numericl method is mp of the form y n+1 = G(y n, n), nd tht if G is nonliner, chos my be observed. Link to Chos on the Web