1. Numerical solution of ordinary and
partial dierential Equations
Module 9: Runge-Kutta methods - IV
Dr.rer.nat. Narni Nageswara Rao
£
August 2011
1 System of Equations
Consider the system of n equations
dy
dt
= f(t; y1; y2; ¡¡¡ ; yn)
y(t0) = (1)
where
y = [y1; y2; ¡¡¡ ; yn]T
; f = [f1; f2; ¡¡¡ ; fn]T
; = [1; 2; ¡¡¡ ; n]T
All the methods derived earlier can be used to solve the system of equations
(1), by writing the methods in vector form. Let us now apply some of these
methods to solve (1).
1.1 Taylor Series Method
We can write the Taylor series expansion in vector form as
yj+1 = yj + hyH
j +
h2
2!
yHH
j + ¡¡¡+
hp
p!
y(p)
j ; j = 0; 1; 2; ¡¡¡ ; N 1 (2)
where
y(k)
j =
2
6664
(y
(k)
1 )j
(y
(k)
2 )j
...
(y
(k)
n )j
3
7775 =
2
64
dk 1
dtk 1 [f1(t; y1; y2; ¡¡¡ ; yn)]j
...
dk 1
dtk 1 [fn(t; y1; y2; ¡¡¡ ; yn)]j
3
75
£nnrao maths@yahoo.co.in
1
2. 1.2 Runge-Kutta method of Second order
Consider the Euler-Cauchy or the Heun method. We write it in vector form
as
yj+1 = yj +
1
2
(K1 + K2) (3)
where
Ki1 = hfi(tj; (y1)j; (y2)j; ¡¡¡ ; (yn)j)
Ki2 = hfi(tj + h; (y1)j + K11; (y2)j + K21; ¡¡¡ ; (yn)j + Kn1)
i = 1; 2; ¡¡¡ ; n
In an explicit form, (3) becomes
2
6664
y1
y2
...
yn
3
7775
j+1
=
2
6664
y1
y2
...
yn
3
7775
j
+
1
2
0
BBB@
2
6664
K11
K21
...
Kn1
3
7775 +
2
6664
K12
K22
...
Kn2
3
7775
1
CCCA; j = 0; 1; ¡¡¡ ; N 1
(4)
1.3 Runge-Kutta (Classical) Method of Fourth Order
The vector format of fourth order Ruge-Kutta method is
yj+1 = yj +
1
6
(K1 + 2K2 + 2K3 + K4) (5)
where
K1 =
2
6664
K11
K21
...
Kn1
3
7775; K2 =
2
6664
K12
K22
...
Kn2
3
7775; K3 =
2
6664
K13
K23
...
Kn3
3
7775; K4 =
2
6664
K14
K24
...
Kn4
3
7775
Ki1 = hfi(tj; (y1)j; (y2)j; ¡¡¡ ; (yn)j)
Ki2 = hfi
tj +
h
2
; (y1)j +
K11
2
; (y2)j +
K21
2
; ¡¡¡ ; (yn)j +
Kn1
2
Ki3 = hfi
tj +
h
2
; (y1)j +
K12
2
; (y2)j +
K22
2
; ¡¡¡ ; (yn)j +
Kn2
2
Ki4 = hfi (tj + h; (y1)j + K13; (y2)j + K23; ¡¡¡ ; (yn)j + Kn3)
i = 1(1)n
2
3. In explicit form, (5) becomes
2
6664
y1
y2
...
yn
3
7775
j+1
=
2
6664
y1
y2
...
yn
3
7775
j
+
1
6
0
BBB@
2
6664
K11
K21
...
Kn1
3
7775 + 2
2
6664
K12
K22
...
Kn2
3
7775 + 2
2
6664
K13
K23
...
Kn3
3
7775 +
2
6664
K14
K24
...
Kn4
3
7775
1
CCCA(6)
j = 1; 2; ¡¡¡ ; N 1
ExampleCompute an approximation to y(1), yH(1) and yHH(1) with the Taylor
series method of Second order and step length h = 1, for the initial value
problem
yHHH + 2yHH + yH y = cos t; 0 t 1
y(0) = 0; yH(0) = 1; yHH(0) = 2
after reducing it to a system of
4. rst order equations.
Solution
Set y = v1; vH
1 = v2; vH
2 = v3
Note that v2 = vH
1 = yH
v3 = vH
2 = yHH and
vH
3 = vHH
2 = yHHH
The system of equations is
vH
1 = v2; v1(0) = 0
vH
2 = v3; v2(0) = 1
vH
3 = cos t 2v3 v2 + v1; v3(0) = 2
or
vH =
2
4
v1
v2
v3
3
5
H
=
2
4
v2
v3
cos t 2v3 v2 + v1
3
5; v(0) =
2
4
0
1
2
3
5
The Taylor series method of second order is
v(t0 + h) = v0 + hvH
0 +
h2
2!
vHH
0
= v0 + vH
0 +
1
2
vHH
0
3
5. Since h = 1, we have
vH
0 =
2
4
v2(0)
v3(0)
1 2v3(0) v2(0) + v1(0)
3
5 =
2
4
1
2
4
3
5
Now,
vHH =
2
4
vH
2
vH
3
sin t 2vH
3 vH
2 + vH
1
3
5and vHH
0 =
2
4
2
4
7
3
5
Hence,
v(1) = v0 + vH
0 +
1
2
vHH
0 =
2
4
0
1
2
3
5 +
2
4
1
2
4
3
5 +
1
2
2
4
2
4
7
3
5 =
2
4
2
1
3=2
3
5
) y(1) = 2; yH(1) = 1; yHH(1) =
3
2
Example Solve the system of equations
xH = 3x + 2y; x(0) = 0
yH = 3x 4y; y(0) = 0:5
with h = 0:2 on the interval [0; 0:4]. Use the
(i) Euler-Cauchy method and
(ii) Classical Runge-Kutta fourth order method.
Solution (i) The Euler-Cauchy method is given by
xj+1 = xj +
1
2
(K1 + K2); j = 0; 1
K1 = hf(tj; xj)
K2 = hf(tj + h; xj + K1)
For j = 0, we have
t0 = 0; x0 = 0; y0 = 0:5
4