Numerical Analysis – Numerical Analysis – Differential EquationDifferential Equation
Hanyang University
Jong-Il Park
Department of Computer Science and Engineering, Hanyang University
Differential EquationDifferential Equation
Department of Computer Science and Engineering, Hanyang University
Solving Differential EquationSolving Differential Equation
Differential EquationOrdinary D.E.
Partial D.E. Ordinary D.E.
Linear eg. Nonlinear eg.
Initial value problem
Boundary value problem
)('' tfyy )(''' tfyyy
Usually no closed-form solution
linearizationnumerical solution
0)0()0(,0. ''' yyyyeg
3)1(,0)0(,1054. ''' yyyyyeg
Department of Computer Science and Engineering, Hanyang University
Discretization in solving D.E.Discretization in solving D.E.
Discretization
Errors in Numerical Approach Discretization error
Stability error
y
tGrid Points
Exact sol.
deD yye
ndS yye
sol. numerical:
sol.ddiscretize:
sol.exact :
n
d
e
y
y
y
Department of Computer Science and Engineering, Hanyang University
ErrorsErrors Total error
SD eee truncation round-off
De Se0 increaseas t 0 as t 0
trade-off
t
eDeSe
Department of Computer Science and Engineering, Hanyang University
Local error & global errorLocal error & global error
Local error The error at the given step if it is assumed that all the
previous results are all exact Global error
The true, or accumulated, error
Department of Computer Science and Engineering, Hanyang University
Useful concepts(I)Useful concepts(I)
Useful concepts in discretization Consistency
Order
Convergence
00)( Deht
55
22
)(
)(
hehO
hehO
D
D
0h
eyy
t
Department of Computer Science and Engineering, Hanyang University
Useful concepts(II)Useful concepts(II) stability
stable
unstable
y
t
Consistentstable
Converge
Department of Computer Science and Engineering, Hanyang University
StabilityStability
Stability condition
0' )0(, yyAyy eg.
Exact sol.Euler method
Ateyy 0
01
1
)1(
)1(
yhA
yhA
hAyyy
n
n
nnn
For stability
AhhA 201|1|
Amplification factor
Department of Computer Science and Engineering, Hanyang University
nnnn
nnn
yhhyhyy
hfyy
)1(2.1)2.1(1
1
h
hy
yhyy
hfyy
n
nnn
nnn
1
2.1
)2.1( 11
11
Explicit :
Implicit :
h increase
h large
h small
ye
y
t
y
texplicit implicit
“conditionally stable” “stable”
yyyyy 2.12.0)0(,2.1 ''eg.= f
Implicit vs. Explicit MethodImplicit vs. Explicit Method
Department of Computer Science and Engineering, Hanyang University
Modification to solve D.E.Modification to solve D.E.
Modified Differential Eq.
)(. ' tgAyyeg
Diff.eq.
ModifiedD.E.
Discretization
Discretization by Euler method)(1 nnnn Ayghyy
<Consistency check>
''!2
1'
''2!2
1'
''2!2
1'1
|
)(||
||
hygAyy
Ayghyyhhyy
yhhyyy
nnn
nnnnnn
nnnn
0Let h nnn gAyy |' consistent;
<Order>)(|' hOgAyy nnn
Department of Computer Science and Engineering, Hanyang University
Initial Value Problem: ConceptInitial Value Problem: Concept
Department of Computer Science and Engineering, Hanyang University
Initial value problemInitial value problem
Initial Value Problem
Simultaneous D.E.
High-order D.E.
00' )(,),( ytyytfdt
dyy
00,21
1001,2111
)(),,,,(
)(),,,,(
nnnnn
n
ytyyyytfdt
dy
ytyyyytfdt
dy
)1(00
)1('00
'0
)(
)1(''')(
)(,,)(,
),,,,,(0
nnt
nn
ytyytyyy
yyyytfy
Department of Computer Science and Engineering, Hanyang University
Well-posed conditionWell-posed condition
Department of Computer Science and Engineering, Hanyang University
Taylor Series Method
),(' ytfy
nnn
n Rhyhyhyyhty )(0!
12''0!2
1'000 )(
Truncation error)( 0 hty
)( 0ty
0t ht 0
h
htt
yn
hR n
n
n
00
)1(1
,)()!1(
Taylor series method(I)Taylor series method(I)
Department of Computer Science and Engineering, Hanyang University
High order differentiation
Implementation
22
'''
''
2
)()(][
))](,([
fffffffff
fffy
fft
ffffffdt
dy
fffdt
dy
y
f
t
ftytf
dt
dy
yyytytytt
yytyttyt
yt
<Type 1>
Complicated computation
0t'0y''
0y'''
0y
hhh
y
tLess computation accuracy
<Type 2>
h h h
0t 1t 2t 3t'0y''
0y'''
0y
'1y''
1y'''
1y
'2y''
2y'''
2y
....
y
tMore computation accuracy
Requiring complicated source codes
Taylor series method(II)Taylor series method(II)
Department of Computer Science and Engineering, Hanyang University
Euler method(I)Euler method(I)
Euler Method
0t
....y
t1t 2t 3t ....
0y0y
1y2y
3y
h
00' )(),,( ytyytfy
Talyor series expansion at to
1002
0''
!21'
001 ,)( tthyhyyy
0
00 ),(
f
ytf
Department of Computer Science and Engineering, Hanyang University
Euler method(II)Euler method(II)
Error
Eg. y’ =-2x3+12x2-20x+8.5, y(0)=1
Department of Computer Science and Engineering, Hanyang University
Euler method(III)Euler method(III)
12
2''!2
11
,)(
)(
nnnnn
nnnn
tthOhfy
hyhfyy
1
010112010 )()()()(
n
iiinnn yyyyyyyyyyy
)()()(2
1
)(2
1
)(
_''
0
2_
''0
2''1
021
hOhytt
hyh
tt
hye
n
n
i
n
it
Generalizing the relationship
Euler’s approx.truncation error
Error Analysis
Accumulated truncation error
h
ttn
ttyy
n
n
n
iin
0
0
1
0
''1'' ,)()(
; 1st order
Department of Computer Science and Engineering, Hanyang University
Eg. Euler methodEg. Euler method
Department of Computer Science and Engineering, Hanyang University
Modified Euler method: Heun’s methodModified Euler method: Heun’s method
Modified Euler’s Method Why a modification?
errormodify
nt nt 1nt
Cny 1
Pny 1
Pnf 1
nf2
1Pnn ff
1nt
Predictor
Average slope
Corrector
nnPn hfyy 1
2
),(),(
211
'1
''
Pnnnnnn ytfytfyy
y
)],(),([2 11
'1 nnnnnn
Cn ytfytf
hyyhyy
Department of Computer Science and Engineering, Hanyang University
Heun’s method with iterationHeun’s method with iteration
Iteration
significant improvement
Department of Computer Science and Engineering, Hanyang University
Error analysis Error analysis Error Analysis
Taylor series
Total error
)(][
)()(
)(
3'1
'2
'''3!3
1''
1221'
'''3!3
1''221'
1
hOyyy
yhhOh
yyhhyy
yhyhhyyy
nnh
n
nnnn
nnnn
truncation3rd order
)( 2hO ; 2nd order method
※ Significant improvement over Euler’s method!
Department of Computer Science and Engineering, Hanyang University
Eg. Euler vs. Modified EulerEg. Euler vs. Modified Euler EulerModified
Euler Method
improvement
Department of Computer Science and Engineering, Hanyang University
Runge-Kutta methodRunge-Kutta method
Runge-Kutta Method Simple computation
very accurate
The idea
code sourceEasy .,,no ''' yy
),,(1 hythyy nnnn
where
),(
),(
),(
11
112
1
2211
nnnnn
nn
nn
nn
ytfk
ytfk
ytfk
kakaka
Department of Computer Science and Engineering, Hanyang University
Second-order Runge-Kutta methodSecond-order Runge-Kutta method
Second-order Runge-Kutta method
),(
),(
)(
112
1
22111
nn
nn
nn
ytfk
ytfk
kakahyy ①
Taylor series expansion
nnyf
ntf
n
hnyt
hnnn
Rfk
yffffhyy
112
'''!3!21
)(
)()()(32
nnytnnn hRffhafaahyy )())(( 112211
②
③
④③→①
Equating ② and ④
),(2
,2
,1 121221 nn ytfh
ah
aaa
Department of Computer Science and Engineering, Hanyang University
Modified Euler - revisitedModified Euler - revisited
)( 2121 kkyy hnn
),(1 nn ytfk ),( 12 hkyhtfk nn Modified Euler method
set
1111 ,,2
1hkha
2
12 a
Modified Euler method is a kind of 2nd-order Runge-Kutta method.
P1
P2
),(1 nn ytfk
),( 12 hkyhtfk nn
1ny
Department of Computer Science and Engineering, Hanyang University
Other 2nd order Runge-Kutta methodsOther 2nd order Runge-Kutta methods
Midpoint method
Ralston’s method
11121 2,
2,1,0 k
hhaa
))),(,(( 221 nnh
nh
nnn ytfytfhyy
)3( 2141 kkyy hnn
),(1 nn ytfk
),( 132
32
2 hkyhtfk nn
Department of Computer Science and Engineering, Hanyang University
Comparison: 2Comparison: 2ndnd order R-K method order R-K method
Department of Computer Science and Engineering, Hanyang University
Comparison: 2Comparison: 2ndnd order R-K method order R-K method
Eg. y’ =-2x3+12x2-20x+8.5, y(0)=1
Department of Computer Science and Engineering, Hanyang University
Fourth-order Runge-Kutta Taylor series expansion to 4-th order accurate short, straight, easy to use
),(
),(
),(
),(
})(2{
34
2223
1222
1
432161
1
hkyhtfk
kytfk
kytfk
ytfk
kkkkhyy
nn
hn
hn
hn
hn
nn
nn
)( 1Pf
nt 2h
nt htn
P1
P2
P3
P4
)( 3Pf
)( 2Pf
)( 1Pf
※ significant improvement over modified Euler’s method
4-th order Runge-Kutta methods4-th order Runge-Kutta methods
Department of Computer Science and Engineering, Hanyang University
Runge-Kutta methodRunge-Kutta method
Department of Computer Science and Engineering, Hanyang University
Eg. 4-th order R-K methodEg. 4-th order R-K method
Significant improvement
Department of Computer Science and Engineering, Hanyang University
DiscussionDiscussion
Better!
Department of Computer Science and Engineering, Hanyang University
ComparisonComparison
(5th order)