Post on 29-Dec-2015
transcript
EE3561_Unit 8 Al-Dhaifallah1435 1
EE 3561 : Computational
MethodsUnit 8
Solution of Ordinary Differential Equations
Lesson 3: Midpoint and Heun’s Predictor corrector Methods
EE3561_Unit 8 Al-Dhaifallah1435 2
Lessons in Topic 8 Lesson 1: Introduction to ODE Lesson 2: Taylor series methods Lesson 3: Midpoint and Heun’s method Lessons 4-5: Runge-Kutta methods Lesson 6: Solving systems of ODE
EE3561_Unit 8 Al-Dhaifallah1435 3
Learning Objectives of Lesson 3 To be able to solve first order
differential equation using Midpoint Method
To be able to solve first order differential equation using Heun’s Predictor Corrector method
EE3561_Unit 8 Al-Dhaifallah1435 4
Outlines of Lesson 3Lesson 3: Midpoint and Heun’s Predictor-corrector methods
• Review Euler Method• Heun’s Method• Midpoint method
EE3561_Unit 8 Al-Dhaifallah1435 5
Euler MethodEuler Method
) Error Truncation Global
) Error Truncation Local
,...2,1
),()(
)(),()(
MethodEuler Problem
2
100
00
O(h
O(h
ifor
yxfhyyyxy
xyyyxfxy
iiii
EE3561_Unit 8 Al-Dhaifallah1435 6
We have seen Taylor series method• Euler method is simple but not accurate• Higher order Taylor series methods are accurate but require calculating higher order derivatives analytically
IntroductionIntroduction
00 )(),,()(
ODEorder first a is solved be toProblem
yxyyxfxy
hyy ii 1
EE3561_Unit 8 Al-Dhaifallah1435 7
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
IntroductionIntroduction
hyy ii 1
),( ii yxf
00 )(),,()(
ODEorder first a is solved be toProblem
yxyyxfxy
EE3561_Unit 8 Al-Dhaifallah1435 8
Midpoint MethodMidpoint Method
) ErrorTruncation Global
) ErrorTruncation Local
),(
),(2
)(
)(),()(
ethodMidpoint MProblem
2
3
2
1
2
11
2
100
00
O(h
O(h
yxfhyy
yxfh
yyyxy
xyyyxfxy
iiii
iiii
EE3561_Unit 8 Al-Dhaifallah1435 9
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
EE3561_Unit 8 Al-Dhaifallah1435 10
Midpoint MethodMidpoint Method
1
2
10
ii
xxx
),( ii yx
),(,),(2 2
1
2
11
2
1
ii
iiiiii
yxfhyyyxfh
yy
EE3561_Unit 8 Al-Dhaifallah1435 11
Midpoint MethodMidpoint Method
1
2
10
ii
xxx
),( ii yxfslope
),( ii yx
),(,),(2 2
1
2
11
2
1
ii
iiiiii
yxfhyyyxfh
yy
EE3561_Unit 8 Al-Dhaifallah1435 12
Midpoint MethodMidpoint 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 iiyx
EE3561_Unit 8 Al-Dhaifallah1435 13
Midpoint MethodMidpoint Method
1
2
10
ii
xxx
),(2
1
2
1
iiyxfslope
),( ii yx
),(,),(2 2
1
2
11
2
1
ii
iiiiii
yxfhyyyxfh
yy
),(2
1
2
1 iiyx
EE3561_Unit 8 Al-Dhaifallah1435 14
Midpoint MethodMidpoint Method
1
2
10
ii
xxx
),(2
1
2
1
iiyxfslope
),( ii yx
),(,),(2 2
1
2
11
2
1
ii
iiiiii
yxfhyyyxfh
yy
),(2
1
2
1 iiyx
EE3561_Unit 8 Al-Dhaifallah1435 15
Midpoint MethodMidpoint Method
1
2
10
ii
xxx
),(2
1
2
1
iiyxfslope
),( ii yx
),(,),(2 2
1
2
11
2
1
ii
iiiiii
yxfhyyyxfh
yy
),(2
1
2
1 iiyx
EE3561_Unit 8 Al-Dhaifallah1435 16
Example 1
y(0.2) and y(0.1) Determine .1.0 Use
1)0(
1)(
ODE thesolve toMethodMidpoint theUse2
h
y
yxxy
EE3561_Unit 8 Al-Dhaifallah1435 17
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)(,1),( :Problem
2
11
2
11
12
111
2
11
2
10
2
10
01
000
2
10
002
yxfhyy
yxfh
yy
yxfhyy
yxfh
yy
hxyyxyyxf
EE3561_Unit 8 Al-Dhaifallah1435 18
Summary 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
EE3561_Unit 8 Al-Dhaifallah1435 20
Heun’s Predictor Corrector Heun’s Predictor Corrector MethodMethod
) ErrorTruncation Global
) ErrorTruncation Local
),(),(2
:Corrector
),(:Predictor)(
)(),()(
Method'HProblem
2
3
111
1
0100
00
O(h
O(h
yxfyxfh
yy
yxfhyyyxy
xyyyxfxy
seun
kiiiii
ki
iiii
EE3561_Unit 8 Al-Dhaifallah1435 21
Heun’s Predictor Corrector(Prediction)
1ii xx
),( ii yx
),(nPreidectio 01 iiii yxfhyy
),( 011 ii yx
EE3561_Unit 8 Al-Dhaifallah1435 22
Heun’s Predictor Corrector(Prediction)
1ii xx
),( ii yx
),(nPreidectio 01 iiii yxfhyy
),( 011 ii yx
),( 011 ii yxfslope
EE3561_Unit 8 Al-Dhaifallah1435 23
Heun’s Predictor Corrector(Prediction)
1ii xx
),( ii yx
),(nPreidectio 01 iiii yxfhyy
),( 011 ii yx
2
),(),( 011
iiii yxfyxfslope
),( 111 ii yx
EE3561_Unit 8 Al-Dhaifallah1435 24
Heun’s Predictor Corrector
10 ixx
),( 11 ii yxfslope
),( ii yx
),(),(2
,),( 011
111 iiiiiiiiii yxfyxf
hyyyxfhyy
),( 011 ii yx
),( 111 ii yx
EE3561_Unit 8 Al-Dhaifallah1435 25
Heun’s Predictor Corrector
10 ixx
),( 11 ii yxfslope
),( ii yx
),(),(2
,),( 011
111 iiiiiiiiii yxfyxf
hyyyxfhyy
),( 011 ii yx
),( 111 ii yx
EE3561_Unit 8 Al-Dhaifallah1435 26
Example 2
y(0.2) and y(0.1) Determine
only correction One .1.0 Use
1)0(
1)(
ODE thesolve toMethod sHeun' theUse2
h
y
yxxy
EE3561_Unit 8 Al-Dhaifallah1435 27
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
022111
12
11102
011000
11
00001
002
yxfyxfh
yy
yxfhyy
yxfyxfh
yy
yxfhyy
hxyyxyyxf
EE3561_Unit 8 Al-Dhaifallah1435 28
Summary 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 second order Taylor series method.
slopehyy ii 1
EE3561_Unit 8 Al-Dhaifallah1435 29
Comparison
),(
)()(),(2
Midpoint
),(),(2
:Corrector
)()(),(:Predictor
Method sHeun'
)()(),( MethodEuler
2
1
2
11
23
2
1
111
1
2301
21
iiii
iiii
kiiiii
ki
iiii
iiii
yxfhyy
hOhOyxfh
yy
yxfyxfh
yy
hOhOyxfhyy
hOhOyxfhyy
Method Local truncation error
Global truncation error
EE3561_Unit 8 Al-Dhaifallah1435 30
More in this Unit Lessons 4-5: Runge-Kutta Methods Lesson 6: Systems of High order ODE Lesson 7: Multi-step methods Lessons 8-9: Boundary Value Problems
EE3561_Unit 8 Al-Dhaifallah1435 31
EE 3561 : Computational Methods
Topic 8Solution of Ordinary
Differential Equations
Lesson 4: Runge-Kutta Methods
EE3561_Unit 8 Al-Dhaifallah1435 32
Lessons in Topic 8 Lesson 1: Introduction to ODE Lesson 2: Taylor series methods Lesson 3: Midpoint and Heun’s method Lessons 4-5: Runge-Kutta methods Lesson 6: Solving systems of ODE
EE3561_Unit 8 Al-Dhaifallah1435 33
Learning Objectives of Lesson 4 To understand the motivation for using
Runge Kutta method and basic idea used in deriving them.
To Familiarize with Taylor series for functions of two variables
Use Runge Kutta of order 2 to solve ODE
EE3561_Unit 8 Al-Dhaifallah1435 34
Motivation We seek accurate methods to solve ODE
that does not require calculating high order derivatives.
The approach is to suggest a formula involving unknown coefficients then determine these coefficients to match as many terms of the Taylor series expansion
EE3561_Unit 8 Al-Dhaifallah1435 35
Runge-Kutta Method
possible. as accurate as is such that
,,,
:Problem
)()(
),(
),(
Kutta RungeOrder Second
21
2211
12
1
h)x(t
wwFind
KwKwtxhtx
KxhtfhK
xtfhK
EE3561_Unit 8 Al-Dhaifallah1435 36
Lecture 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
EE3561_Unit 8 Al-Dhaifallah1435 37
Taylor Series in One Taylor Series in One VariableVariable
hxandxbetweenisxwhere
xfn
hxf
i
hhxf n
ni
n
i
i
)(!
)(!
)(
f(x) ofexpansion SeriesTaylor The
)()(1
0
Approximation Error
EE3561_Unit 8 Al-Dhaifallah1435 38
Taylor Series in One Taylor Series in One VariableVariableanother lookanother look
hxxx
xfdx
dh
nxf
dx
dh
ihxf
f(x)
hxfdx
xfdhxf
dx
dh
nn
i
i
iii
ii
i
and between is
)(!
1)(
!
1)(
ofexpansion SeriesTaylor The
)()(
)(
Define
1
0
)(
EE3561_Unit 8 Al-Dhaifallah1435 39
DefinitionsDefinitions
2
22
2
2
22
2
1
0
),(),(2
),(),(
),(),(),(
),(),(
),(
y
yxfk
yx
yxfkh
x
yxfhyxf
yk
xh
y
yxfk
x
yxfhyxf
yk
xh
yxfyxfy
kx
h
x
fhyxf
xh
Define
i
ii
i
EE3561_Unit 8 Al-Dhaifallah1435 40
Taylor Series Expansion Taylor Series Expansion
)0,0(
)0.0(
1
)0.0(
0
2
),(
4),(
(0,0)at evaluated sderivative Parial
)2)(1(,
yx fkfhyxfy
kx
h
yxfy
kx
h
yxxy)f(x
EE3561_Unit 8 Al-Dhaifallah1435 41
Taylor Series in Two Taylor Series in Two VariablesVariables
),( and ),(between joining line on the is),(
),(!
1),(
!
1),(
, ofexpansion SeriesTaylor The
1
0
kyhxyxyx
errorionapproximat
yxfy
kx
hn
yxfy
kx
hi
kyhxf
y)f(xnn
i
i
x x+h
y
y+k
EE3561_Unit 8 Al-Dhaifallah1435 42
Runge-Kutta Method
possible. as accurate as is such that
,,,
:Problem
)()(
),(
),(
Kutta RungeOrder Second
21
2211
12
1
h)x(t
wwFind
KwKwtxhtx
KxhtfhK
xtfhK
EE3561_Unit 8 Al-Dhaifallah1435 43
Runge-Kutta Method
)(),()()(
),(2
1),(
)),(,(),()()(
...)('''6
)(''2
)(')()(
possible. as many terms asmatch to
,,, :Problem
322
2221
2
21
32
21
hOffhwfhwxtfhwwtxhtx
xtfx
ht
hfhfhffhxhtf
xtfhxhtfwxtfhwtxhtx
txh
txh
thxtxhtx
wwFind
tt
xt
EE3561_Unit 8 Al-Dhaifallah1435 44
Runge-Kutta Method
)(),()()(
...)('''6
)(''2
)(')()(
322
2221
32
hOffhwfhwxtfhwwtxhtx
txh
txh
thxtxhtx
tt
1,1,5.0,5.0
solution possibleOne
5.0,5.0,1
21
2221
ww
wwww
EE3561_Unit 8 Al-Dhaifallah1435 45
Runge-Kutta Method
21
12
1
2
1)()(
),(
),(
Kutta RungeOrder Second
KKtxhtx
KxhtfhK
xtfhK
EE3561_Unit 8 Al-Dhaifallah1435 46
Runge-Kutta MethodAlternative Formula
21
12
1
2)()(
),(
),(
Kutta RungeOrder Second
FFh
txhtx
hFxhtfF
xtfF
EE3561_Unit 8 Al-Dhaifallah1435 47
Runge-Kutta MethodAlternative Formula
21
12
1
2)()(
),(
),(
Form eAlternativ
FFh
txhtx
hFxhtfF
xtfF
21
12
1
2
1)()(
),(
),(
Kutta RungeOrder Second
KKtxhtx
KxhtfhK
xtfhK
EE3561_Unit 8 Al-Dhaifallah1435 48
Runge-Kutta MethodAlternative Formulas
21
12
1
2
1
2
11)()(
),(
),(
)0(select Formulas Kutta RungeOrder Second
FFtxhtx
KxhtfhK
xtfhK
2
1,
2
11,
number zero-nonany Pick
solutionanother
5.0,5.0,1
21
2221
ww
wwww
EE3561_Unit 8 Al-Dhaifallah1435 49
Runge-Kutta Method
4321
34
23
12
1
226
1)()(
),(
)2
1,
2
1(
)2
1,
2
1(
),(
Kutta RungeOrder Fourth
KKKKtxhtx
KxhtfhK
KxhtfhK
KxhtfhK
xtfhK
EE3561_Unit 8 Al-Dhaifallah1435 50
Second order Runge-Kutta Method Example
01.0,4)1(,)(1)(
RK2 using x(1.02)find tosystem following theSolve32 hxttxtx
EE3561_Unit 8 Al-Dhaifallah1435 51
Second order Runge-Kutta Method Example
8269.3)1662.018.0(2
14
2
1)1()01.01(
1662.0))01.()18.0(1(01.0),(
18.0)1(01.0),(
:1STEP
01.0,4)1(,)(1)(
RK2using x(1.02) find tosystem following theSolve
21
3212
321
32
KKxx
txKxhtfhK
txxtfhK
hxttxtx
EE3561_Unit 8 Al-Dhaifallah1435 52
Second order Runge-Kutta Method Example
6648.3)1545.01666.0(2
18254.3
2
1)01.1()01.001.1(
1545.0))01.()1666.0(1(01.0),(
1666.0)1(01.0),(
2 STEP
21
3212
321
KKxx
txKxhtfhK
txxtfhK
EE3561_Unit 8 Al-Dhaifallah1435 54
Summary Runge Kutta methods generate accurate
solution without the need to calculate high order derivatives.
Second order RK have local truncation error of order O(h3)
Fourth order RK have local truncation error of order O(h5)
N function evaluations are needed in N th order RK method.