Académique Documents
Professionnel Documents
Culture Documents
dy
dy
= y' ( x ) = f ( x , y ) as well as
= y' ( t ) = f ( t , y )
dx
dt
(9-1)
yn +1 = yn + dx y '( x ) = yn + h. f ( x, y )
(9-2)
Eq. (9-2) was considered to be the first order Runge-Kutta. Solution can be obtained
only if the boundary condition (for x) or the initial condition (for t) is given. The
increment of x (i.e. x = h) or the increment of time or time step (i.e. t = h) can be
set based on the nature of the problem, wheter it includes higher accuracy or not.
(9-3)
where :
k1 = hf (xn, yn)
k2 = hf (xn+ h, yn+ k1)
k2 = hf (xn+h, yn+ k1)
h = xn+1 - xn
For equation :
y = f(x, y)
, y(xo) = yo
a=b=
, ==1
Calculate yn up to y(xo+nh) for constant h and n = 0, 1, 2, using following
equations :
yn+1 = yn + (k1 + k2) with
k1
= hf (xn, yn)
k2
= hf (xn+h, yn+k1)
9-1
For equation :
y = f(x, y)
, y(xo) = yo
Calculate yn up to y(xo+nh) for constant h and n = 0, 1, 2, using following
equations :
yn+1 = yn + 1/6 (k1 + 2k2 + 2k3 + k4) with :
(9-4)
k1 = hf (xn, yn)
k2 = hf (xn+ h, yn+ k1)
k3 = hf (xn+ h, yn+ k2)
k4 = hf (xn+h, yn+k3)
Give
1
and y(0) = 1
y
: solution within interval x = 0 to x = 1 with h = 0.1
: y' = f ( x , y ) = x
Solution was given in the Table 9-1 and correspondingly depicted by Figure 9.1.
Table 9-1: Solution of example 1
yn
k1
k2
yn+1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1
0.8944
0.7855
0.6681
0.5321
0.3479
-0.1983
-0.0229
2.2201
2.2554
2.3015
-0.1000
-0.1018
-0.1073
-0.1197
-0.1479
-0.2374
0.5642
4.4387
0.0350
0.0457
0.0566
-0.1111
-0.1162
-0.1275
-0.1524
-0.2203
-0.8551
-0.2133
0.0474
0.0357
0.0465
0.0576
-0.1056
-0.1090
-0.1174
-0.1360
-0.1841
-0.5462
0.1754
2.2430
0.0353
0.0461
0.0571
0.8944
0.7855
0.6681
0.5321
0.3479
-0.1983
-0.0229
2.2201
2.2554
2.3015
2.3586
9-2
Lecture Note - Dr.Ir. Lilik Eko Widodo, MS
2.5
yn
1.5
0.5
-0.5
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
xn
h
f ( x n , y n ) + f ( x n +1 , y n +1 )
2
n = 1, 2 , ......
(9-5)
x : independent variable
y : dependent variable
h : xn+1 - xn
Eq. (9-5) is the implicit form for yn+1, since yn+1 appears to be an argument at right
hand side. If f(x,y) is non-linear, then eq. (9-5) can not be closely solved.
Accordingly, yn+1 will be iteratively solved. By introducing the value of xn, the first
estimated value y n(0+)1 on y n + 1 will be obtained based on the first order Runge-Kutta
method as :
y n(0+)1 = y n + hf ( xn , y n )
(9-6)
y n(1+)1 = y n +
h
f ( xn , y n ) + f ( xn + 1 , y n(0+)1 )
2
(9-7)
h
f ( xn , y n ) + f ( xn + 1 , y n(k+11) )
2
k = 1, 2 , ......
(9-8)
The iteration can only be stoped if the level of accuracy has already been achieved.
Step 1 :
Step 2 :
<
Eq. (9-6) is explicit that is called as the the predictor, whereas eq. (9-5) is implicit
and called as the the corrector. If both of them is simultaneously used, then the
corresponding method can be called as the predictor-corrector. The result from the
correction equation of step will always be more accurate than the prediction.
1
and y(0) = 1
y
: solution within interval from x = 0 to x = 0.2 with h = 0.1
: y'''(0) -2, then the error = -(h3/12)y''' 0.0002
: y' = f ( x , y ) = x
9-4
Lecture Note - Dr.Ir. Lilik Eko Widodo, MS
Step 1 :
Step 2 :
from eq. (9-8) will be resulted in y1(1) = 0.8994 and y1(2 ) = 0.8994
Since the value of y1(1) = y1(2 ) = 0.8994 , then the inner iteration was
stoped and results in the value of y1 = 0.8994 that can be used to
compute its derivate as follows :
y 1' = f (x1 , y 1 ) = x1
1
= 1.0118
y1
on x1 = x0 +nh = 0.1
Step 1 :
Step 2:
y (3 ) = 0.7960
2
Since y 2(2 ) = y 2(3 ) = 0.7960 , then the iteration was stoped and the value
of y2 = 0.7960 can be used to calculate its derivate, i.e :
y '2 = f ( x 2 , y 2 ) = x 2
1
= 1.0562
y2
on x2 = x0 + nh = 0.2
(9-9)
f and g are function of t, x and y that is usually given. It can subsequently be defined
as follows :
h
= t n +1 t n
x n = x( t n )
(9-10)
y n = y( t n )
9-5
Lecture Note - Dr.Ir. Lilik Eko Widodo, MS
k 1 = h f (t n , x n , y n )
l 1 = h g (t n , x n , y n )
(9-11)
k
l
h
k 2 = h f t n + , x n + 1 , y n + 1
2
2
2
k
l
h
l 2 = h g t n + , x n + 1 , y n + 1
2
2
2
(9-12)
k
l
h
k 3 = h f t n + , xn + 2 , y n + 2
2
2
2
k
l
h
l3 = h g t n + , xn + 2 , y n + 2
2
2
2
(9-13)
k 4 = h f (t n + h , x n + k 3 , y n + l 3 )
l 4 = h g (t n + h , x n + k 3 , y n + l 3 )
(9-14)
x n +1 = x n +
y n +1
(9-15)
(9-16)
(9-17)
9-6
Lecture Note - Dr.Ir. Lilik Eko Widodo, MS
x ' = f (t , x , y ) = y
(9-18)
l 1 = 0 .1 x (0 .5 x 1 2 x 0 x 0 ) = 0 .05
0 .05
k 2 = 0 .1 x 0 +
= 0 .0025
2
0
0 .1
0 .05
l 2 = 0 .1 x 0 .5 1 + 2 0 +
x 0 +
= 0 .04975
2
2
2
0 .04975
k 3 = 0 .1 x 0 +
= 0 .002488
2
0 .0025
0 .1
0 .04975
l 3 = 0 .1 x 0 .5 1 +
2 0 +
x 0 +
= 0 .049814
2
2
2
k 4 = 0 .1 x (0 + 0 .049814 ) = 0 .004981
l 4 = 0 .1 x [0 .5(1 + 0 .002488 ) 2(0 + 0 .1) x (0 + 0 .049814 )] = 0 .049128
x1 = 1 +
The next result up to the fifth iteration was given in the following Table.
Tabel 9-2: Iteration Result
n = Iterasi
tn
xn
yn
k1
l1
k2
l2
k3
l3
k4
l4
xn + 1 = C
yn + 1 = C
0
1
0
0
0.0500
0.0025
0.0498
0.0025
0.0498
0.0050
0.0491
1.0025
0.0497
0.1
1.0025
0.0497
0.0050
0.0491
0.0074
0.0480
0.0074
0.0481
0.0098
0.0466
1.0099
0.0977
0.2
1.0099
0.0977
0.0098
0.0466
0.0121
0.0447
0.0120
0.0448
0.0142
0.0425
1.0219
0.1424
0.3
1.0219
0.1424
0.0142
0.0426
0.0164
0.0400
0.0162
0.0401
0.0183
0.0373
1.0382
0.1824
0.4
1.0382
0.1824
0.0182
0.0373
0.0201
0.0343
0.0200
0.0345
0.0217
0.0312
1.0582
0.2167
0.5
1.0582
0.2167
0.0217
0.0312
0.0232
0.0279
0.0231
0.0281
0.0245
0.0247
1.0813
0.2447
9-7
Lecture Note - Dr.Ir. Lilik Eko Widodo, MS
9-8
Lecture Note - Dr.Ir. Lilik Eko Widodo, MS