ordinary differential equations
DESCRIPTION
Ordinary Differential Equations. Jyun-Ming Chen. Review Euler’s method 2 nd order methods Midpoint Heun’s Runge-Kutta Method. Systems of ODE Stability Issue Implicit Methods Adaptive Stepsize. Contents. Review. DE (Differential Equation) - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/1.jpg)
Ordinary Differential Equations
Jyun-Ming Chen
![Page 2: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/2.jpg)
Fall 2015 2
![Page 3: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/3.jpg)
3
Contents
• Review• Euler’s method• 2nd order methods
– Midpoint
– Heun’s
• Runge-Kutta Method
• Systems of ODE• Stability Issue• Implicit Methods• Adaptive Stepsize
Fall 2015
![Page 4: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/4.jpg)
4
Review
• DE (Differential Equation)– An equation specifying the relations among the
rate change (derivatives) of variables
• ODE (Ordinary DE) vs. PDE (Partial DE)– The number of independent variables involved
)( 2
2
txxdt
xd ),( 1 yxf
y
f
x
f
Fall 2015
![Page 5: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/5.jpg)
5
Review (cont)
• Solution of an equation:
• Solution of DE vs. Solution of Equation
0)1(1 :Solution
01)( 2
fx
xxf
• Geometrically,
f(x)
x
Fall 2015
![Page 6: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/6.jpg)
6
Review (cont)
• Solution of an differential equation:
• Geometrically:
solutions validall are
,2,
is,That
:Solution
tt
ttt
exex
ecececx
xdt
dx
t
x
Need additional conditions to
specify a solution
Fall 2015
![Page 7: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/7.jpg)
Concept of Vector Field
Fall 2015 7
![Page 8: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/8.jpg)
8
Review (cont)
• Order of an ODE– The highest derivative in the equation
• nth order ODE requires n conditions to specify the solution– IVP (initial value problem): All conditions
specified at the same (initial) point– BVP (boundary value problem): otherwise
Fall 2015
![Page 9: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/9.jpg)
9
IVP VS. BVPRevisit Shooting Problem
t
g
y
(2) 5
(1) 10
10
)10(let
)(
212
1
2
2
ctcty
ctdt
dydt
yd
ggy
tfy
Fall 2015
![Page 10: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/10.jpg)
10
IVP vs. BVP
ttty
c
c
ty
ty
55)(
5
0
5)0(
0)0(
:IVP
2
1
2
tty
ccy
cy
ty
ty
605
6010010500)10(
0)0(
100)10(
0)0(
:BVP
2
11
2
Physical meaning
Fall 2015
![Page 11: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/11.jpg)
11
Maxima on ODE
Ode2: solves 1st and 2nd order ODEIc1, ic2, bc: setting conditions‘ do not evaluate
2)0(, yydx
dy0)0(,1)0(,sin
2
2
xxtxdt
dx
dt
xd
Fall 2015
![Page 12: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/12.jpg)
12
Linear ODE
• Linearity:– Involves no product nor nonlinear functions of
y and its derivatives
• nth order linear ODE
)()()()()( 011
1
1 xbyxadx
dyxa
dx
ydxa
dx
ydxa
n
n
nn
n
n
Fall 2015
![Page 13: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/13.jpg)
13
Focus of This Chapter
• Solve IVP of nth order ODE numerically
• e.g.,
0 ),( Solve
0)0(
1)0( conditions initial ,
2
2
xxy
yx
dx
yd
dxdy
Fall 2015
![Page 14: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/14.jpg)
14
ODE (IVP)
• First order ODE (canonical form)
• Every nth order ODE can be converted to n first order ODEs in the following method:
0)0(),,( yxyyxfdx
dy
Fall 2015
![Page 15: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/15.jpg)
15
)()()()()( 011
1
1 xbyxadx
dyxa
dx
ydxa
dx
ydxa
n
n
nn
n
n
1
11
2
22
3
12
1
)(
)(
)(
)()(
n
nn
n dx
yd
dx
dyxy
dx
yd
dx
dyxy
dx
dy
dx
dyxy
xyxy
1
11
2
22
3
12
1
)(
)(
)(
)()(
n
nn
n dx
yd
dx
dyxy
dx
yd
dx
dyxy
dx
dy
dx
dyxy
xyxy
)()()()()( 10211
1
32
21
xbyxayxayxadx
dyxa
ydx
dy
ydx
dy
ydx
dy
nnn
n
nn
Fall 2015
![Page 16: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/16.jpg)
16
Example
xdx
dyx
dx
yd
dx
yd52 2
2
2
3
3
2
22
1
3
2
1
Let
dx
yddxdy
dxdy
dxdy
y
y
yy
21
32
22
33 52
ydx
dy
ydx
dy
xyxydx
dy
xyyx
y
y
yfy
y
y
y
y
52
)( ,Let
322
3
2
3
2
1
Fall 2015
![Page 17: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/17.jpg)
Equation of Motion哪裡來 ?
Fall 2015 17
Free Body Diagram (FBD)
Newton’s 2nd Law
mgN
xmkxxcF
![Page 18: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/18.jpg)
FBD: Pendulum
Fall 2015 18
cos
sin
mgT
mLmg
s
Newton’s 2nd Law
![Page 19: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/19.jpg)
FBD can be difficult…(ref)
Fall 2015 19
![Page 21: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/21.jpg)
Examples
0
2
12
1
2
2
kxxm
xmx
L
kxx
L
VTL
kxV
xmT
0sin
sin
cos2
1
cos2
1
2
2
2
gl
mlL
mglL
mgllmVTL
mglV
lmT
q
L
q
L
dt
d
VTL
![Page 22: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/22.jpg)
Pendulum on a Moveable Support (ref)
Fall 2015 22
![Page 23: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/23.jpg)
Fall 2015 23
3
324
1
4
2
3
3
3
324
4
23
3
323
4
324342
4
3
2
1
sin
sin
1cos
cos
sin
sin
1cos
cos
0sincos
0sincos
xl
gxmlx
Kx
x
l
xxmlmM
K
xl
gxmlx
x
x
l
xxmlmM
xl
gx
l
xx
xmlxxxmlxmM
x
x
xx
xx
4
2
4
2
3
1
x
x
x
x
x
x
![Page 24: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/24.jpg)
[Homework: Double Pendulum]
Fall 2015 24
![Page 25: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/25.jpg)
End of Review
![Page 26: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/26.jpg)
26
xyxfxyxxy
xyxfyxyxxy
xyxfy
yxfdx
dy
x
y
yxyyxfdx
dy
),()()(
),()()(
),(
),(
)(),,( 00
The Canonical Problem
dx
dy
x
yx
,0
This is Euler’s method
Fall 2015
![Page 27: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/27.jpg)
27
Example
1)0(, yydx
dy
729.0081.081.01.0)81.0()2.0()3.0(
81.009.09.01.0)9.0()1.0()2.0(
9.01.011.0)1()0()1.0(
1.0 Choose
1)1,0(,),(
yy
yy
yy
x
fyyxfCompare with exact sol:
Fall 2015
![Page 28: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/28.jpg)
28
Example (cont)
1)0(
ln
:SolutionExact
x
x
ey
cyecy
cxy
dxy
dy
1.0
1
x
y
y=e–x
Fall 2015
![Page 29: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/29.jpg)
29
Error Analysis(Geometric Interpretation)
xyxfyy
xyxfyyy
xyxfy
yxfdx
dy
x
y
yxyyxfdx
dy
),(
),(
),(
),(
)(),,(
0001
0001
00
If the true solution were a straight line, thenEuler is exact
Think in terms of Taylor’s
expansionFall 2015
![Page 30: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/30.jpg)
30
Error Analysis(From Taylor’s Expansion)
2
62
2
32
),(),()(
)()()()()(x
dxd
xx
yxfxyxfxy
xyxyxxyxyxxy
Euler’sEuler’s truncation errorO(x2) per step
1st order method
Fall 2015
![Page 31: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/31.jpg)
31
Cumulative Error
x
y
x = 0 x = T
Remark:x Error But computation time
Number of steps = T/xCumulative Err. = (T/x) O(x2) = O(x) Fall 2015
![Page 32: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/32.jpg)
32
Example (Euler’s)
xexyyydx
dy )(:exact 1, 0
)(9.0)1)(()(
1.0Let
)()()(
)(),(
xyxxyxxy
x
xxyxyxxy
xyyxf
,...729.0)3.0(,81.0)2.0(,9.0)1.0( yyy
Fall 2015
![Page 33: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/33.jpg)
Methods Improving Euler
Motivated by
Geometric Interpretation
![Page 34: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/34.jpg)
34
Midpoint Method
xxyxfxyxxy
xyxfxyxyxx
xx
))(,()()(
))(,()()(
22
22
xxyxfxyxxy
xyxfxyxyxx
xx
))(,()()(
))(,()()(
22
22
Fall 2015
![Page 35: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/35.jpg)
35
Example (Midpoint)
xxyxy
xxyxfxyxxy
xyxyxy
yxfxyxy
yyxf
x
xx
xx
xx
2
22
22
22
1)( )(
))(,()()(
1)()()(
),()()(
),(
)(905.0)1.0)(05.01)(()()1.0(
1.0Let
1)()()( 2
xyxyxyxy
x
xxyxyxxy x
xexyyydx
dy )(:exact 1, 0
,...741.0)3.0(,819.0)2.0(,905.0)1.0( yyyFall 2015
![Page 36: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/36.jpg)
36
Heun’s Method
xxxyxxfyxfxyxxy
xxyxfxyxxy
))(,(),()()(
)(Predictor ))(,()()(0
21
0
xxxyxxfyxfxyxxy
xxyxfxyxxy
))(,(),()()(
)(Predictor ))(,()()(0
21
0
Fall 2015
![Page 37: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/37.jpg)
37
Example (Heun’s)
xexyyydx
dy )(:exact 1, 0
,...741.0)3.0(,819.0)2.0(,905.0)1.0( yyy
Note the result is the same as
Midpoint!?
Fall 2015
)(905.01.09.011)()1.0(
1.0Let
1)()()(
)()( )(
))(,(),()()(
1)()()(
),()()(
),(
21
21
021
021
0
xyxyxy
x
xxxyxyxy
xxxyxyxy
xxxyxxfyxfxyxxy
xxyxxyxy
xyxfxyxxy
yyxf
![Page 38: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/38.jpg)
38
Remark
• Comparison of Euler, Heun, midpoint– 1st order: Euler
– 2nd order: Heun, midpoint
• “order”:• All are special cases of
RK (Runge-Kutta) methods
ExactEuler (error)
Midpoint (error)
y(0.1) 0.9050.9 (0.0
05)0.905
(0)
y(0.2) 0.8190.81 (0.
009)0.819
(0)
y(0.3) 0.7410.729 (0.
012)0.741
(0)
Fall 2015
![Page 39: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/39.jpg)
39
RK Methods
)1 to from slope (estimate
function lincrementa :),,(
)( ),(
where
),,(
1
1
ii
hyx
hxyyxyy
hhyxyy
ii
iiii
iiii
Fall 2015
![Page 40: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/40.jpg)
40
RK Methods (cont)
expansion sTaylor'match chosen to are ),,( Constants
constants:,
),(
),(
),(
),(
constant:'
11,111,1
22212123
11112
1
2211
ijii
iji
nnnniiin
ii
ii
ii
nn
qpa
qp
nkqnkqyhpxfk
hkqhkqyhpxfk
hkqyhpxfk
yxfk
sa
kakaka
Fall 2015
![Page 41: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/41.jpg)
41
Taylor’s Expansion
fy
f
x
f
yy
f
x
f
dx
dy
y
f
dx
dx
x
fyxf
dx
d
'),(
)(][
)(][),()(
)()()()()(
32
32
32
2
2
2
hOfhfy
hOfhyxfxy
hOxyhxyxyhxy
hiiy
f
ixf
ii
hiiy
f
ixf
iii
hidx
diii
Fall 2015
![Page 42: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/42.jpg)
42
RK 1st Order
method sEuler' ),(
1
expantion sTaylor' with Compare
),(
),(
1
1
1
11
111
hyxfyy
a
hyxfayy
yxfaka
n
iiii
iiii
ii
)(][)( 32
2
hOfhfyhxy hiiy
f
ixf
iii
Fall 2015
![Page 43: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/43.jpg)
43
RK 2nd Order
)(
)(][
)()()(),(
: Expand
32112
21221
311112111
211112
2
hOhfqahpahfahfay
hOhhkqhpfahkayy
hOhkqy
fhp
x
fyxfk
k
iyf
xf
iii
yf
xf
iii
iiii
hkakayy
hkqyhpxfk
yxfk
kakan
ii
ii
i
)(
),(
),(
2
22111
11112
11
2211
)(][)( 32
2
hOfhfyhxy hiiy
f
ixf
iii
21
1122
21
122
21
:
:
1 :
qahf
pah
aahf
iyfxfi
Fall 2015
![Page 44: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/44.jpg)
44
RK 2nd Order (cont)
unknowns 4
eqns, 3
:
:
1 :
21
1122
21
122
21
qahf
pah
aahf
iyfxfi
21
1121
112 , ,01 qpaa
hyxfyhxfyy
hhkqyhpxfyhky
hkakayy
iiiiii
iiii
ii
)),(,(
),(
)(
21
21
1
11112
22111
),(),,(
)( )(
21
2121
22111
hfyhxfkyxfk
hkkyhkakayy
iiiii
iii
Fall 2015
![Page 45: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/45.jpg)
45
RK 4th Order
• Mostly commonly used one
• Higher order … more evaluation, but less gain on accuracy
Classical 4th order
RK
)(
)(
)(
)(
where
)22(
34
221
21
3
121
21
2
1
432161
1
hkh,yxfk
hkh,yxfk
hkh,yxfk
,yxfk
hkkkkyy
nn
nn
nn
nn
nn
Fall 2015
![Page 46: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/46.jpg)
46
Classical 4th order RK
Fall 2015
![Page 47: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/47.jpg)
47
System of ODE
• Convert higher order ODE to 1st order ODEs
• All methods equally apply, in vector form
Fall 2015
![Page 48: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/48.jpg)
48
Example (Mass-Spring-Damper System)
• Governing Equation
• After setting the initial conditions x(0) and x’(0), compute the position and velocity of the mass for any t > 0
0 kxxcxm
c
k
Initial Condition
x
m
Fall 2015
![Page 49: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/49.jpg)
49
0)0(
1)0(:IC
)(10
then
,
2
1
212
21
122
21
x
x
cxkxm
x
xxkxcxxm
xxxx
Example (cont)
0)0(,),()()(
Euler Dim
yyxyxfxyxxy
n
0)0(,),()()(
Euler Dim
yyxyxfxyxxy
n
Fall 2015
![Page 50: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/50.jpg)
50
set t=0.1
27.0
971.01.0
)19.0(99.0
19.0
19.0
99.01.0)2.0),2.0(()2.0()3.0(
19.0
99.01.0
)1.0(1
1.0
1.0
11.0)1.0),1.0(()1.0()2.0(
1.0
11.0
01
0
0
11.0)0.0),0.0(()0.0()1.0(
xfxx
xfxx
xfxx
Example (cont)
)(),(
211
2
2
1
cxkx
xtxf
x
xx
m
Assume m=1,c=1, k=1 (for ease of computation)
21
2
xx
xf
Fall 2015
![Page 51: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/51.jpg)
51
Stability: Symptom
xexy
yydx
dy
10)( :solutionexact
1)0(,10
Fall 2015
![Page 52: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/52.jpg)
52
Symptom: Unstable Spring System
Start with this …
Become unstable instantly …
Cause by stiff (k=4000) springsCause by stiff (k=4000) springs
Fall 2015
![Page 53: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/53.jpg)
53
Stability (cont)• Example Problem:
xexy
yydx
dy
)( :solutionexact
0,1)0(,
xexy
yydx
dy
)( :solutionexact
0,1)0(,
Conditionally stablex
iiii
exy
h
hh
hh
h
h
yhhyyy
)( :solutionexact
2limit stability
2 0
1 1or ,1 1
is,That
11 if unstable
11 if stable
)1(
:Euler
*
1
Fall 2015
![Page 54: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/54.jpg)
54
Discussion
• Different algorithm different stability limit– Check Midpoint Method
• Different problem different stability limit– use the previous problem as benchmark
Fall 2015
![Page 55: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/55.jpg)
55
Review: Numerical DifferentiationTaylor’s expansion:
Forward difference
Backward difference
Fall 2015
![Page 56: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/56.jpg)
56
Numerical Difference (cont)
Central difference
Fall 2015
![Page 57: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/57.jpg)
57
Implicit Method (Backward Euler)
)(),(
)(),(
),()(
)1,(:Euler Backward
2111
21
1
hOyhyxfy
hOyhyxfy
yxfhOh
yy
ii
iiiii
iiii
iiii
)(),(
),()(
),1( :Euler
),(
21
1
hOhyxfyy
yxfhOh
yy
ii
yxf
iiii
iiii
dxdy
Forward difference
Backward difference
Fall 2015
![Page 58: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/58.jpg)
58
Example
• Remark:– Always stable (for this problem)– Truncation error the same as Euler (only
improve the stability)
ihi
ii
iiiiii
yy
hOyyh
hOyhyyhyxfy
yyxf
11
1
21
211111
)()1(
)(),(
),(
Fall 2015
![Page 59: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/59.jpg)
59
Stiff Set of ODE
Stability limit
Use the change of variable
101)0(
121)0(
1000210002
2
2121
21
100021
ccccv
ccu
eczecy
zvuzvu
yvuyvu
zyvzyu
xx
101)0(
121)0(
1000210002
2
2121
21
100021
ccccv
ccu
eczecy
zvuzvu
yvuyvu
zyvzyu
xxGet the following solution:
A stiff equation is a differential equation for which certain numerical methods for solving the equation are numerically unstable, unless the step size is taken to be extremely small Fall 2015
![Page 60: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/60.jpg)
60Fall 2015
![Page 61: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/61.jpg)
61
Linear System of ODE with Constant Coefficients
ii
ii
iii
yhCIy
hOyyhCI
hOhCyyy
11
21
21
)(
)(
EulerImplicit
ii
ii
iii
yhCIy
hOyhCIy
hOhCyyy
1
21
21
)()(
)(
EulerExplicit
Cyy
Do not really use (..)-
1. Solve linear system insteadFall 2015
![Page 62: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/62.jpg)
62
Analysis
222111)(
22221
211222111222111
)1()2(
22211122112211)0()1(
2211)0(
)()1(
xcxcx
xcxcAxcAxcxcxcAAxx
xcxcAxcAxcxcxcAAxx
xcxcx
Axx
nnn
ii
x will converge if |i| 1
represent x(0) in eigen basis
Explicit and implicit Euler both in the form: Ayy
Fall 2015
![Page 63: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/63.jpg)
63
Analysis (cont)
• Stiff equations have large eigenvalues• Explicit Euler requires small h to converge• Implicit Euler always converges (in this problem)
hCIh
hCh
C
i
i
i
of values-e: 1
of values-e:
of values-e :
11 of values-e: 1 hCIh i
ii yhCIy 1
EulerExplicit
ii yhCIy 11
EulerImplicit
Fall 2015
![Page 64: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/64.jpg)
64
Example
v
u
v
u
vuv
vuu
1999999
1998998
1999999
1998998
Explicit
002.021000
1100011
110001 if
hh
h
hstable
Implicit
110001
1 if
hstable
Fall 2015
![Page 65: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/65.jpg)
65
Semi-Implicit Euler• Not guaranteed to be stable, but usually is
Solving implicit methods by linearization is called a “semi-implicit” method
nnn
nnnnn
yhfyy
fhIy
y
fhI
yy
fhy
y
fhyhfyy
1
11
Jacobian
Fall 2015
![Page 66: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/66.jpg)
66
About Jacobian
h
xx
fffxfhxf
hOh
h
xxf
xxf
xxf
hxhxf
hxhxf
hxhxf
hOhhxxfhxhxf
hOhhxxfhxhxf
hOhhxxfhxhxf
xf
xf
xf
xf
xf
xf
xf
xf
xf
xf
xf
xf
21
321
2
213
212
211
213
212
211
2213213
2212212
2211211
,
,,
)(
,
,
,
,
,
,
)(,,
)(,,
)(,,
2
3
1
3
2
2
1
2
2
1
1
1
2
3
1
3
2
2
1
2
2
1
1
1
Jacobian
Taylor’s expansion:
Fall 2015
![Page 67: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/67.jpg)
67
c
k
Initial Condition
x
m
0
:Motion ofEquation
kxxcxm
xmkxxcxmf
nmhc
mkhn
mc
mk
m
yh
y
yy
cxkxx
xx
xx
xx
1
1
211
2
21
2
1
1
1
10
xc
force damping
Implicit Euler
ii yhCIy
Cyy1
1
Fall 2015
![Page 68: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/68.jpg)
68
c
k
Initial Condition
x
m
0
:Motion ofEquation
2
2
kxxcxm
xmkxxcxmf
221
2
1
21
2
2212
21
2
1
21
1
21
10
)(
1Let
xx
x
hxh
hhyy
xy
f
yfy
xxx
xx
xx
xx
kcm
nn
2
force damping fake
xc
Semi-Implicit EulerFall 2015
![Page 69: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/69.jpg)
69
Ex: Semi-Implicit Euler
g
ty
h
hh
ty
ty
hty
hty
fh
hyfh
hyy
yy
ff
y
fJ
yygy
yyyygy
nnnnn
)(
0)(
)(
)(
)(
10
1
10
1
00
10
,
,
3)0(,0)0(,3)0(,0)0(,
22
2
1
2
1
1
1
21
21
212
21
hg
ty
ty
ty
hty
hty
hfyy
Euler
nnn
)(
)(
)(
)(
)(
Compare
2
2
1
2
1
1
Fall 2015
![Page 70: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/70.jpg)
70
Amazingly, this translates to…
tgtvttv
tgttvtytty
g
ty
h
hh
ty
ty
hty
hty
)()(
)()()(
)(
0)(
)(
)(
)(
2
22
2
1
2
1
Very similar to Verlet integration formula… no
wonder Verlet is pretty stable
Fall 2015
![Page 71: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/71.jpg)
GSL
71Fall 2015
![Page 72: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/72.jpg)
Initialization
72Fall 2015
![Page 73: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/73.jpg)
Iteration
73Fall 2015
![Page 74: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/74.jpg)
Extra
Fall 2015 74
![Page 75: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/75.jpg)
75
Adaptive Stepsize
• Solving ODE numerically … tracing the integral curve y(x)
• what’s wrong with uniform step size– Uniformly small:
waste effort
– Uniformly large: might miss details
Fall 2015
![Page 76: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/76.jpg)
76
Step Doubling
• Idea:– Estimate the truncation error by taking each
step twice: one full step, two half steps– control the step size such that the estimated
error is not too big.
1(2h1)
2(h1)Desired h0Fall 2015
![Page 77: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/77.jpg)
77
Ex: RK 2nd Order
00
11
11
00
3
1
0
1
0
3312
432
431
432
431
error desired theproduce tostepsize the:
stepby error estimated the:
error)n truncatio(the 6
)()(2)()2(
)()(2)2(
)()2()2(
31
h
h
hhh
h
hchyy
hOhcyhOhcy
hOhcyhxy
hOhcyhxy
Overhead: # of f(x,y) evaluations24–2 = 6
Overhead: # of f(x,y) evaluations24–2 = 6
Fall 2015
![Page 78: Ordinary Differential Equations](https://reader033.vdocuments.net/reader033/viewer/2022061322/56815749550346895dc4ecd5/html5/thumbnails/78.jpg)
78
Adaptive Step with RK4 (NR)
Fall 2015