Upload
trankien
View
227
Download
0
Embed Size (px)
Citation preview
PERSAMAAN DIFERENSIAL
(DIFFERENTIAL EQUATION)
M E T O D E E U L E R
M E T O D E R U N G E - K U T T A
PERSAMAAN DIFERENSIAL
• Persamaan paling penting dalam bidang rekayasa,
paling bisa menjelaskan apa yang terjadi dalam
sistem fisik.
• Menghitung jarak terhadap waktu dengan
kecepatan tertentu, 50 misalnya.
50dt
dx
Rate equations
PERSAMAAN DIFERENSIAL
• Solusinya, secara analitik dengan integral,
• C adalah konstanta integrasi
• Artinya, solusi analitis tersebut terdiri dari banyak
‘alternatif’
• C hanya bisa dicari jika mengetahui nilai x dan t.
Sehingga, untuk contoh di atas, jika x(0) = (x saat
t=0) = 0, maka C = 0
dtdx 50 Ctx 50
KLASIFIKASI PERSAMAAN DIFERENSIAL
Persamaan yang mengandung turunan dari satu
atau lebih variabel tak bebas, terhadap satu atau
lebih variabel bebas.
• Dibedakan menurut:
• Tipe (ordiner/biasa atau parsial)
• Orde (ditentukan oleh turunan tertinggi yang ada)
• Liniarity (linier atau non-linier)
SOLUSI PERSAMAAN DIFERENSIAL
• Secara analitik, mencari solusi persamaan
diferensial adalah dengan mencari fungsi integral
nya.
• Contoh, untuk fungsi pertumbuhan secara
eksponensial, persamaan umum:
kPdt
dP
Rate equations
But what you really want to know is…
the sizes of the boxes (or state variables) and how they change through time
That is, you want to know:
the state equations
There are two basic ways of finding the state equations for the state variables based on your known rate equations:
1) Analytical integration
2) Numerical integration
Suatu kultur bakteria tumbuh dengan kecepatan
yang proporsional dengan jumlah bakteria yang
ada pada setiap waktu. Diketahui bahwa jumlah
bakteri bertambah menjadi dua kali lipat setiap 5
jam. Jika kultur tersebut berjumlah satu unit pada
saat t = 0, berapa kira-kira jumlah bakteri setelah
satu jam?
• Jumlah bakteri menjadi dua kali lipat setiap 5 jam, maka k = (ln 2)/5
• Jika P0 = 1 unit, maka setelah satu jam…
SOLUSI PERSAMAAN DIFERENSIAL
kPdt
dP
dtkP
dPt
t
P
P
1
0
1
0
)(ln 0
0
ttCkP
P
ktePtP 0)(
)(1)1()1)(
5)2(ln
(eP
1487.1
Rate equation State equation (dsolve in Maple)
The Analytical Solution of the Rate
Equation is the State Equation
THERE ARE VERY FEW MODELS IN ECOLOGY THAT CAN BE SOLVED
ANALYTICALLY.
SOLUSI NUMERIK
• Numerical integration
• Eulers
• Runge-Kutta
Numerical integration makes use of this relationship:
Which you’ve seen before…
Relationship between continuous and discrete time models
*You used this relationship in Lab 1 to program the
logistic rate equation in Visual Basic:
1 where,11
tt
K
NrNNN t
ttt
tdt
dyyy ttt
, known
Fundamental Approach of Numerical Integration
y = f(t), unknown
t, specified
y
t
yt, known
dt
dy
yt+t, estimated
tdt
dyyy ttt
yt+t,
unknown
Euler’s Method: yt+ t ≈ yt + dy/dt t
1 where,1
tt
K
NrNNN t
tttt
dtdN
Calculate dN/dt*1
at Nt
Add it to Nt to
estimate Nt+ t
Nt+ t becomes the new Nt
Calculte dN/dt * 1 at new Nt
Use dN/dt to estimate next Nt+ t
Repeat these steps to estimate the state
function over your desired time length
(here 30 years)
Nt/K with time, lambda = 1.7, time step = 1
0
0.05
0.1
0.15
0.2
0.25
0.3
0.35
0.4
0.45
0 10 20 30 40 50
time (years)
Nt/K
EXAMPLE OF NUMERICAL INTEGRATION
dy
dty y 6 007 2.
Analytical solution to dy/dt
Y0 = 10
t = 0.5
point to
estimate
y
Euler’s Method: yt+ t ≈ yt + dy/dt t
yt = 10
m1 = dy/dt at yt
m1 = 6*10-.007*(10)2
y = m1*t
yest= yt + y
t = 0.5
y
estimated y(t+ t)
analytical y(t+ t)
dy
dty y 6 007 2.
20
RUNGE-KUTTA
METHODS
MOTIVATION
• We seek accurate methods to solve ODEs that do
not require calculating high order derivatives.
• The approach is to use a formula involving
unknown coefficients then determine these
coefficients to match as many terms of the Taylor
series expansion.
21
SECOND ORDER RUNGE-KUTTA METHOD
22
possible. as accurate as is that such
,,,
:Problem
) ,(
),(
1
21
22111
12
1
i
ii
ii
ii
y
wwFind
KwKwyy
KyhxfhK
yxfhK
TAYLOR SERIES IN ONE VARIABLE
23
hxandxbetweenisxwhere
xfn
hxf
i
hhxf
f(x)n
nn
i
n
i
i
)()!1(
)(!
)(
of expansion SeriesTaylor order The
)1(1
)(
0
th
Approximation Error
DERIVATION OF 2ND ORDER RUNGE-KUTTA METHODS – 1 OF 5
24
)(),('2
),(
:as writtenis which
)(2
),( :ODE solve toUsed
ExpansionSeriesTaylor Order Second
32
1
3
2
22
1
hOyxfh
yxfhyy
hOdx
ydh
dx
dyhyy
yxfdx
dy
iiiiii
ii
DERIVATION OF 2ND ORDER RUNGE-KUTTA METHODS – 2 OF 5
25
)(2
),(),(
:
),(),(),(
),('
ationdifferenti rule-chainby obtained is ),(' where
32
1 hOh
yxfy
f
x
fhyxfyy
ngSubstituti
yxfy
f
x
f
dx
dy
y
yxf
x
yxfyxf
yxf
iiiiii
TAYLOR SERIES IN TWO VARIABLES
26
),( and ),( between joining line theon is),(
),()!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
DERIVATION OF 2ND ORDER RUNGE-KUTTA METHODS – 3 OF 5
27
) ,(),(
:ngSubstituti
) ,(
),(
thatsuch ,,,:Problem
1211
22111
12
1
21
Kyhxfhwyxfhwyy
KwKwyy
KyhxfhK
yxfhK
wwFind
iiiiii
ii
ii
ii
DERIVATION OF 2ND ORDER RUNGE-KUTTA METHODS – 4 OF 5
28
...),( ),( )(
... ),( )(
...),( ),(
:
...),() ,(
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
DERIVATION OF 2ND ORDER RUNGE-KUTTA METHODS – 5 OF 5
29
2
1 ,1 :solution possible One
solutions infinite unknowns 4 withequations 3
2
1 and ,
2
1 , 1
:equations threefollowing theobtain we terms,Matching
)(2
),(),(
...),( ),( )(
:for expansions twoderived We
21
2221
32
1
22
22211
1
ww
wwww
hOh
yxfy
f
x
fhyxfyy
yxfy
fhw
x
fhwyxfhwwyy
y
iiiiii
iiiiii
i
2ND ORDER RUNGE-KUTTA METHODS
30
2
1 and ,
2
1 ,1
: thatsuch ,,, Choose
) ,(
),(
2221
21
22111
12
1
wwww
ww
KwKwyy
KyhxfhK
yxfhK
ii
ii
ii
ALTERNATIVE FORM
22111
12
1
) , (
),(
KuttaeOrder Rung Second
KwKwyy
KyhxfhK
yxfhK
ii
ii
ii
31
22111
12
1
) , (
),(
FormeAlternativ
kwkwhyy
khyhxfk
yxfk
ii
ii
ii
CHOOSING , , W1 AND W2
32
Corrector Singlea with' is This
),(),(22
1
),(
),(
:becomes methodKutta -eOrder Rung Second
2
1 ,1 then,1 choosing example,For
011211
12
1
21
s Method Heun
yxfyxfh
yKKyy
KyhxfhK
yxfhK
ww
iiiiiii
ii
ii
CHOOSING , , W1 AND W2
33
Method Midpoint theis This
)2
,2
(
)2
,2
(
),(
:becomes methodKutta -eOrder Rung Second
1 ,0 ,2
1 then
2
1 Choosing
121
12
1
21
Ky
hxfhyKyy
Ky
hxfhK
yxfhK
ww
iiiii
ii
ii
2ND ORDER RUNGE-KUTTA METHODS ALTERNATIVE FORMULAS
34
211
1i2
1
2
1
2
11
) ,(
),(
)0(select mulas Kutta ForeOrder Rung Second
KKyy
KyhxfhK
yxfhK
ii
i
ii
2
11 ,
2
1, :number nonzeroany Pick
1 ,2
1,
2
1
12
2122
ww
wwww
SECOND ORDER RUNGE-KUTTA METHOD
EXAMPLE
CISE301_Topic8L4&5
35
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) find tosystem following theSolve
21
30
20
1002
30
20001
32
KKxx
tx
KxhtfhK
txxtfhK
hxtxtx
x
SECOND ORDER RUNGE-KUTTA METHOD
EXAMPLE
36
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(
2 STEP
21
31
21
1112
31
21111
KKxx
tx
KxhtfhK
txxtfhK
1 RK2,Using
[1,2]for t Solution
,4)1(,)(1)( 32
xttxtx
37
2ND ORDER RUNGE-KUTTA
)( iserror global and )( iserror Local
2
) ,(
),(
corrector singlea withmethod s Heun' toEquivalent
RK2as Know 1, of valueTypical
23
211
12
1
hOhO
kkh
yy
hkyhxfk
yxfk
ii
ii
ii
38
RK2
HIGHER-ORDER RUNGE-KUTTA
39
Higher order Runge-Kutta methods are available. Derived similar to second-order Runge-Kutta. Higher order methods are more accurate but require more calculations.
3RD ORDER RUNGE-KUTTA
40
RK3
)( iserror Global and )( iserror Local
46
)2 ,(
)2
1 ,
2(
),(
RK3asKnow
34
3211
213
12
1
hOhO
kkkh
yy
hkhkyhxfk
hkyh
xfk
yxfk
ii
ii
ii
ii
4TH ORDER RUNGE-KUTTA
41
RK4
)( iserror global and )( iserror Local
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
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
42
EXAMPLE 4TH-ORDER RUNGE-KUTTA METHOD
43
)4.0()2.0(4
2.0
5.0)0(
1 2
yandycomputetoRKUse
h
y
xydx
dy
RK4
EXAMPLE: RK4
)4.0(),2.0(4
5.0)0(,1
:Problem
2
yyfindtoRKUse
yxydx
dy
44
4TH ORDER RUNGE-KUTTA
45
RK4
)( iserror global and )( iserror Local
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
EXAMPLE: RK4
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
:Problem
2
yyfindtoRKUse
yxydx
dy
5.0,0
1),(
0.2
00
2
yx
xyyxf
h
46
See RK4 Formula
Ste
p 1
EXAMPLE: RK4
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
:Problem
2
yyfindtoRKUse
yxydx
dy
8293.0,2.0
1),(
0.2
11
2
yx
xyyxf
h
47
Ste
p 2
EXAMPLE: RK4
)4.0(),2.0(4
5.0)0(,1
:Problem
2
yyfindtoRKUse
yxydx
dy
xi yi
0.0 0.5
0.2 0.8293
0.4 1.2141
48
Summary of the solution
SUMMARY
• Runge Kutta methods generate an accurate
solution without the need to calculate high order
derivatives.
• Second order RK have local truncation error of
order O(h3) and global truncation error of order
O(h2).
• Higher order RK have better local and global
truncation errors.
• N function evaluations are needed in the Nth order
RK method.
49