Chapter 7 Numerical Differentiation and Integration

Post on 14-Feb-2016

593 views 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 of Chapter 7 Numerical Differentiation and Integration

Numerical Analysis

Lecture 30

Numerical Numerical AnalysisAnalysis

Lecture Lecture 3030

Chapter 7Chapter 7 Numerical Numerical

Differentiation Differentiation and Integrationand Integration

INTRODUCTIONINTRODUCTION DIFFERENTIATION USINGDIFFERENTIATION USING DIFFERENCE OPREATORSDIFFERENCE OPREATORS DIFFERENTIATION USING DIFFERENTIATION USING INTERPOLATIONINTERPOLATION RICHARDSON’SRICHARDSON’S EXTRAPOLATION METHODEXTRAPOLATION METHOD NUMERICAL INTEGRATION NUMERICAL 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

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

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:

Y(x)Y(x)

XXii XXOO

Deviation of derivativesDeviation of derivatives

YY PPnn(x)(x)

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.

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.

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

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

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

1

0

10 1

0

( )

( )( ) ( )

n

ii

nn

i i

d x xdx

x x x x x xx x

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

10 1 1

0

0 1

( )( ) ( )

[ , , , ]

nn

i i

n

x x x x x xx x

y x x x

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

( 1)

( ) ( ) ( )( ) ( )

( 1)!

n n

n

E x y x P xx y

n

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

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

( 1) ( )nd ydx

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

( 1)

( ) Error

( ) ( )( 1)!

n i

n

i

E x

yxn

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

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.

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

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

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:

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

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

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

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

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

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

y

[(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)

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

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:

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

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

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

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

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

4 61

( )

4 ( )2 ( )

3

y xhF F h

d h O h

Now, assumingNow, assuming

1 2

4 ( )2

3

hF

hF F h

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

4 61 1( ) ( )

2hy x F d h O h

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

4 61 1( ) ( )

2hy x F d h O h

461

1( ) ( )4 16

d hhy x F O h

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

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

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

1 1 1

2

42 2 ,

4 1 1,2,3,

m m

mm mm m

m

hF

h hF F

m

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.

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

( ) ( )( )21 1

0.05 0.0128 0.05 0.0128 2(0.0128)

y x h y x hF hh

15.923566 26.881720.0256

428.05289

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

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

and and

1 2

2

2

42 2

4 1399.97263

hF

h hF F

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

2 2

21 12

2

2

42 24 1

400.00195

hF

h hF F

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:

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

Lecture 30Lecture 30

Numerical Analysis

Numerical Analysis