SE 301 Numerical Methods Topic 7 Numerical Integration

  • Slides: 51
Download presentation
SE 301: Numerical Methods Topic 7 Numerical Integration Lecture 24 -27 KFUPM (Term 101)

SE 301: Numerical Methods Topic 7 Numerical Integration Lecture 24 -27 KFUPM (Term 101) Section 04 Read Chapter 21, Section 1 Read Chapter 22, Sections 2 -3 CISE 301_Topic 7 1

Lecture 24 Introduction to Numerical Integration p p p Definitions Upper and Lower Sums

Lecture 24 Introduction to Numerical Integration p p p Definitions Upper and Lower Sums Trapezoid Method (Newton-Cotes Methods) Romberg Method Gauss Quadrature Examples CISE 301_Topic 7 2

Integration Indefinite Integrals Definite Integrals Indefinite Integrals of a function are functions that differ

Integration Indefinite Integrals Definite Integrals Indefinite Integrals of a function are functions that differ from each other by a constant. Definite Integrals are numbers. CISE 301_Topic 7 3

Fundamental Theorem of Calculus CISE 301_Topic 7 4

Fundamental Theorem of Calculus CISE 301_Topic 7 4

The Area Under the Curve One interpretation of the definite integral is: Integral =

The Area Under the Curve One interpretation of the definite integral is: Integral = area under the curve f(x) a CISE 301_Topic 7 b 5

Upper and Lower Sums The interval is divided into subintervals. f(x) a CISE 301_Topic

Upper and Lower Sums The interval is divided into subintervals. f(x) a CISE 301_Topic 7 b 6

Upper and Lower Sums f(x) CISE 301_Topic 7 a b 7

Upper and Lower Sums f(x) CISE 301_Topic 7 a b 7

Example CISE 301_Topic 7 8

Example CISE 301_Topic 7 8

Example CISE 301_Topic 7 9

Example CISE 301_Topic 7 9

Upper and Lower Sums • Estimates based on Upper and Lower Sums are easy

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. CISE 301_Topic 7 10

Newton-Cotes Methods In Newton-Cote Methods, the function is approximated by a polynomial of order

Newton-Cotes Methods In Newton-Cote Methods, the function is approximated by a polynomial of order n. p Computing the integral of a polynomial is easy. p CISE 301_Topic 7 11

Newton-Cotes Methods n Trapezoid Method (First Order Polynomials are used) n Simpson 1/3 Rule

Newton-Cotes Methods n Trapezoid Method (First Order Polynomials are used) n Simpson 1/3 Rule (Second Order Polynomials are used) CISE 301_Topic 7 12

Lecture 25 Trapezoid Method p p Derivation-One Interval Multiple Application Rule Estimating the Error

Lecture 25 Trapezoid Method p p Derivation-One Interval Multiple Application Rule Estimating the Error Recursive Trapezoid Method Read 21. 1 CISE 301_Topic 7 13

Trapezoid Method f(x) CISE 301_Topic 7 14

Trapezoid Method f(x) CISE 301_Topic 7 14

Trapezoid Method Derivation-One Interval CISE 301_Topic 7 15

Trapezoid Method Derivation-One Interval CISE 301_Topic 7 15

Trapezoid Method f(x) CISE 301_Topic 7 16

Trapezoid Method f(x) CISE 301_Topic 7 16

Trapezoid Method Multiple Application Rule f(x) x a CISE 301_Topic 7 b 17

Trapezoid Method Multiple Application Rule f(x) x a CISE 301_Topic 7 b 17

Trapezoid Method General Formula and Special Case CISE 301_Topic 7 18

Trapezoid Method General Formula and Special Case CISE 301_Topic 7 18

Example Given a tabulated values of the velocity of an object. Time (s) 0.

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 CISE 301_Topic 7 19

Example 1 CISE 301_Topic 7 Time (s) 0. 0 1. 0 2. 0 3.

Example 1 CISE 301_Topic 7 Time (s) 0. 0 1. 0 2. 0 3. 0 Velocity (m/s) 0. 0 10 12 14 20

Error in estimating the integral Theorem CISE 301_Topic 7 21

Error in estimating the integral Theorem CISE 301_Topic 7 21

Estimating the Error For Trapezoid Method CISE 301_Topic 7 22

Estimating the Error For Trapezoid Method CISE 301_Topic 7 22

Example CISE 301_Topic 7 23

Example CISE 301_Topic 7 23

Example x 1. 0 1. 5 2. 0 2. 5 3. 0 f(x) 2.

Example x 1. 0 1. 5 2. 0 2. 5 3. 0 f(x) 2. 1 3. 2 3. 4 2. 8 2. 7 CISE 301_Topic 7 24

Example x 1. 0 1. 5 2. 0 2. 5 3. 0 f(x) 2.

Example x 1. 0 1. 5 2. 0 2. 5 3. 0 f(x) 2. 1 3. 2 3. 4 2. 8 2. 7 CISE 301_Topic 7 25

Recursive Trapezoid Method f(x) CISE 301_Topic 7 26

Recursive Trapezoid Method f(x) CISE 301_Topic 7 26

Recursive Trapezoid Method f(x) Based on previous estimate Based on new point CISE 301_Topic

Recursive Trapezoid Method f(x) Based on previous estimate Based on new point CISE 301_Topic 7 27

Recursive Trapezoid Method f(x) Based on previous estimate Based on new points CISE 301_Topic

Recursive Trapezoid Method f(x) Based on previous estimate Based on new points CISE 301_Topic 7 28

Recursive Trapezoid Method Formulas CISE 301_Topic 7 29

Recursive Trapezoid Method Formulas CISE 301_Topic 7 29

Recursive Trapezoid Method CISE 301_Topic 7 30

Recursive Trapezoid Method CISE 301_Topic 7 30

Example on Recursive Trapezoid n h R(n, 0) 0 (b-a)= /2 ( /4)[sin(0) +

Example on Recursive Trapezoid 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 CISE 301_Topic 7 31

Advantages of Recursive Trapezoid: p Gives the same answer as the standard Trapezoid method.

Advantages of Recursive Trapezoid: p Gives the same answer as the standard Trapezoid method. p Makes use of the available information to reduce the computation time. p Useful if the number of iterations is not known in advance. CISE 301_Topic 7 32

Lecture 26 Romberg Method p p p Motivation Derivation of Romberg Method Example When

Lecture 26 Romberg Method p p p Motivation Derivation of Romberg Method Example When to stop? Read 22. 2 CISE 301_Topic 7 33

Motivation for Romberg Method p Trapezoid formula with a sub-interval h gives an error

Motivation for Romberg Method p Trapezoid formula with a sub-interval h gives an error of the order O(h 2). p We can combine two Trapezoid estimates with intervals h and h/2 to get a better estimate. CISE 301_Topic 7 34

Romberg Method First column is obtained using Trapezoid Method R(0, 0) R(1, 1) R(2,

Romberg Method First column is obtained using Trapezoid Method R(0, 0) R(1, 1) R(2, 0) R(2, 1) R(2, 2) R(3, 0) R(3, 1) R(3, 2) R(3, 3) The other elements are obtained using the Romberg Method CISE 301_Topic 7 35

First Column Recursive Trapezoid Method CISE 301_Topic 7 36

First Column Recursive Trapezoid Method CISE 301_Topic 7 36

Derivation of Romberg Method CISE 301_Topic 7 37

Derivation of Romberg Method CISE 301_Topic 7 37

Romberg Method R(0, 0) R(1, 1) R(2, 0) R(2, 1) R(2, 2) R(3, 0)

Romberg Method R(0, 0) R(1, 1) R(2, 0) R(2, 1) R(2, 2) R(3, 0) R(3, 1) R(3, 2) CISE 301_Topic 7 R(3, 3) 38

Property of Romberg Method R(0, 0) R(1, 1) R(2, 0) R(2, 1) R(2, 2)

Property of Romberg Method R(0, 0) R(1, 1) R(2, 0) R(2, 1) R(2, 2) R(3, 0) R(3, 1) R(3, 2) R(3, 3) Error Level CISE 301_Topic 7 39

Example 0. 5 3/8 1/3 CISE 301_Topic 7 40

Example 0. 5 3/8 1/3 CISE 301_Topic 7 40

Example (cont. ) CISE 301_Topic 7 0. 5 3/8 1/3 11/32 1/3 41

Example (cont. ) CISE 301_Topic 7 0. 5 3/8 1/3 11/32 1/3 41

When do we stop? CISE 301_Topic 7 42

When do we stop? CISE 301_Topic 7 42

Lecture 27 Gauss Quadrature p p Motivation General integration formula Read 22. 3 CISE

Lecture 27 Gauss Quadrature p p Motivation General integration formula Read 22. 3 CISE 301_Topic 7 43

Motivation CISE 301_Topic 7 44

Motivation CISE 301_Topic 7 44

General Integration Formula CISE 301_Topic 7 45

General Integration Formula CISE 301_Topic 7 45

Lagrange Interpolation CISE 301_Topic 7 46

Lagrange Interpolation CISE 301_Topic 7 46

Example p Determine the Gauss Quadrature Formula of If the nodes are given as

Example p Determine the Gauss Quadrature Formula of If the nodes are given as (-1, 0 , 1) p Solution: First we need to find l 0(x), l 1(x), l 2(x) p Then compute: CISE 301_Topic 7 47

Solution CISE 301_Topic 7 48

Solution CISE 301_Topic 7 48

Using the Gauss Quadrature Formula CISE 301_Topic 7 49

Using the Gauss Quadrature Formula CISE 301_Topic 7 49

Using the Gauss Quadrature Formula CISE 301_Topic 7 50

Using the Gauss Quadrature Formula CISE 301_Topic 7 50

Improper Integrals CISE 301_Topic 7 51

Improper Integrals CISE 301_Topic 7 51