se301: numerical methods topic 8 ordinary differential equations (odes) lecture 28-36

28
CISE301_Topic8L6 KFUPM 1 Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36 KFUPM Read 25.1-25.4, 26-2, 27-1

Upload: xander-hebert

Post on 30-Dec-2015

39 views

Category:

Documents


2 download

DESCRIPTION

SE301: Numerical Methods Topic 8 Ordinary Differential Equations (ODEs) Lecture 28-36. KFUPM 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 Lessons 4-5: Runge-Kutta methods - PowerPoint PPT Presentation

TRANSCRIPT

CISE301_Topic8L6 KFUPM 1

SE301: Numerical Methods

Topic 8 Ordinary Differential

Equations (ODEs)Lecture 28-36

KFUPM

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

CISE301_Topic8L6 KFUPM 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

CISE301_Topic8L6 KFUPM 3

Lecture 33Lesson 6: Solving Systems

of ODEs

CISE301_Topic8L6 KFUPM 4

Learning Objectives of Lesson 6

Convert a single (or a system of) high order ODE to a system of first order ODEs.

Use the methods discussed earlier in this topic to solve systems of first order ODEs.

CISE301_Topic8L6 KFUPM 5

Outlines of Lesson 6 Solution of a system of first order ODEs. Conversion of a high order ODE to a system of

first order ODEs. Conversion of a system of high order ODEs to a

system of first order ODEs. Use different methods to solve systems of first

order ODEs. Use different methods to solve high order ODEs. Use different methods to solve systems of high

order ODEs.

CISE301_Topic8L6 KFUPM 6

Solving a System of First Order ODEs Methods discussed earlier such as Euler,

Runge-Kutta,… are used to solve first order ordinary differential equations.

The same formulas will be used to solve a system of first order ODEs. In this case, the differential equation is a

vector equation and the dependent variable is a vector variable.

CISE301_Topic8L6 KFUPM 7

Euler Method for Solving a System of First Order ODEsRecall Euler method for solving a first order ODE:

)2),2(()2()3(

)),(()()2(

)),(()()(

:

)(),,()(

hahayfhhayhay

hahayfhhayhay

aayfhayhay

MethodEuler

yayxyfdx

xdyGiven a

CISE301_Topic8L6 KFUPM 8

Example - Euler MethodEuler method to solve a system of n first order ODEs.

)2),2(()2()3(

)),(()()2(

)),(()()(

:

)(

...

)(

)(

)(,

),(

...

),(

),(

),()( 2

1

2

1

hahaYFhhaYhaY

hahaYFhhaYhaY

aaYFhaYhaY

MethodEuler

ay

ay

ay

aY

xYf

xYf

xYf

xYFdx

xYdGiven

nn

CISE301_Topic8L6 KFUPM 9

Solving a System of n First Order ODEs Exactly the same

formula is used but the scalar variables and functions are replaced by vector variables and vector values functions.

Y is a vector of length n.

F(Y,x) is a vector valued function.

)2),2(()2()3(

)),(()()2(

)),(()()(

),(

),(

...

),(

),(

...

)(

1

)(

...

)(

)(

)(

2

1

2

1

2

1

hahaYFhhaYhaY

hahaYFhhaYhaY

aaYFhaYhaY

xYF

xYf

xYf

xYf

dx

yd

dx

yddx

yd

dx

xYd

vectornisY

xy

xy

xy

xY

nn

n

CISE301_Topic8L6 KFUPM 10

Example :Euler method for solving a system of first order ODEs.

39.1

78.0

)9.01(1.2.1

12.09.0

)1.0(1

)1.0(1.0

)1.0(

)1.0(

)2.0(

)2.0(

)),(()()20(

:2

2.1

9.0

)11(1.01

1.01

)0(1

)0(1.0

)0(

)0(

)1.0(

)1.0(

)0),0(()0()0(

:1

1.0

1

1

)0(

)0()0(),,(

1)(

)(

1

2

2

1

2

1

1

2

2

1

2

1

2

1

1

2

2

1

y

y

y

y

y

y

hhYFhhYhY

STEP

y

y

y

y

y

y

YFhYhY

STEP

hwithMethodEulerofstepsTwo

y

yYxYF

y

y

xy

xy

CISE301_Topic8L6 KFUPM 11

Example :RK2 method for solving a system of first order ODEs

195.1

89.0

19.0

12.0

2.0

1.0

2

1

1

1

)1.0(

)1.0(

)21(5.0)0()0(

19.0

12.0

)1.0)0((1

2.0)0(1.0)0,1)0((2

2.0

1.0

)0(1

)0(1.0)0),0((1

:1

1.0MethodKuttaRungeorder second

1

1

)0(

)0()0(),,(

1)(

)(

2

1

1

2

1

2

2

1

1

2

2

1

y

y

KKYhY

y

yhKYFhK

y

yYFhK

STEP

hwithofstepsTwo

y

yYxYF

y

y

xy

xy

CISE301_Topic8L6 KFUPM 12

Example :RK2 method for solving a system of first order ODEs

3780.1

7611.0

1771.0

1384.0

1890.0

1195.0

2

1

195.1

89.0

)2.0(

)2.0(

)21(5.0)1.0()1.0(

1771.0

1384.0

)1195.0)1.0((1

189.0)1.0(1.0)1.0,1)1.0((2

1890.0

1195.0

)1.0(1

)1.0(1.0)1.0),1.0((1

:2

1

1

)0(

)0()0(),,(

1)(

)(

2

1

1

2

1

2

2

1

1

2

2

1

y

y

KKYhY

y

yhKYFhK

y

yYFhK

STEP

y

yYxYF

y

y

xy

xy

CISE301_Topic8L6 KFUPM 13

Methods for Solving a System of First Order ODEs

We have extended Euler and RK2 methods to solve systems of first order ODEs.

Other methods used to solve first order ODE can be easily extended to solve systems of first order ODEs.

CISE301_Topic8L6 KFUPM 14

High Order ODEs How do solve a second order ODE?

How do solve high order ODEs?

163 xxx

CISE301_Topic8L6 KFUPM 15

The General Approach to Solve ODEs

4)0(;1)0(

163

xx

xxx

Convert

1

4)0(

,631 12

2

2

1

Z

zz

z

z

z

Solve

High order ODE Convert System of first order ODEs Solve

Second order ODE Two first order ODEs

CISE301_Topic8L6 KFUPM 16

Conversion Procedure High order ODE Convert System of first order ODEs Solve

1. Select the dependent variables One way is to take the original dependent

variable and its derivatives up to one degree less than the highest order derivative.

2. Write the Differential Equations in terms of the new variables. The equations come from the way the new variables are defined or from the original equation.

3. Express the equations in a matrix form.

CISE301_Topic8L6 KFUPM 17

Remarks on the Conversion Procedure

High order ODE Convert System of first order ODE Solve

1. Any nth order ODE is converted to a system of n first order ODEs.

2. There are an infinite number of ways to select the new variables. As a result, for each high order ODE there are an infinite number of set of equivalent first order systems of ODEs.

3. Use a table to make the conversion easier.

CISE301_Topic8L6 KFUPM 18

Example of Converting a High Order ODE to First Order ODEs

xz

xz

xxxxx

2

1

) variables twoneed WeODEorder (Second

variablesofset new aSelect 1.

ODEsorder first of system a to

4)0(;1)0(,163Convert

One degree less than the highest order derivative

CISE301_Topic8L6 KFUPM 19

Example of Converting a High Order ODE to First Order ODEs

1

4)0(,

631

6311

4

cond. name name

Equation Initial new old

12

2

2

1

1222

211

Zzz

z

z

z

zzzzx

zzzx

CISE301_Topic8L6 KFUPM 20

Example of Converting a High Order ODE to First Order ODEs

xz

xz

xz

xxx

xxxx

3

2

1

them)of (3 variablesofset new aSelect 1.

4)0(;1)0(,9)0(

0872

Convert

One degree less than the highest order derivative

CISE301_Topic8L6 KFUPM 21

Example of Converting a High Order ODE to First Order ODEs

9

1

4

)0(,

872

8729

1

4

cond. name name

Equation Initial new old

123

3

2

3

2

1

12333

322

211

Z

zzz

z

z

z

z

z

zzzzzx

zzzx

zzzx

CISE301_Topic8L6 KFUPM 22

Conversion Procedure for Systems of High Order ODEs

System of high order ODEs Convert System of first order ODE Solve

1. Select the dependent variables Take the original dependent variables and their

derivatives up to one degree less than the highest order derivative for each variable.

2. Write the Differential Equations in terms of the new variables. The equations come from the way the new variables are defined or from the original equation.

3. Express the equations in a matrix form.

CISE301_Topic8L6 KFUPM 23

Example of Converting a High Order ODE to First Order ODEs

yz

yz

xz

xz

xz

yyxxx

xxyy

yxxx

5

4

3

2

1

) variables2)((3 variablesofset new aSelect 1.

3)0(;1)0(;9)0(;2)0(;4)0(

22

0825

Convert

One degree less than the highest order derivative

One degree less than the highest order derivative

CISE301_Topic8L6 KFUPM 24

Example of Converting a High Order ODE to First Order ODEs

41255

544

42333

322

211

223

1

8259

2

4

cond. name name

Equation Initial new old

zzzzzy

zzzy

zzzzzx

zzzx

zzzx

CISE301_Topic8L6 KFUPM 25

Solution of a Second Order ODE

Solve the equation using Euler method. Use h=0.1

2

1)0(,

822)(

:as expressed isequation order second The

,: variablesofset new aSelect

2)0(;1)0(

282

12

2

2

1

21

Zzz

z

z

zZFZ

xzxz

xx

xxx

CISE301_Topic8L6 KFUPM 26

Solution of a Second Order ODE

2.2

58.0

)8.0(8)2.2(22

2.21.0

2.2

8.0

))1.0(()1.0()2.0(

2.2

8.0

)1(8)2(22

21.0

2

1

))0(()0()1.00(

1.0,2

1)0(,

822)(

12

2

ZhFZZ

ZhFZZ

hZzz

zZF

CISE301_Topic8L6 KFUPM 27

Summary Formulas used in solving a first order ODE

are used to solve systems of first order ODEs. Instead of scalar variables and functions, we

have vector variables and vector functions.

High order ODEs are converted to a set of first order ODEs.

CISE301_Topic8L6 KFUPM 28

Remaining Lessons in Topic 8

Solution of ODEs

Lessons 8-9:Boundary Value Problems

Lesson 7:Multi-step methods