18
1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form • Example: Numerical methods for ordinary differential equations calculate solution on the points, where h is the steps size 0 ) 0 ( ), , ( ) ( ' y y t y f t y 0 ) 0 ( , 1 ) ( ' 1 ) 0 ( , 5 3 ) ( ' y ty t y y y t y h t t n n 1

1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

Embed Size (px)

Citation preview

Page 1: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

1

Numerical Solution of Ordinary Differential

Equation• A first order initial value problem of ODE may be written

in the form

• Example:

• Numerical methods for ordinary differential equations calculate solution on the points, where h is the steps size

0)0(),,()(' yytyfty

0)0(,1)('

1)0(,53)('

ytyty

yyty

htt nn 1

Page 2: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

2

Numerical Methods for ODE

• Euler Methods– Forward Euler Methods– Backward Euler Method– Modified Euler Method

• Runge-Kutta Methods– Second Order– Third Order– Fourth Order

Page 3: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

3

Forward Euler Method

• Consider the forward difference approximation for first derivative

• Rewriting the above equation we have

• So, is recursively calculated as

nnnn

n tthh

yyy

1

1 ,'

),(','1 nnnnnn tyfyhyyy

ny

),(

),(

),('

111

1112

000001

nnnn tyfhyy

tyfhyy

tyfhyhyyy

Page 4: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

4

Example:Example: solve

Solution:Solution:

etc

25.0,10,1)0(,1' 0 htyytyy

1.251)1*0.25(01

)1(

',25.0for

000

0011

ythy

hyyyt

1.57811)1.25*0.25(0.251.25

)1(

' ,5.0for

111

1122

ythy

hyyyt

1)0(,0for 00 yyt

Page 5: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

5

Graph the solution

Page 6: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

6

Backward Euler Method

• Consider the backward difference approximation for first derivative

• Rewriting the above equation we have

• So, is recursively calculated as

11 ,'

nnnn

n tthh

yyy

),(','1 nnnnnn tyfyhyyy

ny

),(

),(

),('

1

2212

110101

nnnn tyfhyy

tyfhyy

tyfhyhyyy

Page 7: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

7

Example:Example: solve

Solution:Solution:Solving the problem using backward Euler method for

yields

So, we have

25.0,10,1)0(,1' 0 htyytyy

n

nn

nnnn

nnnnnn

ht

hyy

hyyhty

ythyhyyy

1

)1('

1

1

11

ny

333.125.0*25.01

25.01

1,25.0for

1

011

ht

hyyt

Page 8: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

8

8091.15.0*25.01

25.0333.1

1,5.0for

2

122

ht

hyyt

5343.275.0*25.01

25.08091.1

1,75.0for

3

233

ht

hyyt

7142.31*25.01

25.05343.2

1,1for

4

344

ht

hyyt

Page 9: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

9

Graph the solution

Page 10: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

10

Modified Euler Method

• Modified Euler method is derived by applying the trapezoidal rule to integrating ; So, we have

• If f is linear in y, we can solved for similar as backward euler method

• If f is nonlinear in y, we necessary to used the method for solving nonlinear equations i.e. successive substitution method (fixed point)

),(' tyfyn

),('),(2

''11 nnnnnnn tyfyyy

hyy

1ny

Page 11: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

11

Example:Example: solve

Solution:Solution:f is linear in y. So, solving the problem using modified Euler

method for yields

25.0,10,1)0(,1' 0 htyytyy

hyth

th

y

hth

yth

y

ytyth

y

yyh

yy

n

n

n

n

nnnn

nnnnn

nnnn

1

1

11

111

11

)2

1(

)2

1(

)2

1()2

1(

)11(2

)''(2

ny

Page 12: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

12

Graph the solution

Page 13: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

13

Second Order Runge-Kutta Method

• The second order Runge-Kutta (RK-2) method is derived

by applying the trapezoidal rule to integrating over the interval . So, we have

We estimate by the forward euler method.

),(' tyfy

],[ 1nn tt

),(),(2

),(

11

1

1

nnnnn

t

t

nn

tyftyfh

y

dttyfyyn

n

1ny

Page 14: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

14

So, we have

Or in a more standard form as

)),,((),(2 11 nnnnnnnn ttyhfyftyfh

yy

),(

),(where2

1

112

1

211

nn

nn

nn

tkyhfk

tyhfk

kkyy

Page 15: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

15

Third Order Runge-Kutta Method

• The third order Runge-Kutta (RK-3) method is derived by

applying the Simpson’s 1/3 rule to integrating over the interval . So, we have

We estimate by the forward euler method.

),(' tyfy

],[ 1nn tt

),(),(4),(6

),(

11

1

21

21

1

nnnnnnn

t

t

nn

tyftyftyfh

y

dttyfyyn

n

21ny

Page 16: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

16

The estimate may be obtained by forward difference method, central difference method for h/2, or linear combination both forward and central difference method. One of RK-3 scheme is written as

),2(

)2

,(

),(where

46

1

1213

121

2

1

3211

nn

nn

nn

nn

tkkyhfk

htkyhfk

tyhfk

kkkyy

1ny

Page 17: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

17

Fourth Order Runge-Kutta Method

• The fourth order Runge-Kutta (RK-4) method is derived by applying the Simpson’s 1/3 or Simpson’s 3/8 rule to

integrating over the interval . The formula of RK-4 based on the Simpson’s 1/3 is written as

),(' tyfy ],[ 1nn tt

),(

)2,(

)2,(

),(where

226

1

34

221

3

121

2

1

43211

htkyhfk

htkyhfk

htkyhfk

tyhfk

kkkkyy

nn

nn

nn

nn

nn

Page 18: 1 Numerical Solution of Ordinary Differential Equation A first order initial value problem of ODE may be written in the form Example: Numerical methods

18

• The fourth order Runge-Kutta (RK-4) method is derived based on Simpson’s 3/8 rule is written as

),33(

)32,(

)3,(

),(where

338

1

3214

231

131

3

131

2

1

43211

htkkkyhfk

htkkyhfk

htkyhfk

tyhfk

kkkkyy

nn

nn

nn

nn

nn