Date post: | 04-Apr-2018 |
Category: |
Documents |
Upload: | mohammad-rameez |
View: | 214 times |
Download: | 0 times |
of 36
7/29/2019 CISE301-Topic8L4&5.ppt
1/36
CISE301_Topic8L4&5 1
SE301: Numerical Methods
Topic 8Ordinary Differential Equations (ODEs)
Lecture 28-36
KFUPM(Term 101)
Section 04
Read 25.1-25.4, 26-2, 27-1
7/29/2019 CISE301-Topic8L4&5.ppt
2/36
CISE301_Topic8L4&52
Outline of Topic 8
Lesson 1: Introduction to ODEs
Lesson 2: Taylor series methods
Lesson 3: Midpoint and Heuns method
Lessons 4-5: Runge-Kutta methods
Lesson 6: Solving systems of ODEs
Lesson 7: Multiple step Methods
Lesson 8-9: Boundary value Problems
7/29/2019 CISE301-Topic8L4&5.ppt
3/36
CISE301_Topic8L4&53
Lecture 31Lesson 4: Runge-Kutta Methods
7/29/2019 CISE301-Topic8L4&5.ppt
4/36
CISE301_Topic8L4&54
Learning Objectives of Lesson 4
To understand the motivation for usingRunge Kutta method and the basic ideaused in deriving them.
To Familiarize with Taylor series forfunctions of two variables.
Use Runge Kutta of order 2 to solveODEs.
7/29/2019 CISE301-Topic8L4&5.ppt
5/36
CISE301_Topic8L4&55
Motivation
We seek accurate methods to solve ODEsthat do not require calculating high orderderivatives.
The approach is to use a formulainvolving unknown coefficients thendetermine these coefficients to match asmany terms of the Taylor series
expansion.
7/29/2019 CISE301-Topic8L4&5.ppt
6/36
CISE301_Topic8L4&56
Second Order Runge-Kutta Method
possible.asaccurateasisthatsuch,,,
:Problem
),(
),(
1
21
22111
12
1
i
ii
ii
ii
ywwFind
KwKwyy
KyhxfhK
yxfhK
7/29/2019 CISE301-Topic8L4&5.ppt
7/36
CISE301_Topic8L4&57
Taylor Series in TwoVariables
The Taylor Series discussed in Chapter 4is extended to the 2-independent
variable case.
This is used to prove RK formula.
7/29/2019 CISE301-Topic8L4&5.ppt
8/36
CISE301_Topic8L4&58
Taylor Series in One Variable
hxandxbetweenisxwhere
xfn
h
xfi
h
hxf
f(x)n
nn
i
n
i
i
)()!1()(!)(
ofexpansionSeriesTaylororderThe
)1(1
)(
0
th
Approximation Error
7/29/2019 CISE301-Topic8L4&5.ppt
9/36
CISE301_Topic8L4&59
Derivation of 2nd Order
Runge-Kutta Methods1 of 5
)(),('2
),(
:aswritteniswhich
)(2
),(:ODEsolvetoUsed
ExpansionSeriesTaylorOrderSecond
32
1
3
2
22
1
hOyxfh
yxfhyy
hOdx
ydh
dx
dyhyy
yxfdx
dy
iiiiii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
10/36
Derivation of 2nd Order
Runge-Kutta Methods2 of 5
CISE301_Topic8L4&510
)(2),(),(
:
),(
),(),(
),('
ationdifferentirule-chainbyobtainedis),('where
32
1 hOh
yxfy
f
x
fhyxfyy
ngSubstituti
yxfy
f
x
f
dx
dy
y
yxf
x
yxf
yxf
yxf
iiiiii
7/29/2019 CISE301-Topic8L4&5.ppt
11/36
CISE301_Topic8L4&511
Taylor Series in Two Variables
),(and),(betweenjoininglinetheonis),(
),()!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
7/29/2019 CISE301-Topic8L4&5.ppt
12/36
CISE301_Topic8L4&512
Derivation of 2nd Order
Runge-Kutta Methods3 of 5
),(),(
:ngSubstituti
),(
),(
thatsuch,,,:Problem
1211
22111
12
1
21
Kyhxfhwyxfhwyy
KwKwyyKyhxfhK
yxfhK
wwFind
iiiiii
ii
ii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
13/36
Derivation of 2nd Order
Runge-Kutta Methods4 of 5
CISE301_Topic8L4&513
...),(),()(
...),()(
...),(),(
:
...),(),(
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
7/29/2019 CISE301-Topic8L4&5.ppt
14/36
Derivation of 2nd Order
Runge-Kutta Methods5 of 5
CISE301_Topic8L4&514
2
1,1:solutionpossibleOne
solutionsinfiniteunknowns4withequations32
1and,
2
1,1
:equationsthreefollowingtheobtainweterms,Matching
)(2
),(),(
...),(),()(
:forexpansionstwoderivedWe
21
2221
3
2
1
22
22211
1
ww
wwww
hOhyxfyf
xfhyxfyy
yxfy
fhw
x
fhwyxfhwwyy
y
iiiiii
iiiiii
i
7/29/2019 CISE301-Topic8L4&5.ppt
15/36
2nd Order Runge-Kutta Methods
CISE301_Topic8L4&5 15
2
1and,
2
1,1
:thatsuch,,,Choose
),(
),(
2221
21
22111
12
1
wwww
ww
KwKwyy
KyhxfhK
yxfhK
ii
ii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
16/36
CISE301_Topic8L4&5 16
Alternative Form
22111
12
1
),(
),(
FormeAlternativ
kwkwhyy
khyhxfk
yxfk
ii
ii
ii
22111
12
1
),(
),(
KuttaeOrder RungSecond
KwKwyy
KyhxfhK
yxfhK
ii
ii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
17/36
CISE301_Topic8L4&5 17
Choosing , , w1and w2
CorrectorSingleawith'isThis
),(),(22
1
),(
),(
:becomesmethodKutta-eOrder RungSecond
2
1,1then,1choosingexample,For
0
11211
12
1
21
s MethodHeun
yxfyxf
h
yKKyy
KyhxfhK
yxfhK
ww
iiiiiii
ii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
18/36
CISE301_Topic8L4&5 18
Choosing , , w1and w2
MethodMidpointtheisThis
)2
,2
(
)2
,2
(
),(
:becomesmethodKutta-eOrder RungSecond
1,0,2
1then
2
1Choosing
121
12
1
21
KyhxfhyKyy
Ky
hxfhK
yxfhK
ww
iiiii
ii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
19/36
CISE301_Topic8L4&5 19
2nd Order Runge-Kutta MethodsAlternative Formulas
211
1i2
1
2
1
2
11
),(
),(
)0(selectmulasKutta ForeOrder RungSecond
KKyy
KyhxfhK
yxfhK
ii
i
ii
2
11,
2
1,:numbernonzeroanyPick
1,2
1,
2
1
12
2122
ww
wwww
7/29/2019 CISE301-Topic8L4&5.ppt
20/36
CISE301_Topic8L4&5 20
Second order Runge-Kutta MethodExample
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)findtosystemfollowingtheSolve
21
3020
1002
30
20001
32
KKxxtx
KxhtfhK
txxtfhK
hxtxtx
x
7/29/2019 CISE301-Topic8L4&5.ppt
21/36
CISE301_Topic8L4&5 21
Second order Runge-Kutta MethodExample
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(
2STEP
21
31
21
1112
31
21111
KKxx
tx
KxhtfhK
txxtfhK
7/29/2019 CISE301-Topic8L4&5.ppt
22/36
CISE301_Topic8L4&5 22
1RK2,Using
[1,2]for tSolution
,4)1(,)(1)( 32
xttxtx
7/29/2019 CISE301-Topic8L4&5.ppt
23/36
CISE301_Topic8L4&5 23
Lecture 32Lesson 5: Applications of Runge-Kutta
Methods to Solve First Order ODEs
Using Runge-Kutta methods of different
orders to solve first order ODEs
7/29/2019 CISE301-Topic8L4&5.ppt
24/36
CISE301_Topic8L4&5 24
2nd Order Runge-Kutta RK2
)(iserrorglobaland)(iserrorLocal
2
),(
),(
correctorsingleawithmethodsHeun'toEquivalent
RK2asKnow1,ofvalueTypical
23
211
12
1
hOhO
kkh
yy
hkyhxfk
yxfk
ii
ii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
25/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.
7/29/2019 CISE301-Topic8L4&5.ppt
26/36
CISE301_Topic8L4&5 26
3rd Order Runge-Kutta RK3
)(iserrorGlobaland)(iserrorLocal
46
)2,(
)2
1,2(
),(
RK3asKnow
34
3211
213
12
1
hOhO
kkkh
yy
hkhkyhxfk
hkyh
xfk
yxfk
ii
ii
ii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
27/36
CISE301_Topic8L4&5 27
4th Order Runge-Kutta RK4
)(iserrorglobaland)(iserrorLocal
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
7/29/2019 CISE301-Topic8L4&5.ppt
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
7/29/2019 CISE301-Topic8L4&5.ppt
29/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
7/29/2019 CISE301-Topic8L4&5.ppt
30/36
CISE301_Topic8L4&5 30
Example: RK4
)4.0(),2.0(4
5.0)0(,1
:Problem2
yyfindtoRKUse
yxydx
dy
7/29/2019 CISE301-Topic8L4&5.ppt
31/36
CISE301_Topic8L4&5 31
4th Order Runge-Kutta RK4
)(iserrorglobaland)(iserrorLocal
226
),(
)2
1,
2(
)2
1,
2(
),(
45
43211
3i4
2i3
12
1
hOhO
kkkkhyy
hkyhxfk
hkyh
xfk
hkyh
xfk
yxfk
ii
i
i
ii
ii
7/29/2019 CISE301-Topic8L4&5.ppt
32/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
:Problem2
yyfindtoRKUse
yxydx
dy
See RK4 Formula
Step1
7/29/2019 CISE301-Topic8L4&5.ppt
33/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
:Problem2
yyfindtoRKUse
yxydx
dy
Step2
7/29/2019 CISE301-Topic8L4&5.ppt
34/36
CISE301_Topic8L4&5 34
Example: RK4
)4.0(),2.0(4
5.0)0(,1
:Problem2
yyfindtoRKUse
yxydx
dy
xi yi
0.0 0.5
0.2 0.8293
0.4 1.2141
Summary of the solution
7/29/2019 CISE301-Topic8L4&5.ppt
35/36
CISE301_Topic8L4&5 35
Summary
Runge Kutta methods generate anaccurate solution without the need tocalculate high order derivatives.
Second order RK have local truncationerror of order O(h3) and global truncationerror of order O(h2).
Higher order RK have better local and
global truncation errors.
N function evaluations are needed in theNth order RK method.
7/29/2019 CISE301-Topic8L4&5.ppt
36/36
CISE301_Topic8L4&5 36
Remaining Lessons in Topic 8
Lesson 6:Solving Systems of high order ODE
Lesson 7:Multi-step methods
Lessons 8-9:
Methods to solve Boundary Value Problems