numerical analysis – differential...
TRANSCRIPT
Numerical Analysis –Differential Equation
Hanyang University
Jong-Il Park
Department of Computer Science and Engineering, Hanyang University
Differential Equation
P13 FIGURE 1.2
P700 FIGURE PT17.2
Department of Computer Science and Engineering, Hanyang University
Solving 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
Errors in Numerical Approach Discretization error
Stability error
y
t
Grid Points
Exact sol.
deD yye
ndS yye
sol. numerical:sol.ddiscretize:
sol.exact :
n
d
e
yyy
Department of Computer Science and Engineering, Hanyang University
Errors Total error
SD eee truncation round-off
De Se0 increase
as t 0 as t 0
trade-off
t
eDe
Se
Department of Computer Science and Engineering, Hanyang University
Local 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 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) stability
stable
unstable
y
t
Consistentstable
Converge
Department of Computer Science and Engineering, Hanyang University
Stability
Stability condition
0' )0(, yyAyy eg.
Exact sol.Euler method
Ateyy 0
01
1
)1(
)1(
yhA
yhAhAyyy
nn
nnn
For stability
AhhA 201|1|
Amplification factor
Department of Computer Science and Engineering, Hanyang University
nnnn
nnn
yhhyhyyhfyy
)1(2.1)2.1(1
1
hhy
yhyyhfyy
n
nnn
nnn
12.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 Method
Department of Computer Science and Engineering, Hanyang University
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: Concept
P702 FIGURE PT17.4P700 FIGURE PT17.3
Department of Computer Science and Engineering, Hanyang University
Initial value problem Initial Value Problem
Simultaneous D.E.
High-order D.E.
00' )(,),( ytyytf
dtdyy
00,21
1001,2111
)(),,,,(
)(),,,,(
nnnnn
n
ytyyyytfdtdy
ytyyyytfdtdy
)1(00
)1('00
'0
)(
)1(''')(
)(,,)(,
),,,,,(0
nnt
nn
ytyytyyy
yyyytfy
Department of Computer Science and Engineering, Hanyang University
Well-posed condition
problem value-initial Then the . allfor and b][a,in
for t continuous are , respect to with derivative partialfirst its , and f that Suppse
y
yf y
, with ,for , ay(a)btaf(t,y)y'
posed.- wellis problem theand ,for solution unique a has btay(t)
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
hhtt
ynhR n
n
n
00
)1(1
,)()!1(
Taylor series method(I)
Department of Computer Science and Engineering, Hanyang University
High order differentiation
Implementation
22
'''
''
2
)()(][
))](,([
fffffffff
fffy
fft
ffffffdtdy
fffdtdy
yf
tftytf
dtdy
yyytytytt
yytyttyt
yt
<Type 1>
Complicated computation
0t'0y''
0y'''
0y
hhh
y
t
Less computationaccuracy
<Type 2>
h h h
0t 1t 2t 3t'0y''
0y'''
0y
'1y''
1y'''
1y
'2y''
2y'''
2y....
y
t
More computationaccuracy
Requiring complicatedsource codes
Taylor series method(II)
Department of Computer Science and Engineering, Hanyang University
Euler method(I) Euler Method
0t
....
y
t1t 2t 3t ....
0y 0y1y 2y
3y
h
00' )(),,( ytyytfy
Talyor series expansion at to
1002
0''
!21'
001 ,)( tthyhyyy
0
00 ),(f
ytf
P707 FIGURE 25.1
Department of Computer Science and Engineering, Hanyang University
Euler method(II)
Error
Eg. y’ =-2x3+12x2-20x+8.5, y(0)=1
P702 FIGURE PT7.4
P708 FIGURE 25.2
Department of Computer Science and Engineering, Hanyang University
Euler method(III)
12
2''!2
11
,)(
)(
nnnnn
nnnn
tthOhfy
hyhfyy
1
010112010 )()()()(
n
iiinnn yyyyyyyyyyy
)()()(21
)(21
)(
_''
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
httn
ttyy
n
n
n
iin
0
0
1
0
''1'' ,)()(
; 1st order
Department of Computer Science and Engineering, Hanyang University
Eg. Euler method
.5.0)0(with ,20for ,12` yttyywith h=0.2, N=10, and ti=0.2i.
Suppose that Euler`s method is used to approximate the solution to the initial-valueproblem
have we0.5,y(0) wand 1t-yy)f(t, Since 02
2.0008.00088.02.1]104.0[2.0)1( 21
221 iiwiwwtwhww iiiiii
Department of Computer Science and Engineering, Hanyang University
Modified Euler method: Heun’s method Modified Euler’s Method
Why a modification?
errormodify
nt nt 1nt
Cny 1
Pny 1
Pnf 1
nf2
1P
nn ff
1nt
Predictor
Average slope
Corrector
nnPn hfyy 1
2),(),(
211
'1
''
Pnnnnnn ytfytfyyy
)],(),([2 11
'1 nnnnnn
Cn ytfytfhyyhyy
Department of Computer Science and Engineering, Hanyang University
Heun’s method with iteration
Iteration
significant improvement
P720 FIGURE 25.9
Department of Computer Science and Engineering, Hanyang University
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 Euler EulerModified
Euler Method
improvement
.5.0)0(with ,20for ,12` yttyywith h=0.2, N=10, and ti=0.2i, and w0=0.5 in each case. The difference equations produced from the various formulas are
Suppose we apply the Runge-Kutta methods of order 1 to our usual example.
Department of Computer Science and Engineering, Hanyang University
Runge-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
ytfkytfk
kakaka
Department of Computer Science and Engineering, Hanyang University
Second-order Runge-Kutta method Second-order Runge-Kutta method
),(),(
)(
112
1
22111
nn
nn
nn
ytfkytfk
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 ytfhahaaa
Department of Computer Science and Engineering, Hanyang University
Modified Euler - revisited
)( 2121 kkyy hnn
),(1 nn ytfk ),( 12 hkyhtfk nn Modified Euler method
set
1111 ,,21 hkha
21
2 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 methods Midpoint method
Ralston’s method
11121 2,
2,1,0 khhaa
))),(,(( 221 nnh
nh
nnn ytfytfhyy
)3( 2141 kkyy hnn
),(1 nn ytfk
),( 132
32
2 hkyhtfk nn
P725 FIGURE 25.12
Department of Computer Science and Engineering, Hanyang University
Comparison: 2nd order R-K method
.5.0)0(with ,20for ,12` yttyyThe Runge-Kutta method of order 4 applied to the initial-value problem
with h=0.2, N=10, and ti=0.2i, and w0=0.5 in each case. The difference equationsproduced from the various formulas are
Midpoint method: Modified Euler method:
Heun`s method: 2173.0008.00088.022.1
216.0008.00088.022.1
218.0008.00088.022.1
211
211
211
iiww
iiww
iiww
ii
ii
ii
for each i=0,1...9.Table 5.5 on page 196 lists the results of these calculations.
Department of Computer Science and Engineering, Hanyang University
Comparison: 2nd order R-K methodEg. y’ =-2x3+12x2-20x+8.5, y(0)=1
P731 FIGURE 25.14
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
hkyhtfkkytfkkytfk
ytfkkkkkhyy
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 methods
Department of Computer Science and Engineering, Hanyang University
Runge-Kutta method
P733 FIGURE 25.15
Department of Computer Science and Engineering, Hanyang University
Eg. 4-th order R-K method
Significant improvement
.5.0)0(with ,20for ,12` yttyy
The Runge-Kutta method of order 4 applied to the initial-value problem
with h=0.2, N=10, and ti=0.2i, gives the results and errors listed in Table 5.6
Department of Computer Science and Engineering, Hanyang University
Discussion
Better!
For the problem
.5.0)0(with ,20for ,12` yytyyEuler` method with h=0.025, the Modified Euler`s method with h=0.05, and the Runge-Kutta method of order 4 with h=0.1 are compared at the common mesh points of the three methods, 0.1,0.2,0.2,0.4 and 0.5. Each of these techniques requires 20 functional evaluations to approximate y(0.5). In this example, the fourth-order method is clearly superior, as it is in most situations.
Department of Computer Science and Engineering, Hanyang University
Comparison
P736 FIGURE 25.16