Академический Документы
Профессиональный Документы
Культура Документы
DIFFERENTIAL EQUATIONS
USING RUNGE-KUTTA
METHODS
Structure
15.1 Introduction
Objectives
15.2 Runge-~uttaMethods
Runge-Kutta Methods of Second Order
Runge-Kutta Methods of Third Order
Runge-Kutta Methods of Fourth Order
15.3 Richardson's Extrapolation
15.4 Summary
15.5 Solutions/Answers
15.1 INTRODUCTION
In order to avoid this difficulty, at the end of nineteenth century, the Cierman
mathematician, Runge observed that the expression for the increment function t$ (t, y, h)
in the singlestep methods [see Eqn. (24) of Sec. 14.3, Unit 141
can be modified to avoid evaluation of hlgher order derivatives. This idea was further
developed by Runge and Kutta (another German mathematician) and the methods given
by them are known as Runge-Kutta methods. Using their ideas, we can construct higher
order methods using only the function f(t, y) at selected points on each subinterval. We
shall, in the next section, derive some of these methods.
Objectives
After studying this unit, you should be able to :
obtain the solution of IVPs using Runge-Kutta methods of second, third and fourth order,
compare the solutions obtained by using Runge-Kutta and Taylor series methods;
extrapolate the approximate value of the solutions obtained by the Runge-Kutta
methods of second, third and fourth order.
We shall first try to discw the basic idea of how the Runge- Kutta methods are developad.
Numerical D i f h t i a t i o n Integration consider the q h 2 ) singlestep method
and Solution of Differential Equations
hZ
Y , + l Z Y, + hy', + TY",
If we write Qn. (3) in the form of Eqn. (2) i.e., in terms of + [t,,, y,, hl involving
partial derivatives of f(t, y), we obtain
Runge observed that the r.h.s. of Eqn. (4) can also be obtained using the Taylor series
expansion of f(t,, + ph, y, + qhf) as
f(t,, + ph, y, + qhQ - f + ph f, (6,Y,) + qh% fy (b* yn) (5)
Comparing Eqns. (4) and (5) we € i d that p = q = 112 and the Taylor series method of
0(h2) given by Eqn. (3) can also be written as
Since (5) is of q h 2 ) , the value of yn+l in (6) has the TE of 0(h3). Hence the method
(6) is of w h Z ) which is same as that of (3).
The advantage of using (6) over Taylor series method (3) is that we need to evaluate
the function f(t, y) only at two points (t,,, y,) and . We observe that
f(t,,, y,) denotes the slope of the solution curve to the IVP (1) at (t,,, y,). Further,
[ + -, + (-1 I
f t, y, f, denotes an approximation to the slope of the solution curve at the
[ + - ( + -:)I
point t,, y t, Eqn. (6) denotes geometrically, that the slope of the solution
I
curve in the interval t , tn+l is being approximated by an approximation to the slope at
h
the middle points t,, + -. This idea can be generalised and the slope of the solution
2
[ I
curve in t,,, t,+, can be replaced by a weighted sum of slopes at a number of points in
(called off- step poinb). This idea is the basis of the Runge-Kutta methods.
[b,
Let us consider for example, the weighted sum of the slopes at the two points [t,,, y,]
and [t,, + ph, Y, + qhfl, 0 < p, q < 1 as
We a11 W, and W2 as weights and p and q as scale factors. We have to determine the
four unknowns W1, W2, p and q such that 4 (t,,, y,, h) is of 0(h2). Substituting Eqn. (5)
in (7),we have
where ( 1, denotes that the quantities inside the brackets are evaluated at (t,,, y,).
-
Comparing the r.h.s. of Eqn. (9) wlth Eqn. (3), we € i d that
In the system of Eqns. (lo), since the number of unknowns is more than the number of Solution OE Ordinary DiEEuential
Equations using Runpc-Kutta Methods
equations, the solution is not unique and we have infinite llurnber of solutions. The
solution of Eqn. (10) can be written as
Note that when f is a functian of t only, the method (12) is equivalent to the
trapezoidal rule of integration, whereas the method (6) is equivalent to the midpoint rule
of integration. Both the methods (6) and (12) are of 0(h2). The methods (6) and (12)
can easily be implemented to solve the IVP (1). Method (6) is usually known as
improved tangent method or modified Euler method. Method (12) is also known as
Euler-Cauchy method. '
We shall now discuss the Runge-Kutta methods of 0(h2), 0(h3) and 0(h4.
r i-I 1
The parameters Ci, aij, Wj are unknowns and are to be determined to obtain the
Runge-Kutta methods.
where
where the parameters C2 a,, W, and W2 are chosen to make yn+] closer to y(&+3.
h2 h3
y(b+d=y(f)+ ( t d , h ~ ' + ~ ~ ' ( b ) + ~ ~ ' " ( t d , + . . . .
where
Y' = f(S Y)
yff=<+f$
~"'=<~+2f<~+S7fl+fy(~+f$)
We expand Kt and & about the point (\, yn)
1
a21w2 = 5
From these equations we find that if Cz is chosen arbitrarily we have
Subtracting Eqn. (20) fiom the Taylor series (17, we get the truncation error as
= y(b+J - Y,+1
Since the TE is of 0(h3), all the above R-K methods are of second order. Observe that
no choice of C2 will make the leading term of TE zero for all f(t, y). The local TE
depends not only on derivatives of the solution y(t) but also on the function f(t, y). This
is typical of all the Runge-Kutta methods. Generally, C2 is chosen between 0 and 1 so
that we are evaluating f(t, y) at an off-step point in [b, b+,]. From the defmition, every
Runge- Kutta formula must reduce to a quadrature formula of the same order or greater
if f(t, y) is independent of y; where Wi and Ci will be weights and abcissas of the
corresponding numerical integration formula.
Best way o f obtaining the valuk.pf.the arbitrary parameter C2 in our tormula is to Solution o f Ordinary Differential
Equations using RungeKutta Methods
i) choose some of Wi's zero so as to minimize the computations.
ii) choose the parameter to obtain least m,
iii) choose the parameter to have longer stability interval.
Methods satisfying either of the condition (ii) or (iii) are called optimal Runge-kutta
methods.
1 1
i) C 2 = -
2'
:. a2, = - W,= 0, W2 = 1, then
2'
2
iii) C2 = -
3'
.. a2, = 3'2 W1 = -4'1 W2 = -34' then
~ntl=~n+K,
Table 1
Solutions and errors in solution of y' = - t y2 y(2) = 1, h = 0.1. Numbers inside
brackets denote the errors.
You may observe here that all the above numerical solutions have almost the same error.
- -
Solve the following IVPs using Heun's method of q h 2 ) and the optimal R-K method
of 0(h2).
Also compare the errors at t = 0.4, obtained here with the one obtained by Taylor
series method of 0(h2).
1
y' = 3t + - y, y(0) = 1. Find y(0.2) taking h = 0.1. Given y(t) = 13etn- 6t - 12, find
i E3) 2
the errors.
Y~+~=Y~+W~K~+WZK,+W~K~
where
Numerical Differentiation Integration
and Solution of Differential Equations K, = h f(tn + c p , Yn + a21 K,)
K3 = h f(tn + C3h, Y, + a31 Kl + a32 KJ
Expanding 6,K3 and yn+linto Taylor series, substituting their values in Eqn. (25) and
comparing the coefficients of powers of h, h2 and h3, we obtain
1
a21 = C2 c2w2+ C3W3= y
We have 6 equations to determine th? 8 unknowns. Hence the system has two arbitrary
parameters. Eqns. (26) are typical of all the R-K methods. Looking at Eqn. (26), you
may note that the sum of aij9sin any row equals the corresponding Ci's and the sum of
the Wi's is equal to 1. Further, the equations are linear in W2 and W3 and have a
solution for W2 and W3 if and only if
Since two parameters of this system are arbitrary, we can choose C2, C, and determine
from Eqn. (27) a<
C3(C3 - CZ)
a
- 3C2)
32 = C2(2
2
If C3 = 0, or C2 = C3 hen Cz = - and we can choose a= d 0, arbitrarily. All Ci's
3
should. be chosen such that 0 < Ci < 1. Once C2 and C3 are prescribed, Wi9sand aij's
can be determined from Eqns. (26).
Heun's Method
We now illustrate the third order R-K methods by solving the problem considered in
Example 1, using (a) Heun's method @) optimal method
a) Heun's method
= - 0.16080
y(2.1) = 0.8294
Taking t, = 2.1 and y = 0.8294, we have
K, = - 0.14446
K, = - 0.13017
K3 = - 0.11950
y(2.2) = 0.70366
Numerical Differeatiation fntcgration b) Optimal method
and Solution of Differential Equations
K3 = -0.15905
y(2.1) = 0.8297
Taking tl = 2.1 and yl = 0.8297, we have
Kl = -0.14456
You can now easily find the errors in these solutions and compare the results with those
obtained in Example 1.
And now here is an exercise for you.
Since the expansions of K,,K3, and yMl in Taylor series are complicated, we shall
not write down the resulting system of equations for the determination of the unknowns.
It may be noted that the system of equations has 3 arbitrary parameters We shall state
directly a few R-K methods of ~ ( h ? .The R-K methods (31) can be denoted by
c
2 a21
c3 a31 a32
4
'1
' "2' "3
' w4
For different choices of these unknowns we have the following methods :
i) Classical R-Kmethod
Solution of Ordinary Differential
(32) Equations using R u n g e b t a Methods
This is the widely used method due to its simplicity and moderate o d u . We shall also
be working out problems mostly by the classical R-K method lanlcas specified otherwise.
ii) Runge-Kutta-MI metbod
The RungaKutta-Gill method is also used widely. But, in this unit, we s h l l mostly
work out problems witb the classical R-K method of q h 9 . Hence, whenever we refer
to R-K method of q b 4 ) we mean only the classial R-K method of 0@3given by
(32). We shall now illustrate this method through examples.
Example 2 : Solve the IVP y' = t + y, y(0) = 1 by Runge-Kuttr method of 0@3 for
t E [0,0.5] witb h = 0.1. Also find the e m r at t = 0.5, if the exact solution is
y(t) = 2et-t-1.
Solution : We use the R-K metbod of 0@>given by (32).
Initially, to = 0, yo = 1.
We have
Numerical Differentiation Integration 1
and Solution of Differential Equations Y ~ = Y ~ + ~ ( K , + ~ K ~ + ~ & + K ~ )
1
= 1 + - [1+ 0.22 + 0.2210 + 0.121051 = 1.11034167
6
Taking tl = 0.1 and y, = 1:11034167, we repeat the process.
+ 0.144303013] = 1.24280514
Rest of the values y3, ye y5 we give in Table 2.
Table 2
-
Now the exact solution is
Error at t * 0.5 is
Find y(0.1), y(0.2), y(0.3) taking B = 0.1. Also € i d the errors at t = 0.3, if &e exact
solution is y(t) E 3(e2 - e'),
Solution : a) Classical R-K method is Solution of Ordinary Diffaential
Equations using RungeKutta hhethods
K, = 0.528670978,
K, = 0.6045222614,
y(0.3) e 1.416751936
-
From the exact solution we get
y(0.3) 1.416779978
Enor in classical R-K method (at t = 0.3) = 0.2802X lo*
Error in R-K43iII method (at t = 0.3) = 0.2804 x loa.
You may now try the following exercises.
-
+
E8) y' m L
tZ
- t - y2, y(1) - 1. Find y(1.3) taking h = 0.1. Given the exact solution to be
y(t) = t,
Eiid the error at t = 1.3.
In the next section, we shall study the application of Richardson's extrapolation to the
solutions of ordinary differential equations.
You know that Richardson's extrapolation technique improves the approximate value of
y(\) and the order of this improved value of y(f) exceeds the order of the method by
one.
Here we shall first calculate the solutions F(hl) and F(hJ of the given IVP with
steplengths h, and h2 where h2 = h1/2 at a given point using a Runge-Kutta method.
Then by Richardson's extrapolation technique we have for the second order method
as the improved solution at that point, which will be of higher order than tbe original
method. We shall now illustrate the technique through an example..
Example 4 : Using Runge-Kutta method of 0@') find the solution of the IVP y' = t + y,
y(0) = 1 using h = 0.1 and 0.2 at t = 0.4. Use extrapolation technique to improve the
accuracy. Also fid the errors if the exact solution is y(t) = 2et - t - 1.
Solution : We shall use Hcun's second order method (23) to find the solution at
t = 0.4 with h = 0.1 and 0.2. The fdlowing Table 3 gives values of y(t) at t = 0.2
and t = 0.4 with h = 0.1 and 0.2.
Table 3
E9) Solve E2) taking h = 0.1 and 0.2 using q h Z )Heun's method. Extrapolate the value at
t = 0.4. Also find the error at t = 0.4.
E10) Solve E6), taking h = 0.1 and 0.2 using 0(h2) Heun's method. Extrapolate the value
at t = 0.4. Compare this solution with the solution obtained by the classical 0(h4
R-K method.
We now end this unit by giving a iummary of what we have covered in it.
Solution of Ordinary Diffexcntial
Equations using Runge-Kutta Metbds
15.4 SUMMARY
In this unit we have leamt the following :
1) Runge-Kutta methods being singlestep methods are self- starting methods.
b
2) Unlike Taylor series methods, R-K methods do not need calculation of higher order
derivatives of f(t, y) but need only the evaluation of f(t, y) at the off-step points.
3) For a given IVP of the form
y l = f ( t , y ) , ~'(to)=Yo, f"tO,b1
where the mesh points are tj = to + jh, j = 0, 1,. . . . ..,n.
t, = b = t, + nh, R-K methods are obtained by writing
= yn + h (weighted sum of the slopes)
rn
The ullknowns Ci, ai, and Wj are then obtained by expanding K,'s and yn+lin Taylor
series about the point (t,, y,) and comparing the coefficients of different powers of h.
4) Richardso~l'sextrapolation technique canhe used to improve the approximate value
qf y(6) obtained by q h 2 ) ,0(h3) and 0(h3 methods and obtain the method of order
one higher than the method.
K,=0.0833125, &=0.117478125
y(0.2) = 1.166645313
Optimal R-K, method : '
K, = 0.05, K2 = 0.071666667
y(0.1) = 1.06625
K, = 0.0833125, & = 0.106089583
y(0.2) = 1.166645313
Exact y(0.2) = 1.167221935
Error in both the methods is same and = 0.577 x
1
E4) Heun's method : yn+l = yn + q (K1+ 3K3)
Starting with 6 = 0, yo = 2, h = 0.1, we have
K1 = - 0.005, K2 = - 0.004853689024
K, = - 0.0048544, K4= - 0.004715784587
y(4.2) = 0.995 1446726.
Exact y(4.2) = 0.99514523 1, Error = 0.559 x lo4
K, = 0.1, K2 = 0.09092913832
K, = 0.09049729525, K4 = 0.08260717517
~(1.1)= - 0.909089993
K, = 0.08264471 138, & = 0.07577035491
K, = 0.0'7547152415, K, = 0.06942067502
~(1.2)= - 0.8333318022
K, = 0.06944457204, K2= 0.0641 1104536
K, = 0.06389773475, K, = 0.0591559551
~(1.3)= - 0.7692287876
Exact y(1.3) = - 0.7692307692
Error = 0.19816 x
Heun's method :
with h = 0.1
K,=0.1, & = O . l O l
y(0.1) = 0.1005
K, = 0.101010, & = 0.104061
y(0.2) = 0.203035
K, = 0.1041223, 6 = 0.1094346
y(0.3) = 0.309813
K, = 0.1095984, & = 0.1048047
with h = 0.2
F(h) = y(0.4) = 0.4251626422 [see E2]
Now
4F(h/2) - F(h)
F("(0.4) = 3
= 0.4142958537
Exact y(0.4) = 0.422793219
Error = 0.8495 x