applied numerical methods lec10

64
1 Numerical integration

Upload: ymaa1975ma

Post on 14-Aug-2015

93 views

Category:

Engineering


4 download

TRANSCRIPT

Page 1: Applied numerical methods lec10

1

Numerical integration

Page 2: Applied numerical methods lec10

2

Methods for Numerical Integration

Page 3: Applied numerical methods lec10

3

Newton -Cotes FormulasApproximate integrand function f(x) by a polynomial that can then be easily integrated

Page 4: Applied numerical methods lec10

4

Newton-Cotes Quadrature

Page 5: Applied numerical methods lec10

5

The Trapezoidal Rule

( ) ( )dxxfdxxfb

a

b

a ∫∫ ≅= 1I

( ) ( ) ( ) ( ) ( )a-xa-b

afbfafxf

−+=1

( ) ( ) ( ) ( ) ( ) ( ) ( )2

bfafabdxa-x

a-b

afbfafI

b

a

+−=

−+= ∫

All the Newton-Cotes formulas can be expressed in this general average height form

heightaveragewidthI ×≅

Page 6: Applied numerical methods lec10

Example 1 Single Application of the Trapezoidal Rule

f(x) = 0.2 +25x – 200x2 + 675x3 – 900x4 + 400x5

Integrate f(x) from a=0 to b=0.8

%. ...E

...

.

)()()(

tt

:oferror an represents which

:Rule lTrapezoida

58946773117280640531

172802

23202080

2

==−=

=+=

+−=

ε

bfafabI

∫=

=

==80

0

640531.

.)( :value integral Trueb

a

dxxfI

Solution: f(a)=f(0) = 0.2 and f(b)=f(0.8) = 0.232

Page 7: Applied numerical methods lec10

7

• The accuracy can be improved by dividing the interval from a to b into a number of segments and applying the method to each segment.

• The areas of individual segments are added to yield the integral for the entire interval.

Using the trapezoidal rule, we get:

∫∫∫−

+++=

===−=

n

n

x

x

x

x

x

x

n

dxxfdxxfdxxfI

xbxan

abh

1

2

1

1

0

)()()(

seg. of # n 0

L

++−=

++++++=

∑−

=

1

10

12110

22

222n

iin

nn

xfxfxfnab

I

xfxfh

xfxfh

xfxfhI

)()()(

)()()()()()(L

The Multiple-Application Trapezoidal Rule

Page 8: Applied numerical methods lec10

8

Page 9: Applied numerical methods lec10

Example 2

Page 10: Applied numerical methods lec10

10

Page 11: Applied numerical methods lec10

11

Example 3

Page 12: Applied numerical methods lec10

12

Page 13: Applied numerical methods lec10

Example 4

The vertical distance covered by a rocket from to seconds is given by:

−=

30

8

892100140000

1400002000 dtt.

tlnx

a) Use two-segment Trapezoidal rule to find the distance covered.b) Find the true error, for part (a).c) Find the absolute relative true error, for part (a). a∈

tE

Page 14: Applied numerical methods lec10

Solution

a) The solution using 2-segment Trapezoidal rule is

+

++−= ∑

=)b(f)iha(f)a(f

n

abI

n

i

1

1

22

2=n 8=a 30=b

2

830−=n

abh

−= 11=

Page 15: Applied numerical methods lec10

Solution (cont)

+

++−= ∑

=)(f)iha(f)(f

)(I

i

302822

830 12

1

[ ])(f)(f)(f 3019284

22 ++=

[ ]67901754842271774

22.).(. ++=

m11266=

Then:

Page 16: Applied numerical methods lec10

Solution (cont)

−=

30

8

892100140000

1400002000 dtt.

tlnx m11061=

b) The exact value of the above integral is

so the true error is

ValueeApproximatValueTrueEt −=

1126611061−=

Page 17: Applied numerical methods lec10

Solution (cont)

The absolute relative true error, , would bet∈

100Value True

Error True ×=∈t

10011061

1126611061 ×−=

%8534.1=

Page 18: Applied numerical methods lec10

Solution (cont)

Table 1 gives the values obtained using multiple segment Trapezoidal rule for

n Value Et

1 11868 -807 7.296 ---

2 11266 -205 1.853 5.343

3 11153 -91.4 0.8265 1.019

4 11113 -51.5 0.4655 0.3594

5 11094 -33.0 0.2981 0.1669

6 11084 -22.9 0.2070 0.09082

7 11078 -16.8 0.1521 0.05482

8 11074 -12.9 0.1165 0.03560

=30

8

892100140000

1400002000 dtt.

tlnx

Table 1: Multiple Segment Trapezoidal Rule Values

%t∈ %a∈

Exact Value=11061 m

Page 19: Applied numerical methods lec10

19

Example 5

Page 20: Applied numerical methods lec10
Page 21: Applied numerical methods lec10

21

Example 6

Page 22: Applied numerical methods lec10

22

Page 23: Applied numerical methods lec10

23

Page 24: Applied numerical methods lec10

)()( )(

)(2

2

1212

2

21

2

1

≅⇒≅

h

hhEhE

h

h

hE

hE

Romberg IntegrationSuccessive application of the trapezoidal rule to attain efficient numerical integrals of functions.

Richardson’s Extrapolation:Uses two estimates of an integral to compute a third and more accurate approximation.

sizes) stepdifferent for constant is (assume

)()()()(

/)( /)( )()(

)2

(2

12

2211

fhOfhab

E

hEhIhEhI

habnnabhhEhII

′′=′′−

+=+−=−=+=

I = exact value of integral E(h) = the truncation error

I(h): trapezoidal rule (n segments, step size h)

Improved estimate of the integral. It is shown that the error of thisestimate is O(h4). Trapezoidal rule had an error estimate of O(h2). ( ) [ ])()(

/)(

)()(

12221

2

22

1

1hIhI

hhhII

hEhII

−−

+≅

+=

( ) ( ) 1/

)()()( )()(/)()( 2

21

12222

22121 −

−≅⇒+≅+hh

hIhIhEhEhIhhhEhI

Page 25: Applied numerical methods lec10

25

( ) [ ] )()(1/

1)( 122

21

2 hIhIhh

hII −−

+≅

Example 7Evaluate the integral of f(x) = 0.2 +25x – 200x2 + 675x3 – 900x4 + 400x5

from a=0 to b=0.8. I (True Integral value) = 1.6405

Segments h Integral εtr%

1 0.8 0.1728 89.5

2 0.4 1.0688 34.9

4 0.2 1.4848 9.5

%)6.16( 0.2733675.16405.1E

3675.1)1728.0(3

1)0688.1(

3

4

:give tocombined 2 & 1 Segments

tt ==−=

=−≅

ε

I

In each case, two estimates with error O(h2) are combined to give a third estimate with error O(h4)

%)1( 0.01716234.16405.1E

6234.1)0688.1(3

1)4848.1(

3

4

:give tocombined 4 & 2 Segments

tt ==−=

=−≅

ε

I

)2/( If 12 ⇒= hh [ ] )(3

1)(

3

4)()(

12

1)( 121222 hIhIhIhIhII −=−

−+≅

Page 26: Applied numerical methods lec10

26

Simpson’s Rules

General idea:

Use high order polynomials other than trapezoids to achieve more accurate integration result but using the similar amountof computation

Parabola Cubic polynomial

Page 27: Applied numerical methods lec10

• More accurateestimate of an integral is obtained if a high-order polynomial is used to connect the points. These formulas are called Simpson’s rules.

Simpson’s 1/3 Rule: results when a 2nd order Lagrange interpolating polynomialis used for f(x)

dxxfxxxx

xxxxxf

xxxx

xxxxxf

xxxx

xxxxI

dxxfdxxfI

x

x

b

a

b

a

xbxa

xf

∫ ∫

−−−−+

−−−−+

−−−−=

≅=

==

2

0

)())((

))(()(

))((

))(()(

))((

))((

)()(

21202

101

2101

200

2010

21

20

2

Using

.polynomialorder -second a is )(2 where

[ ] RULE 1/3 SSIMPSON' 2

)()(4)(3 210

:results formula following theon,manipulati algebraic andn integratioafter

⇐−=++≅ abhxfxfxf

hI

a=x0 x1 b=x2

Simpson’s Rules

Page 28: Applied numerical methods lec10

28

[ ] RULE 1/3 SSIMPSON' 2

)()(4)(3 210

:results formula following theon,manipulati algebraic andn integratioafter

⇐−=++≅ abhxfxfxf

hI

Page 29: Applied numerical methods lec10

29

Page 30: Applied numerical methods lec10

30

Trapezoidal vs. Simpson’s 1/3 Rule

( ) ( ) ( ) ( )3674671

28080 .

...I =++=++≅

6

0.2322.45640

6

0.8f0.44f0f

%.616=→== tt 0.2730667 1.367467 - 1.640533E ε

Trapezoidal:

Example: f(x) = 0.2 + 25x – 200x2 + 675x3 – 900x4 + 400x5 (integral between a=0 and b=0.8)

( ) ( ) ( )0.1728

2

0.8f0f00.8 =+−≅I

Et = 1.640533 – 0.1728 = 1.467733 � εt = 89.5%

Simpson’s 1/3 rule:

Page 31: Applied numerical methods lec10

31

Example 8

Page 32: Applied numerical methods lec10

32

Multiple Application of Simpson’s 1/3 Rule

Page 33: Applied numerical methods lec10

33

Example 9

Page 34: Applied numerical methods lec10

34

Example 10

Page 35: Applied numerical methods lec10

35

Page 36: Applied numerical methods lec10

36

Example 11

Page 37: Applied numerical methods lec10

37

Page 38: Applied numerical methods lec10

38

[ ]

8

)()(3)(3)()(

)()(3)(3)(8

3

)()(

3210

3210

3

3

)(

xfxfxfxfabI

xfxfxfxfh

I

dxxfdxxfI

abh

b

a

b

a

+++−≅

+++≅

≅=

−=

∫ ∫

Simpson’s 3/8 Rule

Simpson’s 1/3 and 3/8 rules can be applied in tandem to handle multiple applications with odd number of intervals

Fit a 3rd order Lagrange interpolating polynomial to four points and integrate

Page 39: Applied numerical methods lec10

39

Example 12

Page 40: Applied numerical methods lec10

40

Page 41: Applied numerical methods lec10

41

Example 13

Page 42: Applied numerical methods lec10

42

Page 43: Applied numerical methods lec10

Gauss Quadrature

• Gauss quadrature implements a strategy of positioning any two points on a curve to define a straight line that would balance the positive and negative errors.

• Hence the area evaluated under this straight line provides an improved estimate of the integral.

Page 44: Applied numerical methods lec10

44

Gauss Quadrature (cont.)

Page 45: Applied numerical methods lec10

45

Gauss Quadrature (cont.)

Page 46: Applied numerical methods lec10

Method of Undetermined Coefficients

• The trapezoidal rule yields exact results when the function being integrated is a constant or a straight line, such as y=1 and y=x:

)()( 10 bfcafcI +≅

)(2

)(2

2

022

22

110

10

10

10

2/)(

2/)(

10

2/)(

2/)(

bfab

afab

I

abcc

abc

abc

abcc

dxxab

cab

c

dxcc

ab

ab

ab

ab

−+−=

−==

=−+−−

−=+

=−+−−

=+

∫−

−−

−−

Solve simultaneously

Trapezoidal rule

Page 47: Applied numerical methods lec10

47

Derivation of the Two-Point Gauss-Legendre Formula/

• The object of Gauss quadrature is to determine the equations of the form

• However, in contrast to trapezoidal rule that uses fixed end points a and b, the function arguments x0 and x1 are not fixed end points but unknowns.

• Thus, four unknowns to be evaluated require four conditions.

• First two conditions are obtained by assuming that the above eqn. for I fits the integral of a constant and a linear function exactly.

• The other two conditions are obtained by extending this reasoning to a parabolic and a cubic functions.

)()( 1100 xfcxfcI +≅

Page 48: Applied numerical methods lec10

Solved simultaneously

+

−≅

−==

−=−=

==

3

1

3

1

5773503.03

1

5773503.03

1

1

1

0

10

ffI

x

x

cc

K

K

Yields an integral estimate that is third

order accurate

Page 49: Applied numerical methods lec10

49

Two-Point Gauss-Legendre Formula(arbitrary a and b)

( ) ( )b x x

a x - x

2

xababx

d

dd

=→==→=

−++

=1

1

( )∫=b

adxxfI

( ) ( ) ( ) ( )∫

=

=

−++

−++=

1x

-1xddd

d 2

xababd

2

xababfI

( ) ( )∫

−++−=1

1- dd dx

2

xababf

2

abI

Page 50: Applied numerical methods lec10

50

Example of Two-Point Gauss-Legendre Formula

( ) 82257812645925329185251403

1

3

140 ....ff.I dd =+=

+

−=

( ) ( )∫∫ +==1

1-

0.8

0 dd dx0.4x0.4f0.4dxxfI

( )∫=1

1- ddd dxxf40.I

Example14: f(x) = 0.2 + 25x – 200x2 + 675x3 – 900x4 + 400x5 (integral between a=0 and b=0.8)

x = 0.4 + 0.4xd

dx = 0.4 dxd

( ) ( ) ( ) ( ) ( )[ ]∫ +++−+++−++=1

1- dddddd dx0.4x0.40.4x0.40.4x0.40.4x0.40.4x0.4250.20.4 543 400900675200 2I

( ) ( )b x x

a x - x

2

xababx

d

dd

=→==→=

−++

=1

1

)()( 1100 xfcxfcI +≅

Page 51: Applied numerical methods lec10

51

Higher-Point Gauss-Legendre Formula

( ) ( ) ( )[ ]2d21d10d0 xfcxfcxfc ++= 40.I

( ) ( ) ( ) ( )

44444444 344444444 21

L

44444 344444 21

444 3444 21

pointn

1-n1-n

pointthree

22

pointtwo

1100 xfcxfcxfcxfc

++++≅I

( )∫=1

1- ddd dxxf40.I

Example: f(x) = 0.2 + 25x – 200x2 + 675x3 – 900x4 + 400x5 (integral between a=0 and b=0.8)

Three-point Gauss-Legendre formula: c0 = 0.5555556 x0 = - 0.774596669 c1 = 0.8888889 x1 = 0.0c2 = 0.5555556 x2 = 0.774596669

( ) ( ) ( )[ ].77459669f0.5555560f0.88888890.77459669-f0.5555560.4 ddd ++=I

1.640533

Page 52: Applied numerical methods lec10

52

Page 53: Applied numerical methods lec10

53

Example 15

Page 54: Applied numerical methods lec10

54

( ) 543376.0318386.0768365.05.03

1

3

15.0 =+=

+

−= dd ffI

( ) ( ) ( )( )( ) 0.5405910.275778*0.55555560.494845*0.88888890.878598*0.55555565.0

90.77459666*0.55555560.0*0.888888990.77459666-*0.55555565.0

=++=++= ddd fffI

Page 55: Applied numerical methods lec10

55

Gauss QuadratureGauss-Chebyshev Formula

Page 56: Applied numerical methods lec10

56

Gauss QuadratureGauss-Hermite Formula

Page 57: Applied numerical methods lec10

57

Integration Using Matlab

Approximation of Double Integrals Using Matlab

Page 58: Applied numerical methods lec10

58

Miscellaneous problems #1

Page 59: Applied numerical methods lec10

59

Page 60: Applied numerical methods lec10

60

Miscellaneous problems #2

Page 61: Applied numerical methods lec10

61

Page 62: Applied numerical methods lec10

62

Page 63: Applied numerical methods lec10

63

Special Problem 7

Page 64: Applied numerical methods lec10

Homework

64

1.

2.

3.

4.

5.

6.