chapter 7 numerical differentiation and integration

61
N um erical A nalysis Lecture 30 N um erical N um erical A nalysis A nalysis Lecture Lecture 30 30

Upload: ronnie

Post on 14-Feb-2016

595 views

Category:

Documents


44 download

DESCRIPTION

Chapter 7 Numerical Differentiation and Integration. INTRODUCTION DIFFERENTIATION USING DIFFERENCE OPREATORS DIFFERENTIATION USING INTERPOLATION RICHARDSON’S EXTRAPOLATION METHOD NUMERICAL INTEGRATION . NEWTON-COTES INTEGRATION FORMULAE - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Chapter  7 Numerical    Differentiation  and   Integration

Numerical Analysis

Lecture 30

Numerical Numerical AnalysisAnalysis

Lecture Lecture 3030

Page 2: Chapter  7 Numerical    Differentiation  and   Integration

Chapter 7Chapter 7 Numerical Numerical

Differentiation Differentiation and Integrationand Integration

Page 3: Chapter  7 Numerical    Differentiation  and   Integration

INTRODUCTIONINTRODUCTION DIFFERENTIATION USINGDIFFERENTIATION USING DIFFERENCE OPREATORSDIFFERENCE OPREATORS DIFFERENTIATION USING DIFFERENTIATION USING INTERPOLATIONINTERPOLATION RICHARDSON’SRICHARDSON’S EXTRAPOLATION METHODEXTRAPOLATION METHOD NUMERICAL INTEGRATION NUMERICAL INTEGRATION

Page 4: Chapter  7 Numerical    Differentiation  and   Integration

NEWTON-COTESNEWTON-COTES INTEGRATION FORMULAEINTEGRATION FORMULAETHE TRAPEZOIDAL RULE THE TRAPEZOIDAL RULE

( COMPOSITE FORM )( COMPOSITE FORM )SIMPSON’S RULES SIMPSON’S RULES ( COMPOSITE FORM )( COMPOSITE FORM )ROMBERG’S INTEGRATIONROMBERG’S INTEGRATIONDOUBLE INTEGRATIONDOUBLE INTEGRATION

Page 5: Chapter  7 Numerical    Differentiation  and   Integration

DIFFERENTIATION USING DIFFERENTIATION USING INTERPOLATIONINTERPOLATION

If the given tabular function y(x) is If the given tabular function y(x) is reasonably well approximated by reasonably well approximated by a polynomial Pa polynomial Pnn(x) of degree n, it (x) of degree n, it is hoped that the result of is hoped that the result of will also satisfactorily will also satisfactorily approximate the corresponding approximate the corresponding derivative of y(x).derivative of y(x).

( )nP x

Page 6: Chapter  7 Numerical    Differentiation  and   Integration

However, even if Pn(x) and y(x) coincide at the tabular points, their derivatives or slopes may substantially differ at these points as is illustrated in the Figure below:

Page 7: Chapter  7 Numerical    Differentiation  and   Integration

Y(x)Y(x)

XXii XXOO

Deviation of derivativesDeviation of derivatives

YY PPnn(x)(x)

Page 8: Chapter  7 Numerical    Differentiation  and   Integration

For higher order For higher order derivatives, the derivatives, the deviations may be even deviations may be even worst. However, we can worst. However, we can estimate the error estimate the error involved in such an involved in such an approximation. approximation.

Page 9: Chapter  7 Numerical    Differentiation  and   Integration

For non-equidistant tabularFor non-equidistant tabularpairs (xpairs (xii, y, yii), i = 0, …, n we can), i = 0, …, n we canfit the data by using eitherfit the data by using eitherLagrange’s interpolatingLagrange’s interpolatingpolynomial or by usingpolynomial or by usingNewton’s divided differenceNewton’s divided differenceinterpolating polynomial. Ininterpolating polynomial. Inview of economy ofview of economy ofcomputation, we prefer the usecomputation, we prefer the useof the latter polynomial. of the latter polynomial.

Page 10: Chapter  7 Numerical    Differentiation  and   Integration

Thus, recalling the Thus, recalling the Newton’s divided Newton’s divided difference interpolating difference interpolating polynomial for fitting this polynomial for fitting this data as data as

Page 11: Chapter  7 Numerical    Differentiation  and   Integration

0 0 0 1

0 1 0 1 2

1

0 10

( ) [ ] ( ) [ , ] ( )( ) [ , , ]

( ) [ , ,..., ]

n

n

i ni

P x y x x x y x xx x x x y x x x

x x y x x x

Page 12: Chapter  7 Numerical    Differentiation  and   Integration

Assuming that PAssuming that Pnn(x) is a good (x) is a good approximation to y(x), the approximation to y(x), the polynomial approximation to polynomial approximation to can be obtained by can be obtained by differentiating Pdifferentiating Pnn(x). Using (x). Using product rule of differentiation, product rule of differentiation, the derivative of the products the derivative of the products in Pin Pnn(x) can be seen as follows:(x) can be seen as follows:

( )y x

Page 13: Chapter  7 Numerical    Differentiation  and   Integration

1

0

10 1

0

( )

( )( ) ( )

n

ii

nn

i i

d x xdx

x x x x x xx x

Page 14: Chapter  7 Numerical    Differentiation  and   Integration

Thus, is approximated byThus, is approximated by which is given bywhich is given by

( )y x( )nP x

0 1 1

0 0 1 2

( ) [ , ] [( )( )] [ , , ]nP x y x x x xx x y x x x

Page 15: Chapter  7 Numerical    Differentiation  and   Integration

10 1 1

0

0 1

( )( ) ( )

[ , , , ]

nn

i i

n

x x x x x xx x

y x x x

Page 16: Chapter  7 Numerical    Differentiation  and   Integration

The error estimate in this The error estimate in this approximation can be seen approximation can be seen from the following.from the following.

We have seen that if y(x) is We have seen that if y(x) is approximated by Papproximated by Pnn(x), the (x), the error estimate is shown to beerror estimate is shown to be

Page 17: Chapter  7 Numerical    Differentiation  and   Integration

( 1)

( ) ( ) ( )( ) ( )

( 1)!

n n

n

E x y x P xx y

n

Page 18: Chapter  7 Numerical    Differentiation  and   Integration

Its derivative with respect to x Its derivative with respect to x can be written ascan be written as

( 1)

( 1)

( ) ( ) ( )( ) ( )

( 1)!( ) ( )

( 1)!

n n

n

n

E x y x P xx y

nx d y

n dx

Page 19: Chapter  7 Numerical    Differentiation  and   Integration

Since ξ(x) depends on x in Since ξ(x) depends on x in an unknown way the an unknown way the derivativederivative

( 1) ( )nd ydx

Page 20: Chapter  7 Numerical    Differentiation  and   Integration

cannot be evaluated. cannot be evaluated. However, for any of the However, for any of the tabular points x = xtabular points x = xii, ∏(x) , ∏(x) vanishes and the difficult vanishes and the difficult term drops out. Thus, the term drops out. Thus, the error term in the last equation error term in the last equation at the tabular point x = xat the tabular point x = xii simplifies tosimplifies to

Page 21: Chapter  7 Numerical    Differentiation  and   Integration

( 1)

( ) Error

( ) ( )( 1)!

n i

n

i

E x

yxn

Page 22: Chapter  7 Numerical    Differentiation  and   Integration

for some ξ in the interval I for some ξ in the interval I defined by the smallest and defined by the smallest and largest of x, xlargest of x, x00, x, x11, …, x, …, xnn and and

0

0

( ) ( ) ( )

( )

i i i n

n

i jjj i

x x x x x

x x

Page 23: Chapter  7 Numerical    Differentiation  and   Integration

The error in the r-th derivative The error in the r-th derivative at the tabular points can at the tabular points can indeed be expressed indeed be expressed analogously.analogously.

To understand this method To understand this method better, we consider the better, we consider the following example.following example.

Page 24: Chapter  7 Numerical    Differentiation  and   Integration

ExampleExample Find Find and from the and from the following data using the method following data using the method based on divided differences:based on divided differences:

(0.25)f (0.22)f

Page 25: Chapter  7 Numerical    Differentiation  and   Integration

x

x

( )y f x

( )y f x

0.15 0.21 0.230.15 0.21 0.23

0.1761 0.3222 0.3617 0.1761 0.3222 0.3617

0.27 0.32 0.350.27 0.32 0.35

0.4314 0.5051 0.54410.4314 0.5051 0.5441

Page 26: Chapter  7 Numerical    Differentiation  and   Integration

SolutionSolution We first construct We first construct divided difference table for the divided difference table for the given data as shown below:given data as shown below:

Page 27: Chapter  7 Numerical    Differentiation  and   Integration

1st divided1st divideddifferencedifferencex y 2nd divided2nd divided

differencedifference3rd divided3rd divideddifferencedifference

0.150.150.210.210.230.230.270.270.320.320.350.35

0.17610.17610.32220.32220.36170.36170.43140.43140.50510.50510.54410.5441

2.43502.43501.97501.97501.74251.74251.47401.47401.30001.3000

––5.75005.7500––3.87503.8750––2.98332.9833––2.17502.1750

15.625015.6250 8.10648.1064 6.73586.7358

Page 28: Chapter  7 Numerical    Differentiation  and   Integration

Using divided difference Using divided difference formulaformula

10 1 1

0

0 1

( )( ) ( )

[ , , , ]

nn

i i

n

x x x x x xx x

y x x x

Page 29: Chapter  7 Numerical    Differentiation  and   Integration

from a quadratic polynomial, from a quadratic polynomial, we havewe have

3

0 1 1

0 0 1 2

( ) ( )[ , ] {( )

( )} [ , , ]

y x P xy x x x xx x y x x x

Page 30: Chapter  7 Numerical    Differentiation  and   Integration

1 2 0 2

0 1 0 1 2 3

{( )( ) ( )( ) ( )( )} [ , ,

, ]x x x x x x x xx x x x y x x x x

Page 31: Chapter  7 Numerical    Differentiation  and   Integration

Thus, using first, second and Thus, using first, second and third differences from the third differences from the table, the above equation table, the above equation yieldsyields

Page 32: Chapter  7 Numerical    Differentiation  and   Integration

(0.25)2.4350 [(0.25 0.21)(0.25 0.15)]( 5.75)

y

Page 33: Chapter  7 Numerical    Differentiation  and   Integration

[(0.25 0.21)(0.25 0.23)(0.25 0.15)(0.25 0.23)(0.25 0.15)(0.25 0.21)]

(15.625)

Page 34: Chapter  7 Numerical    Differentiation  and   Integration

Therefore,Therefore,

Similarly, we can show thatSimilarly, we can show that

(0.25) 2.4350 0.805 0.10625 1.7363f

(0.22) 1.9734f

Page 35: Chapter  7 Numerical    Differentiation  and   Integration

RICHARDSON’S EXTRAPOLATION RICHARDSON’S EXTRAPOLATION METHOD METHOD

To improve the accuracy of the derivative of a function, which is computed by starting with an arbitrarily selected value of h, Richardson’s extrapolation method is often employed in practice, in the following manner:

Page 36: Chapter  7 Numerical    Differentiation  and   Integration

Suppose we use two-point Suppose we use two-point formula to compute the formula to compute the derivative of a function, then derivative of a function, then we havewe have

( ) ( )( )2

( )

T

T

y x h y x hy x Eh

F h E

Page 37: Chapter  7 Numerical    Differentiation  and   Integration

where Ewhere ETT is the truncation error. is the truncation error. Using Taylor’s series Using Taylor’s series expansion, we can see thatexpansion, we can see that

2 41 2

63

TE c h c h

c h

Page 38: Chapter  7 Numerical    Differentiation  and   Integration

The idea of Richardson’s The idea of Richardson’s extrapolation is to combine two extrapolation is to combine two computed values of using computed values of using the same method but with two the same method but with two different step sizes usually h different step sizes usually h and h/2 to yield a higher order and h/2 to yield a higher order method. Thus, we have method. Thus, we have

( )y x

Page 39: Chapter  7 Numerical    Differentiation  and   Integration

andand

2 41 2( ) ( )y x F h c h c h

2 4

1 2( )2 4 16h h hy x F c c

Page 40: Chapter  7 Numerical    Differentiation  and   Integration

Here, cHere, cii are constants, are constants, independent of h, and F(h) independent of h, and F(h) and F(h/2) represent and F(h/2) represent approximate values of approximate values of derivatives. Eliminating cderivatives. Eliminating c11 from the above pair of from the above pair of equations, we get equations, we get

Page 41: Chapter  7 Numerical    Differentiation  and   Integration

4 61

( )

4 ( )2 ( )

3

y xhF F h

d h O h

Page 42: Chapter  7 Numerical    Differentiation  and   Integration

Now, assumingNow, assuming

1 2

4 ( )2

3

hF

hF F h

Page 43: Chapter  7 Numerical    Differentiation  and   Integration

Equation for y’(x) above Equation for y’(x) above reduces toreduces to

4 61 1( ) ( )

2hy x F d h O h

Page 44: Chapter  7 Numerical    Differentiation  and   Integration

Thus, we have obtained a Thus, we have obtained a fourth-order accurate fourth-order accurate differentiation formula by differentiation formula by combining two results which combining two results which are of second-order accurate. are of second-order accurate. Now, repeating the above Now, repeating the above argument, we have argument, we have

Page 45: Chapter  7 Numerical    Differentiation  and   Integration

4 61 1( ) ( )

2hy x F d h O h

Page 46: Chapter  7 Numerical    Differentiation  and   Integration

461

1( ) ( )4 16

d hhy x F O h

Page 47: Chapter  7 Numerical    Differentiation  and   Integration

Eliminating dEliminating d11 from the above from the above pair of equations, we get a pair of equations, we get a better approximation asbetter approximation as

62( ) ( )

4hy x F O h

Page 48: Chapter  7 Numerical    Differentiation  and   Integration

which is of sixth-order which is of sixth-order accurate, whereaccurate, where

2

21 12

2

4

42 2 4 1

hF

h hF F

Page 49: Chapter  7 Numerical    Differentiation  and   Integration

This extrapolation process can be repeated further until the required accuracy is achieved, which is called an extrapolation to the limit. Therefore the equation for F2 above can be generalized as

Page 50: Chapter  7 Numerical    Differentiation  and   Integration

1 1 1

2

42 2 ,

4 1 1,2,3,

m m

mm mm m

m

hF

h hF F

m

Page 51: Chapter  7 Numerical    Differentiation  and   Integration

where Fwhere F00(h) = F(h). (h) = F(h).

To illustrate this procedure, we To illustrate this procedure, we consider the following consider the following example. example.

Page 52: Chapter  7 Numerical    Differentiation  and   Integration

Example: Using the Example: Using the Richardson’s extrapolation Richardson’s extrapolation limit, find y’(0.05) to the function limit, find y’(0.05) to the function y = -1/x, with h = 0.0128, y = -1/x, with h = 0.0128, 0.0064, 0.0032. 0.0064, 0.0032.

SolutionSolution To start with, we take, To start with, we take, h = 0.0128, then compute F (h) h = 0.0128, then compute F (h) asas

Page 53: Chapter  7 Numerical    Differentiation  and   Integration

( ) ( )( )21 1

0.05 0.0128 0.05 0.0128 2(0.0128)

y x h y x hF hh

Page 54: Chapter  7 Numerical    Differentiation  and   Integration

15.923566 26.881720.0256

428.05289

Page 55: Chapter  7 Numerical    Differentiation  and   Integration

Similarly, F(h/2) = 406.66273. Similarly, F(h/2) = 406.66273. Therefore, using Eq. (7.30), we Therefore, using Eq. (7.30), we getget

1

42 2

2 4 1 399.5327

h hF FhF

Page 56: Chapter  7 Numerical    Differentiation  and   Integration

which is accurate to O(hwhich is accurate to O(h44). ). Halving the step size further, Halving the step size further, we computewe compute

221 1

0.05 0.0032 0.05 0.00322(0.0032)

401.64515

hF

Page 57: Chapter  7 Numerical    Differentiation  and   Integration

and and

1 2

2

2

42 2

4 1399.97263

hF

h hF F

Page 58: Chapter  7 Numerical    Differentiation  and   Integration

Again, using Eq. , we obtainAgain, using Eq. , we obtain

2 2

21 12

2

2

42 24 1

400.00195

hF

h hF F

Page 59: Chapter  7 Numerical    Differentiation  and   Integration

h F Fh F F1 1 FF220.0128 428.0529 0.0128 428.0529 399.5327 399.5327 0.0064 406.6627 0.0064 406.6627 400.00195 400.00195 399.9726 399.9726 0.0032 401.64520.0032 401.6452

The above computation can be The above computation can be summarized in the following table:summarized in the following table:

Page 60: Chapter  7 Numerical    Differentiation  and   Integration

Thus, after two steps, it is Thus, after two steps, it is found that found that while while the exact value isthe exact value is

(0.05) 400.00915y

20.05

1(0.05)

1 = 4000.0025

x

yx

Page 61: Chapter  7 Numerical    Differentiation  and   Integration

Lecture 30Lecture 30

Numerical Analysis

Numerical Analysis