+ All Categories
Home > Documents > SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

Date post: 05-Feb-2016
Category:
Upload: jael
View: 78 times
Download: 2 times
Share this document with a friend
Description:
SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36. KFUPM (Term 101) Section 04 Read 25.1-25.4, 26-2, 27-1. Outline of Topic 8. Lesson 1:Introduction to ODEs Lesson 2:Taylor series methods Lesson 3:Midpoint and Heun’s method - PowerPoint PPT Presentation
36
CISE301_Topic8L4&5 1 Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36 KFUPM (Term 101) Section 04 Read 25.1-25.4, 26-2, 27-1
Transcript
Page 1: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 1

SE301: Numerical Methods

Topic 8 Ordinary Differential

Equations (ODEs)Lecture 28-36

KFUPM(Term 101)Section 04

Read 25.1-25.4, 26-2, 27-1

Page 2: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 2

Outline of Topic 8 Lesson 1: Introduction to ODEs Lesson 2: Taylor series methods Lesson 3: Midpoint and Heun’s method Lessons 4-5: Runge-Kutta methods Lesson 6: Solving systems of ODEs Lesson 7: Multiple step Methods Lesson 8-9: Boundary value Problems

Page 3: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 3

Lecture 31Lesson 4: Runge-Kutta

Methods

Page 4: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 4

Learning Objectives of Lesson 4 To understand the motivation for using

Runge Kutta method and the basic idea used in deriving them.

To Familiarize with Taylor series for functions of two variables.

Use Runge Kutta of order 2 to solve ODEs.

Page 5: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 5

Motivation We seek accurate methods to solve ODEs

that do not require calculating high order derivatives.

The approach is to use a formula involving unknown coefficients then determine these coefficients to match as many terms of the Taylor series expansion.

Page 6: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 6

Second Order Runge-Kutta Method

possible. as accurate as is that such

,,,

:Problem

) ,(

),(

1

21

22111

12

1

i

ii

ii

ii

y

wwFind

KwKwyy

KyhxfhK

yxfhK

Page 7: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 7

Taylor Series in Two Variables

The Taylor Series discussed in Chapter 4 is extended to the 2-independent

variable case.This is used to prove RK formula.

Page 8: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 8

Taylor Series in One Taylor Series in One VariableVariable

hxandxbetweenisxwhere

xfn

hxf

i

hhxf

f(x)n

nn

i

n

i

i

)(

)!1()(

! )(

of expansion SeriesTaylor order The

)1(1

)(

0

th

Approximation Error

Page 9: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 9

Derivation of 2nd OrderRunge-Kutta Methods – 1 of 5

)(),('2

),(

:as writtenis which

)(2

),( :ODE solve toUsed

ExpansionSeriesTaylor Order Second

32

1

32

22

1

hOyxfh

yxfhyy

hOdx

ydh

dx

dyhyy

yxfdx

dy

iiiiii

ii

Page 10: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

Derivation of 2nd OrderRunge-Kutta Methods – 2 of 5

CISE301_Topic8L4&5 10

)(2

),(),(

:

),(),(),(

),('

ationdifferenti rule-chainby obtained is ),(' where

32

1 hOh

yxfy

f

x

fhyxfyy

ngSubstituti

yxfy

f

x

f

dx

dy

y

yxf

x

yxfyxf

yxf

iiiiii

Page 11: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 11

Taylor Series in Two Taylor Series in Two VariablesVariables

),( and ),( between joining line theon is),(

),()!1(

1 ),(

!

1

...

2!2

1

),(),(

1

0

2

2

22

2

22

kyhxyxyx

errorionapproximat

yxfy

kx

hn

yxfy

kx

hi

yx

fhk

y

fk

x

fh

y

fk

x

fhyxfkyhxf

nn

i

i

Page 12: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 12

Derivation of 2nd OrderRunge-Kutta Methods – 3 of 5

) ,(),(

:ngSubstituti

) ,(

),(

thatsuch ,,,:Problem

1211

22111

12

1

21

Kyhxfhwyxfhwyy

KwKwyy

KyhxfhK

yxfhK

wwFind

iiiiii

ii

ii

ii

Page 13: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

Derivation of 2nd OrderRunge-Kutta Methods – 4 of 5

CISE301_Topic8L4&5 13

...),( ),( )(

... ),( )(

...),( ),(

:

...),() ,(

22

22211

12211

1211

11

iiiiii

iiii

iiiiii

iiii

yxfy

fhw

x

fhwyxfhwwyy

y

fK

x

fhhwyxfhwwyy

y

fK

x

fhyxfhwyxfhwyy

ngSubstituti

y

fK

x

fhyxfKyhxf

Page 14: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

Derivation of 2nd OrderRunge-Kutta Methods – 5 of 5

CISE301_Topic8L4&5 142

1 ,1 :solution possible One

solutions infinite unknowns 4 withequations 32

1 and ,

2

1 , 1

:equations threefollowing theobtain we terms,Matching

)(2

),(),(

...),( ),( )(

:for expansions twoderived We

21

2221

32

1

22

22211

1

ww

wwww

hOh

yxfy

f

x

fhyxfyy

yxfy

fhw

x

fhwyxfhwwyy

y

iiiiii

iiiiii

i

Page 15: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

2nd Order Runge-Kutta Methods

CISE301_Topic8L4&5 15

2

1 and ,

2

1 ,1

: thatsuch ,,, Choose

) ,(

),(

2221

21

22111

12

1

wwww

ww

KwKwyy

KyhxfhK

yxfhK

ii

ii

ii

Page 16: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 16

Alternative Form

22111

12

1

) , (

),(

FormeAlternativ

kwkwhyy

khyhxfk

yxfk

ii

ii

ii

22111

12

1

) , (

),(

KuttaeOrder Rung Second

KwKwyy

KyhxfhK

yxfhK

ii

ii

ii

Page 17: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 17

Choosing , , w1 and w2

Corrector Singlea with' is This

),(),(22

1

),(

),(

:becomes methodKutta -eOrder Rung Second2

1 ,1 then,1 choosing example,For

011211

12

1

21

s Method Heun

yxfyxfh

yKKyy

KyhxfhK

yxfhK

ww

iiiiiii

ii

ii

Page 18: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 18

Choosing , , w1 and w2

Method Midpoint theis This

)2

,2

(

)2

,2

(

),(

:becomes methodKutta -eOrder Rung Second

1 ,0 ,2

1 then

2

1 Choosing

121

12

1

21

Ky

hxfhyKyy

Ky

hxfhK

yxfhK

ww

iiiii

ii

ii

Page 19: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 19

2nd Order Runge-Kutta MethodsAlternative Formulas

211

1i2

1

2

1

2

11

) ,(

),(

)0(select mulas Kutta ForeOrder Rung Second

KKyy

KyhxfhK

yxfhK

ii

i

ii

2

11 ,

2

1, :number nonzeroany Pick

1 ,2

1,

2

1

12

2122

ww

wwww

Page 20: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 20

Second order Runge-Kutta Method Example

8269.32/)1662.018.0(4

2/)1()01.01(

1662.0))01.()18.0(1(01.0

),(

18.0)1(01.0)4 ,1(

:1STEP

1 ,01.0 ,4)1(,1)(

RK2using (1.02) find tosystem following theSolve

21

30

20

1002

30

20001

32

KKxx

tx

KxhtfhK

txxtfhK

hxtxtx

x

Page 21: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 21

Second order Runge-Kutta Method Example

6662.3)1546.01668.0(2

18269.3

2

1)01.1()01.001.1(

1546.0))01.()1668.0(1(01.0

),(

1668.0)1(01.0)8269.3,01.1(

2 STEP

21

31

21

1112

31

21111

KKxx

tx

KxhtfhK

txxtfhK

Page 22: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 22

1 RK2,Using

[1,2]for t Solution

,4)1(,)(1)( 32

xttxtx

Page 23: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 23

Lecture 32Lesson 5: Applications of Runge-Kutta Methods to Solve First Order ODEs

Using Runge-Kutta methods of differentorders to solve first order ODEs

Page 24: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 24

2nd Order Runge-Kutta

RK2

)( iserror global and )( iserror Local

2

) ,(

),(

corrector singlea withmethod s Heun' toEquivalent

RK2as Know 1, of valueTypical

23

211

12

1

hOhO

kkh

yy

hkyhxfk

yxfk

ii

ii

ii

Page 25: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 25

Higher-Order Runge-Kutta

Higher order Runge-Kutta methods are available.

Derived similar to second-order Runge-Kutta.

Higher order methods are more accurate butrequire more calculations.

Page 26: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 26

3rd Order Runge-Kutta

RK3

)( iserror Global and )( iserror Local

46

)2 ,(

)2

1 ,

2(

),(

RK3asKnow

34

3211

213

12

1

hOhO

kkkh

yy

hkhkyhxfk

hkyh

xfk

yxfk

ii

ii

ii

ii

Page 27: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 27

4th Order Runge-Kutta

RK4

)( iserror global and )( iserror Local

226

) ,(

)2

1 ,

2(

)2

1 ,

2(

),(

45

43211

3i4

2i3

12

1

hOhO

kkkkh

yy

hkyhxfk

hkyh

xfk

hkyh

xfk

yxfk

ii

i

i

ii

ii

Page 28: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 28

Higher-Order Runge-Kutta

654311

543216

415

324

213

12

1

7321232790

)7

8

7

12

7

12

7

2

7

3 ,(

)16

9

16

3 ,

4

3(

)2

1 ,

2

1(

)8

1

8

1 ,

4

1(

)4

1 ,

4

1(

),(

kkkkkh

yy

hkhkhkhkhkyhxfk

hkhkyhxfk

hkhkyhxfk

hkhkyhxfk

hkyhxfk

yxfk

ii

ii

ii

ii

ii

ii

ii

Page 29: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 29

Example4th-Order Runge-Kutta Method

)4.0()2.0(4

2.0

5.0)0(

1 2

yandycomputetoRKUse

h

y

xydx

dy

RK4

Page 30: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 30

Example: RK4

)4.0(),2.0(4

5.0)0(,1

:Problem

2

yyfindtoRKUse

yxydx

dy

Page 31: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 31

4th Order Runge-Kutta

RK4

)( iserror global and )( iserror Local

226

) ,(

)2

1 ,

2(

)2

1 ,

2(

),(

45

43211

3i4

2i3

12

1

hOhO

kkkkh

yy

hkyhxfk

hkyh

xfk

hkyh

xfk

yxfk

ii

i

i

ii

ii

Page 32: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 32

Example: RK4

5.0,0

1),(

0.2

00

2

yx

xyyxf

h

8293.0226

7908.12.016545.01),(

654.11.0164.01)2

1,

2

1(

64.11.015.01)2

1,

2

1(

5.1)1( ),(

432101

2003004

2002003

2001002

200001

kkkkh

yy

xyhkyhxfk

xyhkyhxfk

xyhkyhxfk

xyyxfk

)4.0(),2.0(4

5.0)0(,1

:Problem

2

yyfindtoRKUse

yxydx

dy

See RK4 Formula

Page 33: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 33

Example: RK4

8293.0,2.0

1),(

0.2

11

2

yx

xyyxf

h

2141.1226

2.0

0555.2),(

9311.1)2

1,

2

1(

9182.1)2

1,

2

1(

1.7893 ),(

432112

3114

2113

1112

111

kkkkyy

hkyhxfk

hkyhxfk

hkyhxfk

yxfk

)4.0(),2.0(4

5.0)0(,1

:Problem

2

yyfindtoRKUse

yxydx

dy

Page 34: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 34

Example: RK4

)4.0(),2.0(4

5.0)0(,1

:Problem

2

yyfindtoRKUse

yxydx

dy

xi yi

0.0 0.5

0.2 0.8293

0.4 1.2141

Summary of the solution

Page 35: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 35

Summary Runge Kutta methods generate an

accurate solution without the need to calculate high order derivatives.

Second order RK have local truncation error of order O(h3) and global truncation error of order O(h2).

Higher order RK have better local and global truncation errors.

N function evaluations are needed in the Nth order RK method.

Page 36: SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36

CISE301_Topic8L4&5 36

Remaining Lessons in Topic 8Lesson 6:Solving Systems of high order ODE

Lesson 7:Multi-step methods

Lessons 8-9:Methods to solve Boundary Value Problems


Recommended