46
Lecture 37 Numerica l Analysis

Lecture 37

  • Upload
    frey

  • View
    44

  • Download
    1

Embed Size (px)

DESCRIPTION

Numerical Analysis. Lecture 37. Chapter 7 Ordinary Differential Equations. Introduction Taylor Series Euler Method Runge-Kutta Method Predictor Corrector Method. TAYLOR’S SERIES METHOD. We considered an initial value problem described by. - PowerPoint PPT Presentation

Citation preview

Page 1: Lecture 37

Lecture 37Lecture 37

NumericalAnalysis

NumericalAnalysis

Page 2: Lecture 37

Chapter 7Ordinary

Differential Equations

Chapter 7Ordinary

Differential Equations

Page 3: Lecture 37

IntroductionIntroductionTaylor SeriesTaylor SeriesEuler MethodEuler MethodRunge-Kutta MethodRunge-Kutta MethodPredictor Corrector Predictor Corrector MethodMethod

Page 4: Lecture 37

TAYLOR’S TAYLOR’S SERIESSERIES

METHODMETHOD

Page 5: Lecture 37

We considered an initial value We considered an initial value problem described byproblem described by

0 0( , ), ( )dy

f t y y t ydt

Page 6: Lecture 37

We expanded We expanded y y ((t t ) by Taylor’s ) by Taylor’s series about the point series about the point tt = = tt00

and obtain and obtain

20

0 0 0 0

( )( ) ( ) ( ) ( ) ( )

2!

t ty t y t t t y t y t

3 40 0

0 0

( ) ( )( ) ( )

3! 4!IVt t t t

y t y t

Page 7: Lecture 37

Noting that Noting that ff is an implicit is an implicit function of function of yy, we have, we have

( , )

x y

y f t y

f f dyy f ff

x y dx

Page 8: Lecture 37

SimilarlySimilarly

2

2

2

2

( ) ( )

2 ( )

3 3

( 2 )

3( )( )

( )

xx xy xy yy y x y

xx xy yy y x y

IVxxx xxx xyy

y xx xy yy

x y xy yy

y x y

y f ff f f ff f f ff

f ff f f f f ff

y f ff f f

f f ff f f

f ff ff ff

f f ff

Page 9: Lecture 37

EULER EULER METHODMETHOD

Page 10: Lecture 37

Consider the differential Consider the differential equation of first order with equation of first order with the initial condition the initial condition yy((tt00) = ) = yy00..

( , )dy

f t ydt

Page 11: Lecture 37

The value of y corresponding The value of y corresponding to to tt = = tt11

1 0 1 0 0 0( ) ( , )y y t t f t y

Page 12: Lecture 37

SimilarlySimilarly

2 1 1 1( , )y y hf t y

Page 13: Lecture 37

Then, we obtained the Then, we obtained the solution in the form of a solution in the form of a recurrence relationrecurrence relation

1 ( , )m m m my y hf t y

Page 14: Lecture 37

MODIFIED MODIFIED EULER’S EULER’S METHODMETHOD

Page 15: Lecture 37

The recurrence relationThe recurrence relation

(1)1 1

1

( , ) ( , )

2m m m m

m m

f t y f t yy y h

is the is the modified Euler’s modified Euler’s methodmethod..

Page 16: Lecture 37

RUNGE – RUNGE – KUTTA KUTTA

METHODMETHOD

Page 17: Lecture 37

These are computationally, These are computationally, most efficient methods in most efficient methods in terms of accuracy. They terms of accuracy. They were developed by two were developed by two German mathematicians, German mathematicians, Runge and Kutta. Runge and Kutta.

Page 18: Lecture 37

They are distinguished by They are distinguished by their orders in the sense that their orders in the sense that they agree with Taylor’s they agree with Taylor’s series solution up to terms of series solution up to terms of hhrr, where , where rr is the order of the is the order of the method. These methods do method. These methods do not demand prior not demand prior computation of higher computation of higher derivatives of y(t) as in TSM.derivatives of y(t) as in TSM.

Page 19: Lecture 37

Fourth-order Runge-Kutta Fourth-order Runge-Kutta methods are widely used for methods are widely used for finding the numerical finding the numerical solutions of linear or non-solutions of linear or non-linear ordinary differential linear ordinary differential equations, the development of equations, the development of which is complicated which is complicated algebraically. algebraically.

Page 20: Lecture 37

Therefore, we convey the Therefore, we convey the basic idea of these methods basic idea of these methods by developing the second-by developing the second-order Runge-Kutta method order Runge-Kutta method which we shall refer hereafter which we shall refer hereafter as R-K method.as R-K method.

Page 21: Lecture 37

Please recall that the modified Please recall that the modified Euler’s method: which can be Euler’s method: which can be viewed asviewed as

1n ny y h (average of slopes) (average of slopes)

This, in fact, is the basic idea This, in fact, is the basic idea of R-K method. of R-K method.

Page 22: Lecture 37

Here, we find the slopes not Here, we find the slopes not only at only at ttnnbut also at several but also at several

other interior points, and take other interior points, and take the weighted average of these the weighted average of these slopes and add to slopes and add to yynn to get to get

yyn+1n+1. Now, we shall derive the . Now, we shall derive the

second order R-K method in second order R-K method in the following slides.the following slides.

Page 23: Lecture 37

Consider the IVPConsider the IVP

( , ), ( )n n

dyf t y y t y

dt

We also define We also define

1 2 1( , ), ( , )n n n nk hf t y k hf t h y k

and take the weighted and take the weighted average of average of kk1 1 and and kk2 2 and add and add

to to yynn to get to get yyn+1n+1

Page 24: Lecture 37

We seek a formula of the We seek a formula of the formform

1 1 1 2 2n ny y W k W k

Where Where are constants are constants to be determined so that the to be determined so that the above equation agree with the above equation agree with the Taylor’s series expansion as Taylor’s series expansion as high an order as possiblehigh an order as possible

1 2, ,W and W

Page 25: Lecture 37

Thus, using Taylor’s series Thus, using Taylor’s series expansion, we haveexpansion, we have

1

2 3

( ) ( ) ( )

( ) ( )2 6

n n n

n n

y t y t hy t

h hy t y t

Page 26: Lecture 37

Rewriting the derivatives of Rewriting the derivatives of y in terms of y in terms of ff of the above of the above equation, we getequation, we get

2

1 ( , ) ( )2n n n n t y

hy y hf t y f ff

32 42 ( ) ( )

6 tt ty yy y t y

hf ff f f f f ff O h

Here, all derivatives are Here, all derivatives are evaluated at (evaluated at (ttnn, , yynn).).

Page 27: Lecture 37

Next, we shall rewrite the given Next, we shall rewrite the given equation after inserting the equation after inserting the expressions or expressions or kk1 1 and and kk22 as as

1 1

2 1

( , )

( , )n n n n

n n

y y W hf t y

W hf t h y k

Page 28: Lecture 37

Now using Taylor’s series Now using Taylor’s series expansion of two variables, we expansion of two variables, we obtainobtain

1 1

2 1

( , )

( , ) ( )

n n n n

n n t y

y y W hf t y

W h f t y hf k f

2 22 2

311 ( )

2 2n ty yy

khf h k f f O h

Page 29: Lecture 37

Here again, all derivatives are Here again, all derivatives are computed at (computed at (ttnn, , yynn). On ). On

inserting the expression for inserting the expression for kk11, the above equation , the above equation

becomesbecomes1 1 2 2( ) ( )n n t yy y W W hf W h hf hff

2 2 2 22 2 3( )

2 2tt ty yy

h hf h ff f f O h

Page 30: Lecture 37

On rearranging in the On rearranging in the increasing powers of increasing powers of hh, we get, we get

21 1 2 2( ) ( )n n t yy y W W hf W h f ff

2 223 4

2 ( )2 2

ytt ty

f ffW h f ff O h

Page 31: Lecture 37

Now, equating coefficients of Now, equating coefficients of hh and and hh22 in the two equations, in the two equations, we obtainwe obtain

1 2 21, ( )2

t yt y

f ffW W W f ff

ImplyingImplying

1 2 2 2

11,

2W W W W

Page 32: Lecture 37

Thus, we have three equations Thus, we have three equations in four unknowns and so, we in four unknowns and so, we can chose one value can chose one value arbitrarily. Solving we getarbitrarily. Solving we get

1 22 2

1 11 , ,

2 2W W

W W

where Wwhere W22 is arbitrary and various is arbitrary and various

values can be assigned to itvalues can be assigned to it

Page 33: Lecture 37

We now consider two cases, We now consider two cases, which are popularwhich are popular

Case ICase I If we choose WIf we choose W22 = 1/3, = 1/3,

then Wthen W11 = 2/3 and = 2/3 and 3/ 2.

1 1 2

1(2 )

3n ny y k k

1 2 1

3 3( , ), ,

2 2k hf t y k hf t h y k

Page 34: Lecture 37

Case II: If we consider Case II: If we consider WW22 = ½, then = ½, then WW11 = ½ and = ½ and

1.

ThenThen1 2

1 2n n

k ky y

1 2 1( , ), ( , )k hf t y k hf t h y k

Page 35: Lecture 37

In fact, we can recognize that In fact, we can recognize that this equation is the modified this equation is the modified Euler’s method and is Euler’s method and is therefore a special case of a 2therefore a special case of a 2ndnd order Runge-Kutta method. order Runge-Kutta method. These equations are known as These equations are known as 22ndnd order R –K Methods, since order R –K Methods, since they agree with Taylor’s series they agree with Taylor’s series solution up to the term solution up to the term hh22..

Page 36: Lecture 37

Defining the local truncation Defining the local truncation error, TE, as the difference error, TE, as the difference between the exact solution between the exact solution yy((ttn+1n+1) at ) at tt = = ttn+1n+1 and the and the

numerical solution numerical solution yyn+1n+1, ,

obtained using the second obtained using the second order R – K method, we haveorder R – K method, we have

1 1( )n nTE y t y

Page 37: Lecture 37

Now, substitutingNow, substituting

2 1

1 1, 1 , ,

2 2W W

2

1 ( )2 nn n tt t y t t

hy y hf f ff

32( 2 )

4 ntt ty yy t t

hf ff f f

into the above equation, we getinto the above equation, we get

Page 38: Lecture 37

Finally, we obtainFinally, we obtain

3 21 1( 2 ) ( )

6 4 6tt ty yy y t yTE h f ff f f f f ff

The expression can further The expression can further be simplified tobe simplified to

3 1 1( )

6 4 6y yTE h y f y f y

Page 39: Lecture 37

Therefore, the expression for Therefore, the expression for local truncation error is given local truncation error is given byby 3 1

6 4 4 yTE h y f y

Please verify that the Please verify that the magnitude of the TE in case I magnitude of the TE in case I is less than that of case IIis less than that of case II

Page 40: Lecture 37

Following similar procedure, Following similar procedure, Runge-Kutta formulae of any Runge-Kutta formulae of any order can be obtained. order can be obtained. However, their derivations However, their derivations becomes exceedingly becomes exceedingly lengthy and complicated.lengthy and complicated.

Page 41: Lecture 37

Amongst them, the most Amongst them, the most popular and commonly popular and commonly used in practice is the R-K used in practice is the R-K method of fourth-order, method of fourth-order, which agrees with the which agrees with the Taylor series method up to Taylor series method up to terms of terms of O O ((hh44). ).

Page 42: Lecture 37

This well-known fourth-This well-known fourth-order R-K method is order R-K method is described in the described in the following steps.following steps.

1 1 2 3 4

1( 2 2 )

6n ny y k k k k

Page 43: Lecture 37

1

12

23

4 3

( , )

,2 2

,2 2

( , )

n n

n n

n n

n n

k hf t y

khk hf t y

khk hf t y

k hf t h y k

wherewhere

Page 44: Lecture 37

Please note that the second-Please note that the second-order Runge-Kutta method order Runge-Kutta method described above requires described above requires the evaluation of the the evaluation of the function twice for each function twice for each complete step of complete step of integration. integration.

Page 45: Lecture 37

Similarly, fourth-order Similarly, fourth-order Runge-Kutta method Runge-Kutta method requires the evaluation of requires the evaluation of the function four times. The the function four times. The discussion on optimal discussion on optimal order R-K method is very order R-K method is very interesting, but will be interesting, but will be discussed some other time.discussed some other time.

Page 46: Lecture 37

Lecture 37Lecture 37

NumericalAnalysis

NumericalAnalysis