lecture 9 - thammasat universitypongsak.ee.engr.tu.ac.th/le230/ode.pdfhigher order taylor series...

88
1 Lecture 9 Ordinary Differential Equations Part I ODEs Taylor series methods and Euler method Midpoint and Heun’s method Runge-Kutta methods

Upload: others

Post on 22-Apr-2020

5 views

Category:

Documents


1 download

TRANSCRIPT

1

Lecture 9Ordinary Differential Equations

Part I

�ODEs

�Taylor series methods and Euler method

�Midpoint and Heun’s method

�Runge-Kutta methods

2

Partial Derivatives

u is a function of

more than one independent variable

Ordinary Derivatives

v is a function of one

independent variable

Derivatives

Derivatives

dt

dv

y

u

∂∂

3

Partial Differential Equations

involve one or more partial derivatives of unknown functions

Ordinary Differential Equations

involve one or more

Ordinary derivatives of

unknown functions

Differential EquationsDifferentialEquations

162

2

=+ tvdt

vd0

2

2

2

2

=∂∂

−∂∂

x

u

y

u

4

Ordinary Differential Equations

)cos()(2)(

5)(

)()(

:

2

2

ttxdt

tdx

dt

txd

etvdt

tdv

Examples

t

=+−

=−

Ordinary Differential Equations (ODEs) involve one or

more ordinary derivatives of unknown functions with

respect to one independent variable

x(t): unknown function

t: independent variable

5

Example of ODE:

Model of Falling Parachutist

The velocity of a falling parachutist is given by:

velocityv

tcoefficiendragc

massM

vM

c

td

vd

:

:

:

8.9 −=

vM

c

dt

dv−= 8.9

6

Definitions

Ordinary differential equation

(Dependent variable) unknown function to be determined

(independent variable) the variable with respect to which other variables are differentiated

7

Order of a Differential Equation

1)(2)()(

)cos()(2)(

5)(

)()(

:

4

3

2

2

2

2

=+−

=+−

=−

txdt

tdx

dt

txd

ttxdt

tdx

dt

txd

etxdt

tdx

Examples

t

The order of an ordinary differential equation is the order

of the highest order derivative.

Second order ODE

First order ODE

Second order ODE

8

A solution to a differential equation is a function that

satisfies the equation.

Solution of a Differential Equation

0)()(

:

=+ txdt

tdx

Example

0)()(

)(

:Proof

)(

=+−=+

−=

=

−−

tt

t

t

eetxdt

tdx

edt

tdx

etxSolution

9

Linear ODE

1)()()(

)cos()(2)(

5)(

)()(

:

3

2

2

2

2

2

=+−

=+−

=−

txdt

tdx

dt

txd

ttxtdt

tdx

dt

txd

etxdt

tdx

Examples

t

An ODE is linear if

The unknown function and its derivatives appear to power one

No product of the unknown function and/or its derivatives

Linear ODE

Linear ODE

Non-linear ODE

10

Nonlinear ODE

1)()()(

2)()(

5)(

1))(cos()(

:ODEnonlinear of Examples

2

2

2

2

=+−

=−

=−

txdt

tdx

dt

txd

txdt

tdx

dt

txd

txdt

tdx

An ODE is linear if

The unknown function and its derivatives appear to power one

No product of the unknown function and/or its derivatives

11

Solutions of Ordinary Differential

Equations

0)(4)(

ODE thetosolution a is

)2cos()(

2

2

=+

=

txdt

txd

ttx

Is it unique?

solutions. are constant) real a is (where

)2cos()( form theof functions All

c

cttx +=

12

Uniqueness of a Solution

bx

ax

txdt

txd

=

=

=+

)0(

)0(

0)(4)(

2

2

&

In order to uniquely specify a solution to an nth

order differential equation we need n conditions.

Second order ODE

Two conditions are needed to uniquely specify the solution

13

Auxiliary Conditions

Boundary Conditions

� The conditions are not at one point of the independent variable

Initial Conditions

� All conditions are at one point of the independent variable

Auxiliary Conditions

14

Boundary-Value and

Initial value Problems

Boundary-Value Problems

� The auxiliary conditions are not at one point of the independent variable

� More difficult to solve than initial value problems

5.1)2(,1)0(

2 2

==

=++ −

xx

exxxt

&&&

Initial-Value Problems

� The auxiliary conditions are at one point of the

independent variable

5.2)0(,1)0(

2 2

==

=++ −

xx

exxxt

&

&&&

same different

15

Analytic and Numerical Solutions

� Analytical Solutions to ODEs are available for linear ODEs and special classes of nonlinear differential equations.

� Numerical methods are used to obtain a graph or a table of the unknown function.

� Most of the Numerical methods used to solve ODEs are based directly (or indirectly) on the truncated Taylor series expansion.

16

Classification of the Methods

Numerical Methods

for Solving ODE

Multiple-Step Methods

Estimates of the solution at a particular step are based on information on more than one step

Single-Step Methods

Estimates of the solution at a particular step are entirely based on information on the

previous step

17

Taylor Series MethodThe problem to be solved is a first order ODE:

00 )(),,()(

yxyyxfdx

xdy==

Estimates of the solution at different base points:

are computed using the truncated Taylor series

expansions.

....),3(),2(),( 000 hxyhxyhxy +++

18

Taylor Series Expansion

0

0

0

00

0

00

,,2

22

,0

0 ,

0

!...

!2)(

!)(

Expansion SeriesTaylor Truncated

yyxx

n

nn

yyxx

yyxx

n

k yyxx

k

kk

dx

yd

n

h

dx

ydh

dx

dyhxy

dx

yd

k

hhxy

==

==

==

= ==

++++≈

≈+ ∑

The nth order Taylor series method uses the nth order Truncated Taylor series expansion.

19

Euler Method

� First order Taylor series method is known as Euler Method.

� Only the constant term and linear term are used in the Euler method.

� The error due to the use of the truncated Taylor series is of order O(h2).

20

First Order Taylor Series Method(Euler Method)

),(

),(

),(,

:

)()()(

1

,

0

2

,00

0

0

iiii

ii

yyxx

nnn

yyxx

yxfhyy

MethodEuler

yxfdx

dy

xyynhxx

Notation

hOdx

dyhxyhxy

i

i

+=

=

=+=

++=+

+

==

==

21

Euler Method

,...2,1),(

)(

:MethodEuler

,...2,1)(:Determine

)( :condition initial with the

),()(:ODEorder first Given the

:Problem

1

00

0

00

=+=

=

=+=

=

=

+ iforyxfhyy

xyy

iforihxyy

xyy

yxfxy

iiii

i

&

22

Interpretation of Euler Method

x0 x1 x2 x

y0

y1

y2

23

Interpretation of Euler Method

hx0 x1 x2 x

y0

y1=y0+hf(x0,y0)

Slope=f(x0,y0)

hf(x0,y0)

y1

24

Interpretation of Euler Method

hx0 x1 x2 x

y0

y1=y0+hf(x0,y0)

Slope=f(x0,y0)

hf(x0,y0)

y1

h

y2=y1+hf(x1,y1)Slope=f(x1,y1)

y2

hf(x1,y1)

25

Example 1Use Euler method to solve the ODE:

to determine y(1.01), y(1.02) and y(1.03).

4)1(,1 2 −=+= yxdx

dy

26

Example 1

01.0,4,1,1),( 00

2 =−==+= hyxxyxf

( )( )( )( ) 9394.302.1101.09598.3),(:3

9598.301.1101.098.3),(:2

98.3))1(1(01.04),(:1

),(

MethodEuler

2

2223

2

1112

2

0001

1

−=++−=+=

−=++−=+=

−=++−=+=

+=+

yxfhyyStep

yxfhyyStep

yxfhyyStep

yxfhyy iiii

27

Example 1

Summary of the result:

01.0,4,1,1),( 00

2 =−==+= hyxxyxf

i xi yi

0 1.00 -4.00

1 1.01 -3.98

2 1.02 -3.9595

3 1.03 -3.9394

28

Example 1

Comparison with true value:

01.0,4,1,1),( 00

2 =−==+= hyxxyxf

i xi yi True value of yi

0 1.00 -4.00 -4.00

1 1.01 -3.98 -3.97990

2 1.02 -3.9595 -3.95959

3 1.03 -3.9394 -3.93909

29

Example 1

01.0,4,1,1),( 00

2 =−==+= hyxxyxf

A graph of the solution of the ODE for 1<x<2

30

Types of Errors

� Local truncation error:

Error due to the use of truncated Taylor series to compute x(t+h) in one step.

� Global Truncation error:

Accumulated truncation over many steps.

� Round off error:

Error due to finite number of bits used in representation of numbers. This error could be accumulated and magnified in succeeding steps.

31

Second Order Taylor Series Methods

ly.analytical derived be toneeds

)(!2

method SeriesTaylor order Second

)(),,()(

2

2

3

2

22

1

00

dx

yd

hOdx

ydh

dx

dyhyy

yxyxyfdx

xdyGiven

ii +++=

==

+

32

Third Order Taylor Series Methods

ly.analytical derived be toneed and

)(!3!2

method SeriesTaylor order Third

)(),,()(

3

3

2

2

4

3

33

2

22

1

00

dx

yd

dx

yd

hOdx

ydh

dx

ydh

dx

dyhyy

yxyxyfdx

xdyGiven

ii ++++=

==

+

33

High Order Taylor Series Methods

ly.analytical derived be toneed ,.....,,

)(!

....!2

method SeriesTaylor order n

)(),,()(

3

3

2

2

1

2

22

1

th

00

n

n

n

n

nn

ii

dx

yd

dx

yd

dx

yd

hOdx

yd

n

h

dx

ydh

dx

dyhyy

yxyxyfdx

xdyGiven

++ +++++=

==

34

Higher Order Taylor Series Methods

� High order Taylor series methods are more accurate than Euler method.

� But, the 2nd, 3rd, and higher order derivatives need to be derived analyticallywhich may not be easy.

35

Example 2Second order Taylor Series Method

?)(

:isWhat

01.0,1)0(,12

:solve to method SeriesTaylor order Second Use

2

2

2

dt

txd

husextxdt

dx===++

36

Example 2

))21(41(2

)21(

1)21(4140)(

21

01.0,1)0(,12

:solve to method SeriesTaylor order Second Use

22

2

1

2

2

2

2

2

iiiiiii txxh

txhxx

txxdt

dxx

dt

txd

txdt

dx

husextxdt

dx

−−−−+−−+=

−−−−=−−=

−−=

===++

+

37

Example 2

))21(41(2

)21(

01.0,1,0,21),(

22

2

1

00

2

iiiiiii txxh

txhxx

hxttxxtf

−−−−+−−+=

===−−=

+

( )

( )

9716.0

:3

9807.0))01.0)9901.0(21)(9901.0(41(2

01.0)01.0)9901.0(21(01.09901.0

:2

9901.0))021)(1(41(2

01.0)0)1(21(01.01

:1

3

2

2

2

2

2

2

1

=

=−−−−+−−+=

=−−−−+−−+=

x

Step

x

Step

x

Step

38

Example 2

Summary of the results:

01.0,1,0,21),( 00

2 ===−−= hxttxxtf

i ti xi

0 0.00 1

1 0.01 0.9901

2 0.02 0.9807

3 0.03 0.9716

39

Programming Euler MethodWrite a MATLAB program to implement Euler method to solve:

100,...,2,1,01.0

1)0(.21 2

==

=−−=

iitfor

vtvdt

dv

i

40

Programming Euler Methodf=inline('1-2*v^2-t','t','v')

h=0.01

t=0

v=1

T(1)=t;

V(1)=v;

for k=1:100

v=v+h*f(t,v)

t=t+h;

T(k+1)=t;

V(k+1)=v;

end

41

Programming Euler Methodf=inline('1-2*v^2-t','t','v')

h=0.01

t=0

v=1

T(1)=t;

V(1)=v;

for k=1:100

v=v+h*f(t,v)

t=t+h;

T(k+1)=t;

V(k+1)=v;

end

Definition of the ODE

Initial condition

Main loop

Euler method

Storing information

42

Programming Euler MethodPlot of the

solution

plot(T,V)

43

Euler Method

) Error Truncation Global

) Error Truncation Local

,...2,1

),()(

)(),()(

MethodEuler Problem

2

100

00

O(h

O(h

ifor

yxfhyyyxy

xyyyxfxy

iiii

=

+==

==

+

&

44

� The methods proposed in this lesson have the general form:

� For the case of Euler:

� Different forms of will be used for the Midpoint and Heun’s Methods.

Midpoint Method Introduction

φhyy ii +=+1

),( ii yxf=φ

00 )(),,()(

:ODEorder first a is solved be toProblem

yxyyxfxy ==&

φ

45

Midpoint Method

) Error Truncation Global

) Error Truncation Local

),(

),(2

)(

)(),()(

MethodMidpoint Problem

2

3

2

1

2

11

2

100

00

O(h

O(h

yxfhyy

yxfh

yyyxy

xyyyxfxy

iiii

iiii

+++

+

+=

+==

==&

46

Motivation

� The midpoint can be summarized as:

� Euler method is used to estimate the solution at the midpoint.

� The value of the rate function f(x,y) at the mid point is calculated.

� This value is used to estimate yi+1.

� Local Truncation error of order O(h3).

� Comparable to Second order Taylor series method.

47

Midpoint Method

1

2

10 ++

ii

xxx

),( ii yx

),(,),(2

2

1

2

11

2

1++

++

+=+=ii

iiiiii

yxfhyyyxfh

yy

48

Midpoint Method

1

2

10 ++

ii

xxx

),( ii yxfslope =

),( ii yx

),(,),(2

2

1

2

11

2

1++

++

+=+=ii

iiiiii

yxfhyyyxfh

yy

49

Midpoint Method

1

2

10 ++

ii

xxx

),( ii yxfslope =

),( ii yx

),(,),(2

2

1

2

11

2

1++

++

+=+=ii

iiiiii

yxfhyyyxfh

yy

),(2

1

2

1++ ii

yx

50

Midpoint Method

1

2

10 ++

ii

xxx

),(2

1

2

1++

=ii

yxfslope

),( ii yx

),(,),(2

2

1

2

11

2

1++

++

+=+=ii

iiiiii

yxfhyyyxfh

yy

),(2

1

2

1++ ii

yx

51

Midpoint Method

1

2

10 ++

ii

xxx

),(2

1

2

1++

=ii

yxfslope

),( ii yx

),(,),(2

2

1

2

11

2

1++

++

+=+=ii

iiiiii

yxfhyyyxfh

yy

),(2

1

2

1++ ii

yx

52

Example 1

y(0.2) and y(0.1) Determine .1.0 Use

1)0(

1)(

ODE thesolve toMethodMidpoint theUse

2

=

=

++=

h

y

yxxy&

53

Example 1

4446.1)3438.2(1.02103.1),(

3213.1)2103.101.01(05.2103.1),(2

:2Step

2103.1)1.10025.01(1.01),(

1.1)101(05.01),(2

:1Step

1.0,1)0(,1),( :Problem

2

11

2

11

12

111

2

11

2

10

2

10

01

000

2

10

02

=+=+=

=+++=+=

=+++=+=

=+++=+=

===++=

++

+

++

+

yxfhyy

yxfh

yy

yxfhyy

yxfh

yy

hyyyxyxf

54

Heun’s Predictor Corrector Method

( )

) ErrorTruncation Global

) ErrorTruncation Local

),(),(2

:Corrector

),(:Predictor)(

)(),()(

Method'HProblem

2

3

011

11

0100

00

O(h

O(h

yxfyxfh

yy

yxfhyyyxy

xyyyxfxy

seun

iiiiii

iiii

+++

+

++=

+==

==&

55

Heun’s Predictor Corrector

(Prediction)

1+ii xx

),( ii yx

),(Prediction 01 iiii yxfhyy +=+

),( 0

11 ++ ii yx

56

Heun’s Predictor Corrector

(Prediction)

1+ii xx

),( ii yx

),(Prediction 0

1 iiii yxfhyy +=+

),( 0

11 ++ ii yx),( 0

11 ++= ii yxfslope

57

Heun’s Predictor Corrector

(Correction)

1+ii xx

),( ii yx

),( 0

11 ++ ii yx2

),(),( 0

11 +++= iiii yxfyxf

slope

),( 1

11 ++ ii yx

( )),(),(2

0

11

1

1 +++ ++= iiiiii yxfyxfh

yy

58

Example 2

y(0.2) and y(0.1) Determine

only correction One .1.0 Use

1)0(

1)(

ODE thesolve toMethod sHeun' theUse

2

=

=

++=

h

y

yxxy&

59

Example 2

( )

( ) 4452.1),(),(2

:Corrector

4326.1),(:Predictor

:2Step

2105.1),(),(2

:Corrector

2.1)2(1.01),(:Predictor

:1Step

1.0,1)(,1),( :Problem

0

22111

1

2

111

0

2

0

11000

1

1

000

0

1

00

2

=++=

=+=

=++=

=+=+=

===++=

yxfyxfh

yy

yxfhyy

yxfyxfh

yy

yxfhyy

hxyyxyyxf

60

Summary of Midpoint & Heun’s

� Euler, Midpoint and Heun’s methods are similar in the following sense:

� Different methods use different estimates of the slope.

� Both Midpoint and Heun’s methods are comparable in accuracy to the second order Taylor series method.

slopehyy ii ×+=+1

61

Comparison

( )

),(

)()(),(2

Midpoint

),(),(2

:Corrector

)()(),(:Predictor

Method sHeun'

)()(),( MethodEuler

2

1

2

11

23

2

1

11

1

1

230

1

2

1

+++

+

++++

+

+

+=

+=

++=

+=

+=

iiii

iiii

k

iiiii

k

i

iiii

iiii

yxfhyy

hOhOyxfh

yy

yxfyxfh

yy

hOhOyxfhyy

hOhOyxfhyy

Method Local truncation error

Global truncation error

62

Runge-Kutta Method : 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.

63

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

βα

βα

64

Taylor Series in One Variable

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

65

Derivation of 2nd Order

Runge-Kutta Methods – 1 of 5

)(),('2

),(

:as writtenis which

)(2

),( :ODE solve toUsed

ExpansionSeriesTaylor Order Second

32

1

3

2

22

1

hOyxfh

yxfhyy

hOdx

ydh

dx

dyhyy

yxfdx

dy

iiiiii

ii

+++=

+++=

=

+

+

Derivation of 2nd Order

Runge-Kutta Methods – 2 of 5

66

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

∂∂

+∂∂

++=

∂∂

+∂∂

=∂

∂+

∂∂

=

+

67

Taylor Series in Two Variables

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

++

∂∂

+∂∂

++

∂∂

+∂∂

=

+

∂∂∂

+∂

∂+

+

∂∂

+∂∂

+=++

+

=

68

Derivation of 2nd Order

Runge-Kutta Methods – 3 of 5

) ,(),(

:ngSubstituti

) ,(

),(

thatsuch ,,,:Problem

1211

22111

12

1

21

Kyhxfhwyxfhwyy

KwKwyy

KyhxfhK

yxfhK

wwFind

iiiiii

ii

ii

ii

βα

βα

βα

++++=

++=

++=

=

+

+

Derivation of 2nd Order

Runge-Kutta Methods – 4 of 5

69

...),( ),( )(

... ),( )(

...),( ),(

:

...),() ,(

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

βα

βα

βα

βαβα

Derivation of 2nd Order

Runge-Kutta Methods – 5 of 5

70

2

1 ,1 :solution possible One

solutions infinite unknowns 4 withequations 3

2

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

βα

βα

βα

2nd Order Runge-Kutta Methods

71

2

1 and ,

2

1 ,1

: thatsuch ,,, Choose

) ,(

),(

2221

21

22111

12

1

===+

++=

++=

=

+

βα

βα

βα

wwww

ww

KwKwyy

KyhxfhK

yxfhK

ii

ii

ii

72

Alternative Form

( )22111

12

1

) , (

),(

FormeAlternativ

kwkwhyy

khyhxfk

yxfk

ii

ii

ii

++=

++=

=

+

βα

22111

12

1

) , (

),(

KuttaeOrder Rung Second

KwKwyy

KyhxfhK

yxfhK

ii

ii

ii

++=

++=

=

+

βα

73

Choosing αααα, ββββ, w1 and w2

( ) ( )Corrector Singlea with' is This

),(),(22

1

),(

),(

:becomes methodKutta -eOrder Rung Second

2

1 ,1 then,1 choosing example,For

011211

12

1

21

s Method Heun

yxfyxfh

yKKyy

KyhxfhK

yxfhK

ww

iiiiiii

ii

ii

+++ ++=++=

++=

=

==== βα

74

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

+++=+=

++=

=

====

+

βα

75

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

76

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

α&

77

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

CISE301_Topic8L4&5

78

1 RK2,Using

[1,2]for t Solution

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

=

−=++=

α

xttxtx&

79

2nd Order Runge-Kutta RK2

( )

)( iserror global and )( iserror Local

2

) ,(

),(

corrector single a with method sHeun' toEquivalent

RK2 asKnown 1, of valueTypical

23

211

12

1

hOhO

kkh

yy

hkyhxfk

yxfk

ii

ii

ii

++=

++=

=

=

+

α

80

Higher-Order Runge-Kutta

Higher order Runge-Kutta methods are available.

Derivation approach similar to that of second-order Runge-Kutta.

Higher order methods are more accurate butrequire more calculations-> Higher cost.

81

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

+++=

+−+=

++=

=

+

82

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

++++=

++=

++=

++=

=

+

83

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

+++++=

+−++−+=

+++=

+−+=

+++=

++=

=

+

84

Example4th-Order Runge-Kutta Method

)4.0()2.0(4

2.0

5.0)0(

1 2

yandycomputetoRKUse

h

y

xydx

dy

=

=

++=

RK4

85

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

++++=

++=

++=

++=

=

+

86

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 FormulaStep 1

87

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=++=

Step 2

88

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

)32(5.3)( :Solution Analytic 2 ++−= xxexyx