Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Numerical Integration 1 Introduction to Numerical Integration Definitions Upper and Lower Sums Trapezoid Method (Newton-Cotes Methods) 2 Integration Indefinite Integrals 2 x x dx 2 c Indefinite Integrals of a function are functions that differ from each other by a constant. Definite Integrals 1 2 1 x 0 xdx 2 0 1 2 Definite Integrals are numbers. 3 Fundamental Theorem of Calculus If f is continuous on an interval [a,b], F is antideriva tive of f (i.e., F ' (x) f(x) ) b a f(x)dx F(b) F(a) There is no antideriva tive for : e b x2 No closed form solution for : e dx x2 a 4 The Area Under the Curve One interpretation of the definite integral is: Integral = area under the curve f(x) Area a b a f(x)dx b 5 Upper and Lower Sums The interval is divided into subintervals. Partition P a x0 x1 x2 ... xn b Define mi min f ( x) : xi x xi 1 M i max f ( x) : xi x xi 1 f(x) n 1 Lower sum L( f , P) mi xi 1 xi i 0 n 1 Upper sum U ( f , P) M i xi 1 xi i 0 x0 x1 x2 x3 a b 6 Upper and Lower Sums n 1 Lower sum L( f , P ) mi xi 1 xi i 0 n 1 Upper sum U ( f , P ) M i xi 1 xi f(x) i 0 Estimate of the integral Error L U 2 U L 2 x0 x1 x2 x3 CISE301_Topic7 a b 7 Example 1 0 x 2 dx 1 2 3 Partition : P 0, , , ,1 4 4 4 n 4 (four equal intervals ) 1 1 9 m0 0, m1 , m2 , m3 16 4 16 1 1 9 M 0 , M1 , M 2 , M 3 1 16 4 16 1 xi 1 xi 4 for i 0,1, 2, 3 0 1 4 1 2 3 4 1 8 Example n 1 Lower sum L( f , P ) mi xi 1 xi i 0 L( f , P ) 1 1 1 9 14 0 4 16 4 16 64 n 1 Upper sum U ( f , P ) M i xi 1 xi i 0 U ( f , P) 11 1 9 30 1 4 16 4 16 64 1 30 14 11 Estimate of the integral 2 64 64 32 1 30 14 1 Error 2 64 64 8 0 1 4 1 2 3 4 1 9 Upper and Lower Sums • Estimates based on Upper and Lower Sums are easy to obtain for monotonic functions (always increasing or always decreasing). • For non-monotonic functions, finding maximum and minimum of the function can be difficult and other methods can be more attractive. 10 Newton-Cotes Methods In Newton-Cote Methods, the function is approximated by a polynomial of order n. Computing the integral of a polynomial is easy. b b a a f ( x)dx b a a n a x ... a x dx 0 1 n (b 2 a 2 ) (b n1 a n1 ) f ( x)dx a0 (b a) a1 ... an 2 n 1 11 Newton-Cotes Methods Trapezoid Method (First Order Polynomials are used) b a f ( x)dx b a a0 a1x dx Simpson 1/3 Rule (Second Order Polynomials are used) b a f ( x)dx b a a 0 a1x a2 x dx 2 12 Trapezoid Method Derivation-One Interval Multiple Application Rule Estimating the Error Recursive Trapezoid Method 13 Trapezoid Method b f (b) f (a) f (a) ( x a) ba f(x) I f ( x)dx a f (b) f (a ) I f (a) ( x a ) dx a ba b b f (b) f (a ) f (a) a x ba a 2 b f (b) f (a ) x ba 2 a b a f (b) f (a ) b a 2 14 Trapezoid Method Derivation-One Interval f (b) f (a ) I f ( x)dx f (a ) ( x a ) dx a a ba b f (b) f (a ) f (b) f (a ) I f (a) a x dx a ba ba b b b 2 b f (b) f (a ) f (b) f (a ) x f (a) a x ba ba 2 a a f (b) f (a ) f (b) f (a ) 2 f (a) a (b a 2 ) b a ba 2(b a ) f (b) f (a ) b a 2 15 Trapezoid Method f(x) f (b ) f (a ) ba f (a) f (b) Area 2 a b 16 Trapezoid Method Multiple Application Rule The interval [a, b] is f(x) f ( x2 ) f ( x1 ) x2 x1 Area 2 partitione d into n segments a x0 x1 x2 ... xn b b a f ( x)dx sum of the areas of the trapezoid s x x0 a x1 x2 x3 b 17 Trapezoid Method General Formula and Special Case If the interval is divided into n segments (not necessaril y equal) a x0 x1 x2 ... xn b n 1 1 f ( x)dx xi 1 xi f ( xi 1 ) f ( xi ) i 0 2 b a Special Case ( Equaliy spaced base points) xi 1 xi h for all i b a n 1 1 f ( x)dx h f ( x0 ) f ( xn ) f ( xi ) i 1 2 18 Example Given a tabulated values of the velocity of an object. Time (s) 0.0 1.0 2.0 3.0 Velocity (m/s) 0.0 10 12 14 Obtain an estimate of the distance traveled in the interval [0,3]. Distance = integral of the velocity Distance 3 0 V (t ) dt 19 Example 1 The interval is divided Time (s) 0.0 1.0 2.0 3.0 into 3 subinterva ls Velocity (m/s) 0.0 10 12 14 Base points are0,1,2,3 Trapezoid Method h xi 1 xi 1 1 n 1 T h f ( xi ) f ( x0 ) f ( xn ) 2 i 1 1 Distance 1(10 12) (0 14) 29 2 20 Error in estimating the integral Theorem Assumption : f ' ' ( x) is continuous on [a,b] Equal intervals (width h) Theorem : approximat e If Trapezoid Method is used to b a f ( x)dx then b a 2 '' Error h f ( ) where [a,b] 12 ba 2 Error h max f ' ' ( x) x[ a ,b ] 12 CISE301_Topic7 21 Estimating the Error For Trapezoid Method How many equally spaced intervals are needed to compute 0 sin( x)dx to 5 decimal digit accuracy ? 22 Example sin( x )dx, 0 1 find h so that error 105 2 ba 2 Error h max f ' ' ( x ) 12 x[ a ,b] b ; a 0; f ' ( x ) cos( x ); f ' ' ( x ) sin( x ) 1 f ' ' ( x ) 1 Error h 105 12 2 2 6 h 105 h 0.00437 2 (b a ) n 719 intervals h 0.00437 23 Example x 1.0 1.5 2.0 2.5 3.0 f(x) 2.1 3.2 3.4 2.8 2.7 Use Trapezoid method to compute : 3 1 f ( x)dx n 1 1 Trapezoid T ( f , P) xi 1 xi f ( xi 1 ) f ( xi ) i 0 2 Special Case : h xi 1 xi for all i, 1 n 1 T ( f , P) h f ( xi ) f ( x0 ) f ( xn ) 2 i 1 24 Example x 1.0 1.5 2.0 2.5 3.0 f(x) 2.1 3.2 3.4 2.8 2.7 3 1 n1 1 f ( x)dx h f ( xi ) f ( x0 ) f ( xn ) 2 i 1 1 0.5 3.2 3.4 2.8 2.1 2.7 2 5.9 25 Recursive Trapezoid Method Estimate based on one interval : f(x) h ba ba f ( a ) f ( b) R (0,0) 2 a ah 26 Recursive Trapezoid Method Estimate based on 2 intervals : f(x) h ba 2 R (1,0) ba 1 f ( a h ) f ( a ) f ( b ) 2 2 R(1,0) 1 R(0,0) h f ( a h ) 2 Based on previous estimate a ah a 2h Based on new point 27 Recursive Trapezoid Method f(x) ba h 4 R (2,0) R(2,0) ba f (a h) f (a 2h) f (a 3h) 4 1 f (a ) f (b) 2 1 R(1,0) h f (a h) f (a 3h) 2 Based on previous estimate a a 2h a 4h Based on new points 28 Recursive Trapezoid Method Formulas ba f (a) f (b) R (0,0) 2 1 R (n,0) R (n 1,0) h f a (2k 1)h 2 k 1 2 ( n1) ba h n 2 29 Recursive Trapezoid Method ba , 2 ba f (a) f (b) 2 1 1 R(1,0) R(0,0) h f a (2k 1)h 2 k 1 ba h 2 , 2 1 2 R(2,0) R(1,0) h f a (2k 1)h 2 k 1 ba h 3 , 2 2 1 R(3,0) R(2,0) h f a (2k 1)h 2 k 1 h b a, h R (0,0) 2 .................. h ba , n 2 2 1 R(n,0) R(n 1,0) h f a (2k 1)h 2 k 1 ( n 1) 30 Example on Recursive Trapezoid Use Recursive Trapezoid method to estimate : /2 sin( x )dx by computing R(3,0) then estimate the error 0 n h R(n,0) 0 (b-a)=/2 (/4)[sin(0) + sin(/2)]=0.785398 1 (b-a)/2=/4 R(0,0)/2 + (/4) sin(/4) = 0.948059 2 (b-a)/4=/8 R(1,0)/2 + (/8)[sin(/8)+sin(3/8)] = 0.987116 3 (b-a)/8=/16 R(2,0)/2 + (/16)[sin(/16)+sin(3/16)+sin(5/16)+ sin(7/16)] = 0.996785 Estimated Error = |R(3,0) – R(2,0)| = 0.009669 31 Advantages of Recursive Trapezoid Recursive Trapezoid: Gives the same answer as the standard Trapezoid method. Makes use of the available information to reduce the computation time. Useful if the number of iterations is not known in advance. 32