Академический Документы
Профессиональный Документы
Культура Документы
Differential Equation
Hanyang University
Jong-Il Park
Department of Computer Science and Engineering, Hanyang University
Differential Equation
Department of Computer Science and Engineering, Hanyang University
Solving Differential Equation
Differential Equation
Ordinary D.E.
Partial D.E.
Ordinary D.E.
Linear eg.
Nonlinear eg.
Initial value problem
Boundary value problem
) (
' '
t f y y = +
) (
' ' '
t f y y y = +
Usually no closed-form solution
linearization
numerical solution
0 ) 0 ( ) 0 ( , 0 .
' ' '
= = = + y y y y eg
3 ) 1 ( , 0 ) 0 ( , 10 5 4 .
' ' '
= = = + + y y y y y eg
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.
d e D
y y e =
n d S
y y e =
sol. numerical :
sol. d discretize :
sol. exact :
n
d
e
y
y
y
Department of Computer Science and Engineering, Hanyang University
Errors
Total error
S D
e e e + =
truncation round-off
D
e
S
e
0 increase
as t A 0
as t A 0
trade-off
t A
e
D
e
S
e
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
0 0 ) ( = A
D
e h t
5 5
2 2
) (
) (
h e h O
h e h O
D
D
0 h
e
y
y
t
Department of Computer Science and Engineering, Hanyang University
Useful concepts(II)
stability
stable
unstable
y
t
Consistent
stable
Converge
Department of Computer Science and Engineering, Hanyang University
Stability
Stability condition
0
'
) 0 ( , y y Ay y = =
eg.
Exact sol.
Euler method
At
e y y
=
0
0
1
1
) 1 (
) 1 (
y hA
y hA
hAy y y
n
n
n n n
+
=
=
=
=
For stability
A
h hA
2
0 1 | 1 | s < s
Amplification factor
Department of Computer Science and Engineering, Hanyang University
n n n n
n n n
y h h y h y y
hf y y
) 1 ( 2 . 1 ) 2 . 1 (
1
1
= + =
+ =
+
+
h
h y
y h y y
hf y y
n
n n n
n n n
+
+
=
+ =
+ =
+ +
+ +
1
2 . 1
) 2 . 1 (
1 1
1 1
Explicit :
Implicit :
h increase
h large
h small
ye
y
t
y
t
explicit implicit
conditionally stable stable
y y y y y = = = + 2 . 1 2 . 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.
) ( .
'
t g Ay y eg = +
Diff.
eq.
Modified
D.E.
Discretization
Discretization by Euler method
) (
1 n n n n
Ay g h y y + =
+
<Consistency check>
= +
+ = + + +
+ + + =
+
' '
! 2
1
'
' ' 2
! 2
1
'
' ' 2
! 2
1
'
1
|
) ( | |
| |
hy g Ay y
Ay g h y y h hy y
y h hy y y
n n n
n n n n n n
n n n n
0 Let h
n n n
g Ay y = + |
' consistent ;
<Order>
) ( |
'
h O g Ay y
n n n
+ = +
Department of Computer Science and Engineering, Hanyang University
Initial Value Problem: Concept
Department of Computer Science and Engineering, Hanyang University
Initial value problem
Initial Value Problem
Simultaneous D.E.
High-order D.E.
0 0
'
) ( , ) , ( y t y y t f
dt
dy
y = = =
0 0 , 2 1
10 0 1 , 2 1 1
1
) ( ), , , , (
) ( ), , , , (
n n n n
n
n
y t y y y y t f
dt
dy
y t y y y y t f
dt
dy
= =
= =
) 1 (
0 0
) 1 ( '
0 0
'
0
) (
) 1 ( ' ' ' ) (
) ( , , ) ( ,
) , , , , , (
0
= = =
=
n n t
n n
y t y y t y y y
y y y y t f y
Department of Computer Science and Engineering, Hanyang University
Well-posed condition
Department of Computer Science and Engineering, Hanyang University
Taylor Series Method
) , (
'
y t f y =
n
n n
n
R h y h y h y y h t y + + + + + = +
) (
0 !
1
2 ' '
0 ! 2
1
'
0 0 0
) (
Truncation error
) (
0
h t y +
) (
0
t y
0
t h t +
0
h
h t t
y
n
h
R
n
n
n
+ s s
+
=
+
+
0 0
) 1 (
1
, ) (
)! 1 (
2 2
' ' '
' '
2
) ( ) ( ] [
))] ( , ( [
f f f f f f f f f
f f f
y
f f
t
f f f f f f
dt
d
y
f f f
dt
dy
y
f
t
f
t y t f
dt
d
y
yy y t y ty tt
y y ty tt y t
y t
+ + + + =
c
c
+
c
c
+ + = + =
+ =
c
c
+
c
c
= =
<Type 1>
Complicated computation
0
t
'
0
y
' '
0
y
' ' '
0
y
h
h
h
y
t
Less computation
accuracy
<Type 2>
h h h
0
t
1
t
2
t
3
t
'
0
y
' '
0
y
' ' '
0
y
'
1
y
' '
1
y
' ' '
1
y
'
2
y
' '
2
y
' ' '
2
y
....
y
t
More computation
accuracy
Requiring complicated
source codes
Taylor series method(II)
Department of Computer Science and Engineering, Hanyang University
Euler method(I)
Euler Method
0
t
....
y
t
1
t
2
t
3
t
....
0
y
0
y
1
y
2
y
3
y
h
0 0
'
) ( ), , ( y t y y t f y = =
Talyor series expansion at t
o
1 0 0
2
0
' '
! 2
1
'
0 0 1
, ) ( t t h y h y y y s s + + =
0
0 0
) , (
f
y t f
=
Department of Computer Science and Engineering, Hanyang University
Euler method(II)
Error
Eg. y =-2x
3
+12x
2
-20x+8.5, y(0)=1
Department of Computer Science and Engineering, Hanyang University
Euler method(III)
1
2
2 ' '
! 2
1
1
, ) (
) (
+
+
s s + + =
+ + =
n n n n n
n n n n
t t h O h f y
h y h f y y
=
+
+ = + + + + =
1
0
1 0 1 1 2 0 1 0
) ( ) ( ) ( ) (
n
i
i i n n n
y y y y y y y y y y y
) ( ) ( ) (
2
1
) (
2
1
) (
_
' '
0
2
_
' '
0
2 ' '
1
0
2
1
h O h y t t
h y
h
t t
h y e
n
n
i
n
i
t
= =
=
=
=
s s =
=
; 1
st
order
Department of Computer Science and Engineering, Hanyang University
Eg. Euler method
Department of Computer Science and Engineering, Hanyang University
Modified Euler method: Heuns method
Modified Eulers Method
Why a modification?
error
modify
n
t
n
t
1 + n
t
C
n
y
1 +
P
n
y
1 +
P
n
f
1 +
n
f
2
1
P
n n
f f
+
+
1 + n
t
Predictor
Average slope
Corrector
n n
P
n
hf y y + =
+1
2
) , ( ) , (
2
1 1
'
1
'
'
P
n n n n n n
y t f y t f y y
y
+ + +
+
=
+
=
)] , ( ) , ( [
2
1 1
'
1 + + +
+ + = + =
n n n n n n
C
n
y t f y t f
h
y y h y y
Department of Computer Science and Engineering, Hanyang University
Heuns method with iteration
Iteration
significant
improvement
Department of Computer Science and Engineering, Hanyang University
Error analysis
Error Analysis
Taylor series
Total error
) ( ] [
) ( ) (
) (
3 '
1
'
2
' ' ' 3
! 3
1
' '
1
2
2
1
'
' ' ' 3
! 3
1
' ' 2
2
1
'
1
h O y y y
y h h O
h
y y
h hy y
y h y h hy y y
n n
h
n
n n
n n
n n n n
+ + + =
+
)
`
+ + =
+ + + =
+
+
+
truncation
3
rd
order
) (
2
h O
; 2
nd
order method
Significant improvement over Eulers method!
Department of Computer Science and Engineering, Hanyang University
Eg. Euler vs. Modified Euler
e Euler Modified
Euler Method
improvement
Department of Computer Science and Engineering, Hanyang University
Runge-Kutta method
Runge-Kutta Method
Simple computation
very accurate
The idea
code source Easy . , , no
' ' '
y y
) , , (
1
h y t h y y
n n n n
| + =
+
where
) , (
) , (
) , (
1 1
1 1 2
1
2 2 1 1
+ + =
+ + =
=
+ + + =
n n n n n
n n
n n
n n
y t f k
y t f k
y t f k
k a k a k a
| o
| o
|
Department of Computer Science and Engineering, Hanyang University
Second-order Runge-Kutta method
Second-order Runge-Kutta method
) , (
) , (
) (
1 1 2
1
2 2 1 1 1
| o + + =
=
+ + =
+
n n
n n
n n
y t f k
y t f k
k a k a h y y
Taylor series expansion
( ) ( )
n
n
y
f
n
t
f
n
h
n y t
h
n n n
R f k
y f f f f h y y
+ + + =
+ + + + =
c
c
c
c
+
1 1 2
' ' '
! 3 ! 2 1
) (
) ( ) ( ) (
3 2
| o
n n y t n n n
hR f f ha f a a h y y + + + + + =
+
) ( ) )( (
1 1 2 2 1 1
| o
Equating and
) , (
2
,
2
, 1
1 2 1 2 2 1 n n
y t f
h
a
h
a a a = = = + | o
Department of Computer Science and Engineering, Hanyang University
Modified Euler - revisited
) (
2 1 2 1
k k y y
h
n n
+ + =
+
) , (
1 n n
y t f k =
) , (
1 2
hk y h t f k
n n
+ + =
Modified Euler method
set
1 1 1 1
, ,
2
1
hk h a = = = | o
2
1
2
= a
Modified Euler method is a kind
of 2
nd
-order Runge-Kutta method.
P1
P2
) , (
1 n n
y t f k =
) , (
1 2
hk y h t f k
n n
+ + =
1 + n
y
Department of Computer Science and Engineering, Hanyang University
Other 2nd order Runge-Kutta methods
Midpoint method
Ralstons method
1 1 1 2 1
2
,
2
, 1 , 0 k
h h
a a = = = = | o
))) , ( , ( (
2 2 1 n n
h
n
h
n n n
y t f y t f h y y + + + =
+
) 3 (
2 1
4
1
k k y y
h
n n
+ + =
+
) , (
1 n n
y t f k =
) , (
1
3
2
3
2
2
hk y h t f k
n n
+ + =
Department of Computer Science and Engineering, Hanyang University
Comparison: 2
nd
order R-K method
Department of Computer Science and Engineering, Hanyang University
Comparison: 2
nd
order R-K method
Eg. y =-2x
3
+12x
2
-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 {
3 4
2 2 2 3
1 2 2 2
1
4 3 2 1 6
1
1
hk y h t f k
k y t f k
k y t f k
y t f k
k k k k h y y
n n
h
n
h
n
h
n
h
n
n n
n n
+ + =
+ + =
+ + =
=
+ + + + =
+
) (
1
P f
n
t
2
h
n
t + h t
n
+
P1
P2
P3
P4
) (
3
P f
) (
2
P f
) (
1
P f
significant improvement over
modified Eulers method
4-th order Runge-Kutta methods
Department of Computer Science and Engineering, Hanyang University
Runge-Kutta method
Department of Computer Science and Engineering, Hanyang University
Eg. 4-th order R-K method
Significant
improvement
Department of Computer Science and Engineering, Hanyang University
Discussion
Better!
Department of Computer Science and Engineering, Hanyang University
Comparison
(5
th
order)