Trapezoidal Rule Its mathematically given by; Tn=Pn(x) + E(n)…………………………………1 β 2 I= [ f(a) + f(b) ]…………………………………2 Where equation 2 is Pn(x) And E(X) which is the error term is given by; β3 12 f’’(C)…………3 Derivation of Trapezoidal rule Derivation ctd • Assuming from the graph between the points a and b, there exists values x0, x1, x2,x3 to xn for n interval • Therefore, considering the number of intervals as • n=1 • Which means we have x0, x1 Derivation ctd • From our equation 1 I= π₯−π₯1 y0[ ] π₯0−π₯1 + π₯−π₯0 y1[ ]…………………..4 π₯1−π₯0 Now we integrate both sides π₯1 πΌππ₯ π₯0 = y0 π₯1 (π₯−π₯1) π₯0 (π₯0−π₯1) dx + y1 π₯1 (π₯−π₯0) π₯0 (π₯1−π₯0) dx Derivation ctd • After integrating we will get ; π₯1 πΌ π₯0 ππ₯ = π¦0 2 [1] + π¦1 2 [1] The bracket will give us a constant (let it be h), thus I= π¦0+π¦1 h( ) 2 giving us the term Pn(x) Derivation ctd Where y0 if f(x0) and y1 is f(x1) Now the error term is got from; E(x)= 1 π₯1 2! π₯0 E(x)= π′′(πΆ) π1 π0 2 π₯ − π₯1 π₯ − π₯0 π ′′ πΆ ππ₯ π₯ − π₯1 π₯ − π₯0 ππ₯ Derivation ctd Now substituting the limits we will get the error term as ; E(x)= β3 12 π′′(π) ……. Thus giving us an exact value of the Trapezoid rule from eqn 1; Tn= π¦0+π¦1 h( ) 2 - β3 12 π′′(π) Improving the Trapezoid rule The improved Trapezoid rule is given by β 2 I= [ f(x0) + 2f(x1) + 2f(x2)+……..+f(xn) ] which is the Pn(x) The error term remains the same thus the final improved trapezoid rule is given β 2 Tn(f) = = [ f(x0) + 2f(x1) + 2f(x2)+……..+f(xn) ] - β3 12 π′′(π) Note The interval h is determined by; assuming the lower limit is a and upper is b h= π−π 2 Example 1 • Use the trapezoidal rule to approximate the integral below 0.8 πππ₯ππ₯ 0 Solution Determine the h Which is 0.4 Soln ctd Now determine Pn(x) which is ; Pn(x)= 0.4 2 [ in(0) + in(0.4) + in(0.8) ] Pn(x)=--------------Now we determine the error term E(x)= β3 12 f’’(C) Soln ctd Now we first solve for second derivative of the function f(x) = inx f’(x)= 1/x f’’(x)= 1 - 2 π₯ f’’(C) = 1 - 2 πΆ Soln ctd Where C is value which between the interval 0 and 0.8 that is 0<C<0.8 3 E(x)= - 0.4 12 E(x) ≈ − 0.4 12 Thus E(x) ≈ . 1 - 2 πΆ 3 . 1/1 since is taken a constant value 1 − 0.4 12 3 . SOLN CTD • Now combine the two values to obtain the approximation Note When you are going to use the improved, simply multiply the mid values by 2 and starting and the end points remain the same . The error term also remains the same Now repeat the example using the improved Trapezoid rule Trial 1. Use the trapezoid rule to approximate the following integrals a) 1 π₯2 π ππ₯ 0 b) 21 1 π₯ dx 1 SIMPSONS 3 RULE The simpson rule of integration is given mathematically as; β 3 I= [ y0 + 4 π π¦πππ + 2 π π¦ππ£ππ + π(π¦π)]- β5 90 Error term Simpson formular fiv(C) Derivation of Simpson’s Rule Consider the graph having points a and b with intervals of n=2 that is x0, x1, x2 Derivation ctd • Then ; I= y0 L0(x) + y1L1(x) + y2L2(x) Now we integrate both sides π₯2 πΌππ₯= π₯0 Where ; y0 π₯2 πΏ0 π₯0 π₯ ππ₯ +y1 π₯2 πΏ1 π₯0 π₯ ππ₯ + y2 π₯2 πΏ2 π₯0 π₯ ππ₯ Derivation ctd L0(x)= (π₯−π₯1)(π₯−π₯2 (π₯0−π₯1)(π₯0−π₯2) L1(x)= (π₯−π₯0)(π₯−π₯2) (π₯1−π₯0)(π₯1−π₯2) L2(x) = (π₯−π₯1)(π₯−π₯0) (π₯2−π₯1)(π₯2−π₯0) Now substitute the values of L0(x), L1(x) and L2(x) Derivation ctd • We therefore obtain π₯2 π₯2 (π₯−π₯1)(π₯−π₯2 πΌππ₯= y0 π₯0 ππ₯ π₯0 (π₯0−π₯1)(π₯0−π₯2) π₯2 (π₯−π₯1)(π₯−π₯0) y2 π₯0 ππ₯ (π₯2−π₯1)(π₯2−π₯0) + y1 π₯2 (π₯−π₯0)(π₯−π₯2) ππ₯ π₯0 (π₯1−π₯0)(π₯1−π₯2) Giving a constant h on integration and substituting the limits + Derivation ctd Which gives us; β 3 Pn(x) = [ y0 + 4 π πππ + 2 π(π¦ππ£ππ) + yn ] Now the ERROR term can be obtained from; E(x) = 1 π₯2 3! π₯0 π₯ − π₯0 π₯ − π₯1 π₯ − π₯2 π ππ£ πΆ ππ₯ On integration substituting the limits will give; β5 E(x) = fiv(C) 90 Note • Some books represent the ERROR term as • E(x) = π−π β4 180 fiv C where h = π−π 2 • The error term is also sometimes represented with negative because we account for some inaccuracies in the approximation of the function. • You can choose to have negative on the error term or just subtract it during the calculation • It is therefore preferable to attach the negative on error term to avoid difficulty in calculations Example Use simpson’s rule to approximate the integral 2 πππ₯ππ₯ 1 Solution From Simpson’s rule β 3 I = [ y0 + 4 π πππ + 2 h= 2−1 2 = 0.5 π(π¦ππ£ππ) + yn ] Soln ctd • Where y0 = f(x0)= in(1)= --------• y1= f(x1)= in(0.5)=-----------• Y2= f(x2)= in(2)= ----------• now substitute these back to the simpson’s equation I= 0.5 3 [ ( in 1 + 4in 0.5 + in 2 ] Now we obtain the ERROR term Soln ctd E(x) = β5 90 fiv C = − 0.5 5 90 f iv C Now we obtain the forth derivative of the function f(x)=inx F’(x) = 1/x F’’(x) = -1/x2 F’’’(x) = -2/x3 Fiv(x) = -6/x4 Thus Fiv(C) = -6/c4 Now we substitute back to the ERROR term equation Soln ctd E(x) = − 0.5 5 6 .− 4 90 π =−−−−−−−−−−− − Note The constant C is approximated to be C=1 Now the simpson’s approximation is then obtained by; Sn(x) = I + E(x)=-------------- Note • Sometimes we might be asked to obtain the interval h when the error term is given; • It is mathematically obtained by • β5 90 fiv C <0.5x10-n Where n is number of sub intervals Example • Using the previous example, How small does the error theory say that h has to be to get that the error is less than 10~3? 10~6? Solution Starting with 10 ~3 From β5 90 fiv C <0.5x10-n Our n=3 and f^iv(C)= − β5 90 fiv C <0.5x10-n 6 π4 Soln ctd • Substitute the values of n and f^iv(C) and obtain the h • Repeat for error of 10~6 and obtain h Note • It applies to Trapezoidal rule too where the h is obtained given ERROR value . It is given by β3 • - 12 f ii C <0.5x10-n • Take note that the f’’(C) is second derivative of the function for trapezoid rule while fiv(C) is forth Derivative of the function for Simpson’s rule 3 8 THE SIMPSON’S RULE • This is mathematically given by I= 3β 8 ( f x0 + 3( f(x1 + f x2 + (f xn Where h= π−π 3 −1 + β― + f xn ) The Error term • It is given by • E(x) =• E(x) =- 3β5 80 f 1v C = − π−π β4 80 f iv (C) 3 π−π β4 3 80 f 1v C Example • Use the simpson’s 3/8 rule to approximate the integral 0.8 (0.2 + 25π₯ − 200π₯ 2 + 675π₯ 3 − 900π₯ 4 + 400π₯ 5 )dx 0 Soln 0.8−0 h= 3 =………………………… Trials Note • For trial question 3, we have apply the xpression below to otain the h in case the error term is given • 3β5 80 f iπ£ C <0.5x10-n