Professional Documents
Culture Documents
Equations
Runge-Kutta Methods
Chapter 25
This chapter is devoted to solving first-order
ordinary differential equations (linear/non-linear)
of the form:
dy
f ( x, y ) with initial condition y ( X 0 ) Y0
dx
This type of problem is called IVP (Initial Value
Problem).
[IVPs provides all the conditions (values) at some initial points of the independent variables]
2
Eulers Method
dy
yi 1 yi
( xi 1 xi )
dx i
dy
f ( x, y )
dx
yi 1 yi f ( xi , yi )h
+ = + ,
Each new iteration for +1 is done by adding step size
with the previous iteration, i.e., the iterations must
4
progress one step size (constant) at a time.
=+
0 =1
Solution: We have, +1 = + , .
where, , = + = 0.25
Iteration-1: = 0, = 1, , = 0, 1 = 1
+ = 0+0.25 = 0 + 0, 1
. = 1 + 1 0.25 = .
Iteration-2: = 0.25, = 1.25, , = (0.25, 1.25) = 1.50
+ = 0.25+0.25 = 0.25 + 0.25, 1.25
. = 1.25 + 1.50 0.25 = .
5
= 2 1
. = .
100%
1.7974 1.625
=
100% = 9.6%
1.7974
1.0
1.0
0.1
1.1
1.2
0.2
1.2200
1.4200
0.3
1.3620
1.6620
0.4
0.5
1.5282
1.7210 (Error 4.2%)
1.9282
2.2210
(v)
= 2 3 + 12 2 20 + 8.5
0 =1
= 2
0 =1
= 2 + 2
0 =2
2+1
= + +
0 =1
0 =1
7
dy
f ( x, y ) 2 x 3 12x 2 20x 8.5
dx
Starting point x0 0, y0 1
Not good
f ( xi , yi ) 2
Ea
h
2!
Ea O ( h 2 )
Propagated truncation error
In conclusion,
the error can be reduced by reducing the step size
If the solution to the differential equation is linear, the
method will provide error free predictions as for a straight
line the 2nd derivative would be zero.
10
Figure 25.4
11
Heuns Method/
One method to improve the estimate of the slope
involves the determination of two derivatives for the
interval:
At the initial point
At the end point
Predictor :
yi01 yi f ( xi , yi )h
f ( xi , yi ) f ( xi 1 , yi01 )
Corrector : yi 1 yi
h
2
13
Heuns Method/
Predictor :
yi01 yi f ( xi , yi )h
f ( xi , yi ) f ( xi 1 , yi01 )
Corrector : yi 1 yi
h
2
14
+1 = + ,
2
+1 = + (
1, 1)
+2 +2
15
=+
0 =1
Iteration
xi
yi
f(xi, yi )
1.25
0.25
1.5
0.25
1.56
1.7031
0.5
2.2031
0.50
1.3125
1.7832
Error
0.8%
y0i+1 xi+1
f(xi+1, y0i+1)
16
=+
0 =1
Iteration
xi
yi
0.25
1.3125
1.7832
0.50 Error 0.8%
f(xi, yi ) xi+1/2
yi+1/2
f(xi+1/2, yi+1/2 )
0.125
1.125
1.25
1.56
0.375
1.5078
1.8828
17
(v)
= 2 3 + 12 2 20 + 8.5
0 =1
= 2
0 =1
= 2 + 2
0 =2
2+1
= + +
0 =1
0 =1
18
21 1
22 2
19
yi 1 yi (a1k1 a2 k2 )h
20
f ' ( xi , yi ) 2
h
2!
f ( xi , yi ) f ( xi , yi ) dy
f ' ( xi , yi )
x
y
dx
However yi 1 yi f ( xi , yi )h
But
f ( xi , yi ) f ( xi , yi ) dy h 2
Then yi 1 yi f ( xi , yi )h
2!
y
dx
k1 f ( x i , yi )
k 2 f ( xi p1h, yi q11k1h)
We now expand k 2 f ( xi p1h, yi q11k1h)
f ( xi , yi )
f ( xi , yi )
k 2 f ( xi , yi )
p1h
q11k1h
x
y
21
We replace k1 and k2 in
yi 1 yi (a1k1 a2 k2 )h
to get
f ( xi , yi )
f ( xi , yi )
yi 1 yi a1 f ( xi , yi ) a2 f ( xi , yi )
p1h
q11k1h h
x
y
or
f ( xi , yi )
yi 1 yi a1h f ( xi , yi ) a2 h f ( xi , yi ) a2 p1h 2
x
2 f ( xi , yi )
a2 q11 f ( xi , yi )h
y
Compare with
f ( xi , yi ) f ( xi , yi )
h2
yi 1 yi f ( xi , yi )h
f ( xi , yi )
2!
a1 a2 1
and obtain
1
2
1
a2 q11
2
a 2 p1
(3 equations-4 unknowns)
22
Figure 25.14
24
yi 1 yi i h
i ( xi , yi , h ) a k a2k2 a k a4k4
i
1 1
k f ( xi , yi )
i
1
i
3 3
p1 = 1/2,
q11 =1/2
p2 = 1/2,
q21 =0,
q22 = 1/2
p3 = 1,
q31 =0,
q32 = 0,
k2 f ( xi p1h, yi q11k1h )
i
q33 = 1
25
1 = ,
2 =
,
2
1
2
2
+ , +
2
2
4 = ( + , + 3 )
3 =
1 + 22 + 23 + 4
=
+1 = +
6
In this method, for each new iteration (i+1) with increased stepsize, the values of ks and (weighted average of slope
components) are calculated at i, then estimate of +1 is made.
26
=+
0 =1
Itera
tion
xi
yi
k1 i
0.125
1.125
1.25
1.1563
1.2813
0.25
1.3203
1.5703
0.25
1.3180
1.5680
0.375
1.514
1.8890
1.5542
1.9292
0.50
1.8003
2.3003
i
i
xi+h/2 yi+k1h/2 k2 yi+k2h/2 k3
xi+h yi+k3h
1.7974
Error
0.50
0%
27
k4 i
(v)
0 =1
0 =1
= +
0 =2
= +
0 =1
= 2
0 =1
28
Higher-Order/Simultaneous (Coupled)
Differential Equations
Given a second-order differential equation (IVP) as shown below:
2
2 2+3
+ 5 = 11
=
We can set
2
Then
=
2
2
+ 3 + 5 = 11
0 = 13
29
Higher-Order/Simultaneous (Coupled)
Differential Equations
So we have two equations of the first order as follows:
= = , ,
0 =7
11 3 5
=
= (, , ) 0 = 13
2
Thus we can reduce the higher-order differential equations into
a set of first-order differential equations and then solve them
simultaneously using any of the Euler, Heun, Midpoint or R-K
methods.
[ Note that each step, both the equations are to be solved, (i.e., both y and z
are to be solved) before going to the next higher step ]
30
Higher-Order/Simultaneous (Coupled)
Differential Equations
Lets solve the following to estimate y(0.5) using Eulers method:
2
2 2
+ 5 = 11
0 = 7,
0 = 13
= = , ,
0 =7
11 3 5
=
= (, , )
0 = 13
31
Higher-Order/Simultaneous (Coupled)
Differential Equations
From Eulers Method, +1 = + 1 , , .
And
+1 = + 2 , , .
where, , , =
, , =
0+0.25 = 0 + 1 0, 7, 13
. = 7 + 13 0.25 = .
And
0+0.25 = 0 + 2 0, 7, 13
. = 13 + 31.5 0.25 = .
32
Higher-Order/Simultaneous (Coupled)
Differential Equations
From Eulers Method, +1 = + 1 , , .
And
+1 = + 2 , , .
where, , , =
, , =
33
2
2
+2
3 = 6
2
10 2
0 =1
+ 6 = 0
0 =0
34
Higher-Order/Simultaneous (Coupled)
Differential Equations
2
+2
3 = 6
2
We have,
0 = 0,
= = , ,
0 =1
0 =0
= 6 + 3 2 = (, , )
0 =1
0
Heuns Method, +1
= + 1 , , .
0
And
+1
= + 2 , , .
where, , , = , , = +
Then, +1 = +
0
0
1 , , +1 +1 ,+1
,+1
35
Higher-Order/Simultaneous (Coupled)
Differential Equations
2
+2
3 = 6
0 = 0,
0 =1
2
Heuns Method (each iteration should complete predictor step for all the
variables and then go for corrector step)
0
Predictor Step: +1
= + 1
0
+1
= + 2
where, , , =
, , .
, , .
, , = +
Corrector Step:
+1
0
0
1 , , + 1 +1 , +1
, +1
= +
2
+1
0
0
2 , , + 2 +1 , +1
, +1
= +
2
.
36
+ =
= 0.25
+
2
+ 5 = 0
2
0 = 4.
37