Академический Документы
Профессиональный Документы
Культура Документы
It can be verified that the estimate for e4 agrees with the actual error in the
value of y(0.04) obtained in Example 8.5.
RungeKutta methods are designed to give greater accuracy and they possess
the advantage of requiring only the function values at some selected points
on the subinterval.
If we substitute y1 = y0 + hf ( x0 , y0 ) on the right side of Eq. (8.13), we
obtain
h
y1 = y0 + [ f 0 + f ( x0 + h, y0 + hf 0 )],
2
where f 0 = f ( x0 , y0 ). If we now set
k1 = hf 0 and k 2 = hf ( x0 + h, y0 + k1 )
then the above equation becomes
1
y1 = y0 + (k1 + k2 ), (8.15)
2
which is the second-order RungeKutta formula. The error in this formula
can be shown to be of order h3 by expanding both sides by Taylors series.
Thus, the left side gives
h2 h3
y0 hy0b y0bb y0bbb "
2 6
and on the right side
⎡ ∂f ∂f ⎤
k2 = hf ( x0 + h, y0 + hf 0 ) = h ⎢ f 0 + h + hf 0 + O (h 2 ) ⎥ .
⎣ ∂x0 ∂y0 ⎦
Since
df ( x, y ) ∂f ∂f
= +f ,
dx ∂x ∂y
we obtain
k2 = h [ f 0 + hf 0′ + O (h 2 )] = hf 0 + h 2 f 0′ + O (h3 ),
h2
= y0 + hy0′ + y0′′ + O ( h3 ).
2
It therefore follows that the Taylor series expansions of both sides of Eq. (8.15)
agree up to terms of order h2, which means that the error in this formula
is of order h3.
More generally, if we set
y1 = y0 + W1k1 + W2 k 2 (8.16a)
where
k1 = hf 0 ⎫⎪
⎬ (8.16b)
k2 = hf ( x0 + α 0 h, y0 + β 0 k1 ) ⎪⎭
312 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
then the Taylor series expansions of both sides of the last equation in (8.16a)
gives the identity
h2 ⎛ ∂f ∂f ⎞ 3
y0 + hf0 + ⎜ + f0 ⎟ + O (h ) = y0 + (W1 + W2 ) hf0
2 ⎝ ∂x ∂y ⎠
⎛ ∂f ∂f ⎞
+ W2 h2 ⎜ B 0 + C0 f0 ⎟ + O (h3 ).
⎝ ∂x ∂y ⎠
Equating the coefficients of f (x, y) and its derivatives on both sides, we
obtain the relations
1 1
W1 + W2 = 1, W2B 0 = , W2 C0 = . (8.17)
2 2
Clearly, B 0 = C0 and if B 0 is assigned any value arbitrarily, then the remaining
parameters can be determined uniquely. If we set, for example, B 0 = C0 = 1,
then we immediately obtain W1 = W2 = 1/2, which gives formula (8.15).
It follows, therefore, that there are several second-order RungeKutta formulae
and that formulae (8.16) and (8.17) constitute just one of several such
formulae.
Higher-order RungeKutta formulae exist, of which we mention only the
fourth-order formula defined by
y1 = y0 + W1k1 + W2 k 2 + W3 k3 + W4 k 4 (8.18a)
where
k1 = hf ( x0 , y0 ) ⎫
⎪
k2 = hf ( x0 + B 0 h, y0 + C0 k1 ) ⎪⎪
⎬ (8.18b)
k3 = hf ( x0 + B1h, y0 + C1k1 + O1k2 ) ⎪
⎪
k4 = hf ( x0 + B 2 h, y0 + C 2 k1 + O 2 k2 + E1k3 ), ⎪⎭
where the parameters have to be determined by expanding both sides of the
first equation of (8.18a) by Taylors series and securing agreement of terms
up to and including those containing h4. The choice of the parameters is,
again, arbitrary and we have therefore several fourth-order RungeKutta
formulae. If, for example, we set
1 ⎫
B 0 = C0 = , B1 = 1 , B 2 = 1, ⎪
2 2 ⎪
1 ⎪
C1 = ( 2 − 1), C2 = 0 ⎪
2 ⎪
⎬ (8.19)
1 1 1 ⎪
O1 = 1 − , O = − , E = 1 + ,
2
2
2
1
2 ⎪
⎪
1 1⎛ 1 ⎞ 1⎛ 1 ⎞⎪
W1 = W4 = , W2 = ⎜1 − ⎟, W3 = ⎜1 + ⎟,
6 3⎝ 2⎠ 3⎝ 2 ⎠ ⎪⎭
SECTION 8.5: RungeKutta Method 313
B 0 = B1 = 1 , 1 ⎫
C0 = O1 =
2 2 ⎪
⎪
C1 = C2 = O 2 = 0, ⎪ (8.20)
B 2 = E1 = 1 ⎬
⎪
W1 = W4 = ,
1 2 ⎪
W2 = W3 = ⎪
6 6 ⎭
leads to the fourth-order RungeKutta formula, the most commonly used
one in practice:
1
y1 = y0 + (k1 + 2k2 + 2k3 + k4 ) (8.21a)
6
where
k1 = hf ( x0 , y0 ) ⎫
⎪
⎛ 1 1 ⎞⎪
k2 = hf ⎜ x0 + h, y0 + k1 ⎟ ⎪
⎝ 2 2 ⎠⎪
(8.21b)
⎬
⎛ 1 1 ⎞⎪
k3 = hf ⎜ x0 + h, y0 + k2 ⎟ ⎪
⎝ 2 2 ⎠
⎪
k4 = hf ( x0 + h, y0 + k3 ) ⎪
⎭
in which the error is of order h5. Complete derivation of the formula is
exceedingly complicated, and the interested reader is referred to the book by
Levy and Baggot. We illustrate here the use of the fourth-order formula by
means of examples.
Example 8.8 Given dy/dx = y − x where y (0) = 2, find y (0.1) and y (0.2)
correct to four decimal places.
(i) RungeKutta second-order formula: With h = 0.1, we find k1 = 0.2
and k 2 = 0.21. Hence
1
y1 = y (0.1) = 2 + (0.41) = 2.2050.
2
To determine y2 = y (0.2), we note that x0 = 0.1 and y0 = 2.2050. Hence,
k1 = 0.1(2.105) = 0.2105 and k2 = 0.1(2.4155 − 0.2) = 0.22155.
It follows that
1
y2 = 2.2050 + (0.2105 + 0.22155) = 2.4210.
2
Proceeding in a similar way, we obtain
y3 = y (0.3) = 2.6492 and y4 = y (0.4) = 2.8909
314 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
We next choose h = 0.2 and compute y (0.2) and y(0.4) directly. With h = 0.2.
x0 = 0 and y0 = 2, we obtain k1 = 0.4 and k2 = 0.44 and hence y(0.2) =
2.4200. Similarly, we obtain y(0.4) = 2.8880.
From the analytical solution y = x + 1 + ex, the exact values of y(0.2)
and y(0.4) are respectively 2.4214 and 2.8918. To study the order of conver-
gence of this method, we tabulate the values as follows:
x Computed y Exact y Difference Ratio
Example 8.10 We consider the initial value problem y ′ = 3x + y/2 with the
condition y(0) = 1.
The following table gives the values of y(0.2) by different methods, the
exact value being 1.16722193. It is seen that the fourth-order RungeKutta
method gives the accurate value for h = 0.05.
Method h Computed value
EXERCISES
8.1. Given
dy
= 1 + xy, y (0) = 1,
dx
obtain the Taylor series for y(x) and compute y(0.1), correct to four
decimal places.
8.2 Show that the differential equation
d2y
= – xy, y (0) = 1 and y ′(0) = 0 ,
dx 2
has the series solution
x3 1 t 4 6 1 t 4 t 7 9
y 1 x x "
3! 6! 9!
336 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
8.3 If
dy 1
= with y (4) = 4,
dx x 2 + y
compute the values of y (4.1) and y (4.2) by Taylors series method.
8.4 Use Picards method to obtain a series solution of the problem given
in Problem 8.1 above.
8.5 Use Picards method to obtain y (0.1) and y (0.2) of the problem defined
by
dy
x yx 4 , y(0) 3.
dx
8.6 Using Eulers method, solve the following problems:
dy 3 3 dy
(a) x y , y(0) 1 (b) 1 y 2 , y(0) 0
dx 5 dx
8.7 Compute the values of y (1.1) and y (1.2) using Taylors series method
for the solution of the problem
y ′′ + y 2 y1 = x3 , y (1) = 1 and y ′(1) = 1.
8.8 Find, by Taylors series method, the value of y (0.1) given that
y bb – xy b y 0, y(0) 1 and y b(0) 0.
8.9 Using Picards method, find y (0.1), given that
dy y x
and y (0) 1.
dx y x
8.10 Using Taylors series, find y (0.1), y (0.2) and y (0.3) given that
dy
= xy + y 2 , y (0) = 1.
dx
8.11 Given the differential equation
dy
= x2 + y
dx
with y (0) = 1, compute y (0.02) using Eulers modified method.
∂ 2u ∂ 2u
+
= 2, 0 ≤ x, y ≤ 1
∂x 2 ∂y 2
with u = 0 on the boundary C of the square region 0 £ x £ 1, 0 £ y £ 1.
Answers to Exercises
8.1 1.1053
x3 1 × 4 6 1 × 4 × 7 9
8.2 1− + x − x +"
3! 6! 9!
8.3 4.005, 4.0098
340 CHAPTER 8: Numerical Solution of Ordinary Differential Equations
x 2 x3 x 4
8.4 1 + x + + + +"
2 3 8
8.5 3.005, 3.0202
8.8 1.005012
8.9 1.0906
8.11 1.0202
dy
13. Given the differential equation = x 2 y + x 2 and the data
dx
x 1 1.1 1.2 1.3
y 1 1.233 1.548488 1.978921
determine y(1.1) by Adams-Bashforth formula.
dy
14. Using Adams-Bashforth method, obtain the solution of = x − y 2 at x = 0.8, given
dx
x 9 0.2 0.4 0.6
y 0 0.0200 0.0795 0.1762
Answers
1. y 4′ = 1.583627, = 1.5703
2.
x 0.3 0.4 0.5 0.6
y 0.061493 0.45625 0.29078 0.12566
FG h , y + k IJ ,
H 2
k3 = h f x0 +
2K
3
0
k = h f b x + h, y + k g,
4 0 0 3
∆y = bk + 2 k + 2 k + k g .
1
and 1 2 3 4
6
Thus we can write
x1 = x 0 + h, y1 = y0 + ∆y .
Similarly the increments for the other intervals are computed. It will be noted that if f(x, y) is
independent of y then the method reduces to Simpson’s formula. Though approximately the same as
Taylor’s polynomial of degree four. Runge-Kutta formulae do not require prior calculations of higher
derivatives of y(x), as the Taylor’s method does. These formulae involve computation of f (x, y) of
various position. This method known as Runge-Kutta fourth order method is very popular and
extensively used but the errors in method are not easy to watch. The error in the Runge-Kutta method
is of the order h5. Runge-Kutta methods agree with Taylor’s series solution up to the term hm where
m differs from the method and is called the order of that method.
First order Runge-Kutta method:
Consider the first order equation
dy
dx
a f b g
= f x , y , y x 0 = y0 L (1)
b g
y1 = y x 0 + h = y0 + hy0′ +
h2
2
y0′′ + L (3)
Comparing (2) and (3), it follows that, Euler’s method agrees with Taylor’s series solution up
to the term in h.
Hence Euler’s method is the Runge-Kutta method of the first order.
Second order Runge-Kutta method:
The modified Euler’s method gives
y1 = y0 +
h
2
b
f x0 , y0 + f x0 + h, y1 g b g (4)
b
y1 = y x0 + h g = y0 +
h
2
b
f 0 + f x0 + h, y 0 + h f 0 g (5)
b g
y1 = y x 0 + h = y0 + hy0′ +
h2
2!
y0′′ +
h3
3!
y0′′′+ L (6)
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 235
Expanding f (x0 + h, y0 + h f0) by Taylor’s series for a function of the variables, we obtain
FG ∂f IJ FG ∂f IJ d i
f0 + h =
H ∂x K 0
+ h f0
H ∂y K 0
+ O h2
1 LM LMFG ∂f IJ FG ∂f IJ OP + O dh iOP
MNH ∂x K H ∂y K PQ
y1 = y0 + hf 0 + hf 0 + h 2 + f0
MN PQ
3
2 0 0
= y0 + hf 0 +
h2
2
f 0′ + O h 3 d i
LMQ df
=
∂f
+ f
∂f
where f = f x , y b gOPQ
N dx ∂x ∂y
= y0 + hy0′ +
h2
2!
y0′′ + O h 3 . d i (7)
Comparing (6) and (7), it follows that the modified Euler’s method agrees with Taylor’s series
solution up to the term in h2.
Hence the modified Euler’s method is the Runge-Kutta method of second order.
The second order Runge-Kutta formula is as follows:
b g
k1 = h f xn , yn
k2 = h f b x + h, y
n n + k1 g
yn + 1 = yn + ∆yn
where ∆yn =
1
2
b
k1 + k 2 g
which gives k1 = h f bx , y g
0 0
k2 = h f b x + h, y + k g
0 0 1
= y + bk + k g = y
1
and y1 0 1 2 0 + ∆y0 .
2
236 NUMERICAL ANALYSIS
y1 = y0 +
1
6
b
k1 + 4 k 2 + k 3 g
where b g
k1 = h f x0 , y0
F h
k = h f Gx + , y + J
k I
H 2 2K
1
2 0 0
k = h f b x + h, y + 2 k − k g
3 0 0 2 1
where b g
k1 = h f xn + yn
F 1
k = hf G x + h , y + k J
1 I
2
H 2 2 K
n n 1
k = hf b x + h , y + 2 k − k g
3 n n 2 1
∆y = b k + 4 k + k g
1
and 1 2 3
6
Runge-Kutta methods are one-step methods and are widely used. Fourth order R-K method is
most commonly used and is known as Runge-Kutta method only. We can increase the accuracy of
Runge-Kutta method by taking higher order terms.
Example 10.12 Use Runge–Kutta method to approximate y when x = 0.1, given that y = 1, when
dy
x = 0 and = x + y.
dx
Solution We have
x0 = 0, y0 = 1
b g
f x , y = x + y , and h = 01
..
∴ f bx , y g = x
0 0 0 + y0 = 0 + 1 = 1,
we get k1 = h f x0 , y0b g = 01
. × 1 = 01
. ,
= b01
. g f b0.05, 105
. g = b01
. gb0.05 + 105
. g = 011
. ,
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 237
FG h , y + k IJ
H 2
k 3 = h f x0 +
2K
2
0
= b01
. g c f b0 + 0.05g, 1 + 0.055h = b01. gb0.05 + 1055. g
= b01
. gb1105
. g = 01105. ,
k4 = f bx + h , y + k g
0 0 3
= b01
. g f b0 + 0.01, 1 + 01105
. g = b01. g f b01. , 11105
. g
= b01
. gb12105
. g = 012105
. ,
∴ ∆y =
1
6
b
k1 + 2 k 2 + 2 k 3 + k 4 g
=
1
6
b
0.1 + 0.22 + 0.2210 + 012105
. g = 011034
. .
We get x1 = x0 + h = 0 + 01
. = 01
.
y1 = y0 + ∆y = 1 + 0.11034 = 111034
. .
dy
Example 10.13 Using Runge–Kutta method, find an approximate value of y for x = 0.2, if = x + y 2 , gives that
dx
y = 1 when x = 0.
Solution Taking step-length h = 0.1, we have
x 0 = 0, y 0 = 1,
dy
dx
b g
= f x, y = x + y 2 .
Now b g b gb g
k1 = h f x0 , y0 = 01
. 0 + 1 − 01
. ,
F h k I
= h f G x + , y + J = b01 . gb0.05 + 11025g
H 2 2K
1
k2 0 0 .
= b01
. gb11525
. g = 011525
. ,
F h k I
= h f G x + , y + J = b01 . gb0.05 + 11185g
H 2 2K
2
k3 0 0 .
= b01
. gb11685
. g = 011685
. ,
k4 = h f bx + h , y + k g
0 0 3
= b01
. gb0.01 + 12474
. g = b01. gb13474
. g = 013474
. ,
∴ ∆y =
1
6
bk1 + 2 k 2 + 2 k 3 + k 4 g
238 NUMERICAL ANALYSIS
=
1
6
c0.1 + 2 011525
. b g b
+ 2 0.11685 + 0.13474 g h
=
1
6
b0.6991 = 0.1165.g
We get y1 = y0 + ∆y = 1 + 01165
.
b g
∴ y 01
. = 11165
. .
For the second step, we have
x0 = 01
. , y0 = 11165
. ,
b gb
k1 = 01 . + 12466
. 01 . g
= 01347
. ,
k = b01
2 . gb015
. + 14014
. g = b01. gb15514
. g = 01551
. ,
k = b01
3 . gb015
. + 14259
. g = b01. gb15759
. g = 01576
. ,
k = b01
4 . gb0.2 + 16233
. g = b01. gb18233
. g = 01823
. ,
∆y = b 0.9424 g = 0.1571 ,
1
6
∴ yb0.2g = 11165
. + 01571
. = 12736
.
∴ yb01 . g = 11165
. and yb0.2g = 12736
. .
Example 10.14 Using Runge-Kutta method of order 4, find y for x = 0.1, 0.2, 0.3, given that
dy
= xy + y 2 , y(0 ) = 1. . Continue the solution at x = 0.4 using Milne’s method.
dx
Solution. We have f(x, y) = xy + y2
x0 = 0, y0 = 1
x1 = 0.1, x2 = 0.2, x3 = 0.3, x4 = 0.4, and h = 0.1
To find y1 = y (0.1):
k 1 = hf (x0, y0) = (0.1) (0 × 1 + 12) = 0.1000
FG x h k IJ
k 2 = hf H 0 +
2
, y0 + 1
2 K = (0.1) f (0.05, 1.05)
= 0.1155
FG h k IJ
k 3 = hf x0 +
H 2 K
, y0 + 2 = ( 0.1) f (0. 05,1. 0577 )
2
= 0.1172
k 4 = hf (x0 + h, y0 + k3) = (0.1) f (0.1, 1.1172)
= 0.13598
and k =
1
6
b
k1 + k2 + 2 k3 + k4 g
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 239
=
1
6
b
0.1000 + 2 × 0.1155 + 2 × 0.1172 + 0.13598 g
= 0.11687
∴ y1 = y(0.1) = y0 + k = 1 + 0.11687 = 1.11687 ~ 1.1169
⇒ y1 = 1.1169
To find y2 = y(0.2)
Here we have
k 1 = hf (x1, y1) = (0.1) f (1, 1.1169) = 0.1359
FG h k IJ
H
k 2 = hf x1 +
2 K
, y1 + 1 = (0.1) f (0.15, 1.1848)
2
= 0.1581
FG h k IJ = (0.1) f (0.15,1.0959)
k 3 = hf x1 +
H 2
, y1 + 2
2 K
= 0.1609
k 4 = hf ( x1 + h, y1 + k3 ) = ( 0.1) f ( 0. 2, 1. 2778)
= 0.1888
k =
1
6
b
k1 + 2 k2 + 2 k3 + k4 g
=
1
6
b
0.1359 + 2 × 0.1581 + 2 × 0.1609 + 0.1888 g
= 0.1605
y2 = y(0.2) = y1 + k = 1.1169 + 0.1605 = 1.2774
To find y3 = y(0.3)
Here we have k 1 = hf (x2, y2) = (0.1) f (0.2, 1.2774)
= 0.1887
FG h k IJ
k 2 = hf x2 +
H 2 K
, y2 + 1 = (0.1) f (0. 25,1. 3716)
2
= 0.2224
FG h k IJ
k 3 = hf x2 +
H 2 K
, y2 + 2 = (0.1) f ( 0. 25,1.3885)
2
= 0.2275
b g
k 4 = hf x2 + h, y2 + k3 = ( 0.1) f ( 0. 3,1.5048)
= 0.2716
k =
1
6
b
k1 + 2 k2 + 2 k3 + k4 g
=
1
6
b
0.1887 + 2 × 0. 2224 + 2 × 0. 2275 + 0. 2716 g
= 0.2267
240 NUMERICAL ANALYSIS
4h
y4 = y0 + 2 y ′1 − y ′ 2 − 2 y ′3
3
4 × 0.1
= 1+ 2 × 1. 3591 − 1.8869 + 2 × 2.7132]
3
= 1.8344
⇒ y′4 = 4.0988
h
and the corrector is y4 = y2 + y ′ 2 + 4 y ′3 + y ′4
3
0.1
= 12773 + 1.8869 + 4 × 2. 7132 + 4. 0988 = 1.8366
3
∴ y(0.4) = 1.8366
Exercise 10.3
bg
1. Solve the equation dy = x − y 2 , y 0 = 1 for x = 0.2 and x = 0.4 to 3 decimal places by Runge-Kutta
dx
fourth order method.
2. Use the Runge-Kutta method to approximate y at x = 0.1 and x = 0.2 for the equation
dy
dx
bg
= x + y , y 0 = 1.
6. Use Runge-Kutta method to obtain y when x = 1.1 given that y = 1.2 when x = 1 and y satisfies the
dy
equation = 3x + y 2 .
dx
dy 1
7. Solve the differential equation = for x = 2.0 by using Runge-Kutta method. Initial values
dx x + y
x = 0, y = 1, interval length h = 0.5.
NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS 241
8. Use Runge-Kutta method to calculate the value of y at x = 0.1, to five decimal places after a single
step of 0.1, if
dy
= 0. 31 + 0.25 y + 0.3x 2
dx
and y = 0.72 when x = 0
dy y2 − x2
9. Using Runge-Kutta method of fourth order solve = 2 , with y(0) = 1 at x = 0.2, 0.4.
dx y + x2
dy
10. Using Runge-Kutta method of order, 4 compute y(0.2) and y(0.4) from 10 = x 2 + y 2 , y (0) = 1, taking
dx
x = 0.1.
11. Find by Runge-Kutta method an approximate value of y for x = 0.8, given that y = 0.41 when x = 0.4
and
dy
= x + y.
dx
12. The unique solution of the problem
dy
dx
bg
= − xy, y 0 = 1
is y = e − x
2
/3
, find approximate value of y(0.2) using one application of R-K method.
Answers
Explicit Methods
Runge-Kutta methods
The general Runge-Kutta method can be written as
v
yn+1 = yn + ∑ w K, i i n = 0, 1, 2, ..., N – 1 (5.28)
i=1
F i−1 I
where Ki = hf GG x + ci h, yn + ∑a Km JJ
H n
m=1
im
K
with c1 = 0.
For v = 1, w1 = 1, the equation (5.28) becomes the Euler method with p = 1. This is the
lowest order Runge-Kutta method. For higher order Runge-Kutta methods, the minimum
number of function evaluations (v) for a given order p is as follows :
p 2 3 4 5 6 ...
v 2 3 4 6 8 ...
We now list a few Runge-Kutta methods.
Heun method
1
yn+1 = yn + (K1 + 3K3), n = 0(1)N – 1, (5.32)
4
K1 = hf (xn, yn),
278 Numerical Methods : Problems and Solutions
FG 1 1 IJ
H
K2 = hf x n +
3
h , yn + K 1
3 K
= hf FG x 2
+ K J
2 I
K3
H n +
3
h , yn
3 K 2 .
Classical method
1
yn+1 = yn + (K1 + 4K2 + K3), n = 0(1)N – 1, (5.33)
6
K1 = hf (xn, yn),
FG 1 1 IJ
H
K2 = hf x n +
2
h , yn + K 1 ,
2 K
K3 = hf (xn + h, yn – K1 + 2K2).
Fourth Order Methods
Kutta method
1
yn+1 = yn + (K1 + 3K2 + 3K3 + K4), n = 0(1)N – 1, (5.34)
8
K1 = hf (xn, yn),
FG 1 1 IJ
H
K2 = hf x n +
3
h , yn + K 1 ,
3 K
F
= hf G x
2 1 IJ
K3
H 3
h , yn − K 1 + K 2 ,
n +
3 K
K4 = hf (xn + h, yn + K1 – K2 + K3).
Classical method
1
yn+1 = yn + (K1 + 2K2 + 2K3 + K4), n = 0(1)N – 1, (5.35)
6
K1 = hf (xn, yn),
FG 1 1 IJ
H
K2 = hf x n +
2
h , yn + K 1
2 K
F
= hf G x
1
+ K J
1 I
K3
H 2
n +
h , yn
2 K 2
K4 = hf (xn + h, yn + K3).
Implicit Runge-Kutta Methods
The Runge-Kutta method (5.28) is modified to
v
yn+1 = yn + ∑ wi Ki, n = 0(1)N – 1, (5.36)
i=1
F v I
where GG
Ki = hf x n + ci h, yn + ∑a JJ
Km .
H m=1
im
K
With v function evaluations, implicit Runge-Kutta methods of order 2v can be obtained.
A few methods are listed.
Numerical Solution of Ordinary Differential Equations 279
1 LM k OP
Cq =
q!
1−
m=1
MN ∑
am (1 − m) q
PQ
k
1
–
(q − 1) !
∑ bm(1 – m)q–1, q = 1(1)p. (5.43)
m=0
Numerical Solution of Ordinary Differential Equations 305
Hence, we get
x 4 ( 4) 99 4
| R4 | = y (ξ) ≤ x
24 24
99 4
Now, x < 5 × 10–5, gives x ≤ 0.059.
24
306 Numerical Methods : Problems and Solutions
(b) If we use the first p terms in the Taylor series method then we have
xp
max max | y(p)(ξ)| ≤ 5 × 10–6.
0 ≤ x ≤ 0.4 p! ξ ∈[ 0, 0.4 ]
(0.4) p
or (11)3p–2 ≤ 5 × 10–6, which gives p ≥ 10.
p!
(c) The second order Taylor series method is given by
h2
yn+1 = yn + h yn′ + yn″ , n = 0, 1, 2, 3
2
We have yn′ = 2x + 2y
n n
yn″ = 2 + 3 yn′ = 2 + 3(2xn + 3yn) = 2 + 6xn + 9yn.
With h = 0.1, the solution is obtained as follows :
n = 0, x0 = 0 : y0 = 1
y0′ = 2 × 0 + 3y0 = 3
y0″ = 2 + 6 × 0 + 9 × 1 = 11,
(0.1) 2
y1 = 1 + 0.1(3) + × 11 = 1.355.
2
n = 1, x1 = 0.1 : y1′ = 2 × 0.1 + 3(1.355) = 4.265.
y1″ = 2 + 6 × 0.1 + 9(1.355) = 14.795.
1
y2 = y1 + h y1′ + h 2 y1″
2
(0.1) 2
= 1.355 + 0.1(4.265) + (14.795) = 1.855475.
2
n = 2, x2 = 0.2 : y2′ = 2 × 0.2 + 3(1.855475) = 5.966425.
y2″ = 2 + 6 × 0.2 + 9(1.855475) = 19.899275.
h2
y3 = y2 + h y2′ + y2″
2
(0.1) 2
= 1.855475 + 0.1(5.966425) + (19.899275) = 2.5516138.
2
Numerical Solution of Ordinary Differential Equations 307
L v ′ OP LM 2OP
v″(0) = M
2
Hence, we obtain
LMv (1)OP LM y(1) OP LM0OP LM 1OP LM 2OP LM 2 OP
1
MNvv ((11))PQ = MN yy″′ ((11))PQ = MN21PQ + MN− 42PQ + 0.5 MN− 47PQ = MN1.15PQ
2
3
5.14 Apply Taylor series method of order p to the problem y′ = y, y(0) = 1 to show that
hp x
| yn – y(xn) | ≤ xn e n .
( p + 1) !
Solution
The p-th order Taylor series method for y′ = y is given by
F h2 hp I
GH
yn+1 = 1 + h +
2!
+ ... + JK
y = A yn, n = 0, 1, 2, ...
p! n
h2 hp
where A=1+h+ + ... + .
2! p!
Setting n = 0, 1, 2, ..., we obtain the solution of this first order difference equation which
satisfies the initial condition, y(0) = y0 = 1, as
F
= G1 + h +
h 2
h I p n
p ! JK
An + ... +
yn =
H 2!
.
A sufficient condition is
1
> 0,
2– or 2p1 p2 – 1 > 0.
p1 p2
Substituting p2 = 2 – p1, we have
1
2 p12 – 4p1 + 1 < 0, or (p1 – 1)2 – < 0.
2
Similarly, we obtain
1
(p2 – 1)2 – < 0.
2
Hence, if follows
1 1
1–
< p1, p2 < 1 + .
2 2
5.18 (a) Give the exact solution of the IVP y′ = xy, y(0) = 1.
(b) Estimate the error at x = 1, when Euler’s method is used, with step size h = 0.01. Use
the error formula
hM
| y(xn) – y(xn ; h) | ≤ [exp (xn – a) L – 1]
2L
when Euler’s method is applied to the problem y′ = f (x, y); y(x) = A, in a ≤ x ≤ b and
h = (b – a) / N, xn = a + nh and | ∂f / ∂y | ≤ L ; | y″(x) | ≤ M.
(Uppsala Univ., Sweden, BIT 25(1985), 428)
Solution
(a) Integrating the differential equation
1 dy
=x
y dx
2
we obtain y = c e x /2
.
The initial condition gives y(0) = c = 1.
2
The exact solution becomes y(x) = e x / 2 .
(b) We have at x = 1,
∂f
= | x | ≤ L = 1,
∂y
2
| y″(x) | = (1 + x2) e x / 2 ≤ M = 3.297442,
1
| y(xn) – y(xn; h) | ≤ [(0.01) 3.297442] (e – 1) = 0.0283297.
2
Hence, we obtain
| y(xn) – y(xn; h) | ≤ 0.03.
5.19 Apply the Euler-Cauchy method with step length h to the problem
y′ = – y, y(0) = 1.
(a) Determine an explicit expression for yn.
312 Numerical Methods : Problems and Solutions
H
yn = 1 − h +
2
h
K
, n = 0, 1, 2, ......
= Me G 1 +
3
h3
yn = Ge
H
−h
+
6
+ O( h 4 ) JK
MN H 6
−h
JK PQ 4
F 1 + nh 3 I
= e–nh GH 6 + O(h )J 4 1
K = e + 6 x e h + O(h ).
–nh
n
–nh 2 4
(a) Apply Heun’s method to the differential equation y′ = λ y, y(0) = 1. Show that
yn = [H(λh)]n
and state the function H. Give the asymptotic expression for yn – y(xn) when h → 0.
(b) Apply Heun’s method to the differential equation y′ = f (x), y(0) = 0 and find yn.
(Royal Inst. Tech., Stockholm, Sweden, BIT 26(1986), 540)
Solution
(a) We have K1 = λh yn,
K2 = λh (yn + λh yn) = λh(1 + λh) yn ,
1
yn + 1 = yn + [λhyn + λh (1 + λh) yn]
2
FG1 IJ
H K
2
= 1 + λh + (λh) yn.
2
This is a first order difference equation. The general solution satisfying the initial con-
dition, y(0) = 1, is given by
FG 1 IJ n
H
yn = 1 + λh +
2
(λh) 2
K .
Therefore, we have
1
(λh)2.
H(λh) = 1 + λh +
2
The analytic solution of the test equation gives
y(xn) = (eλh)n .
Hence, we may write yn in the form
L
= Me
λh 1
(λh) 3 + O(h 4 )
OP n
LM 1
n(λh) 3 + O(h 4 )
OP
yn
N −
6 Q N
= eλ nh 1 −
6 Q
1
x λ3 h2 e λ xn + O(h4)
= y(xn) –
6 n
Therefore, the asymptotic expression for yn – y(xn) is given by
LMFG y − y( xn ) IJ OP = – 1 x λ
NH KQ 6
lim n 3 λ xn .
e
h→0 2 n
h
(b) The Heun method for y′ = f (x), becomes
yn = z xn
0
f ( x) dx = T(h).
where T(h) is the expression for the trapezoidal rule of integration.
5.21 Consider the following Runge-Kutta method for the differential equation y′ = f (x, y)
1
yn + 1 = yn + (K1 + 4K2 + K3),
6
K1 = hf (xn, yn),
h FG K IJ
K2 = hf xn +
2 H
, yn + 1 ,
2 K
K3 = hf (xn + h, yn – K1 + 2K2).
314 Numerical Methods : Problems and Solutions
K3 = 0.2 M
Ly0 − 0.2 + 0.48 + 0.2 O
P = 0.27407.
Ny0 − 0.2 + 0.48 − 0.2 Q
1
y1 = 1 + (0.2 + 0.96 + 0.27407) = 1.23901.
6
Now, using y1 = 1.23901, x1 = 0.2, we obtain
FG y 1 + 0.2IJ = 0.277.
K1 = 0.2
Hy 1 − 0.2 K
= 0.2 G
Fy 1 + 0.13850 + 0.3 I
J = 0.31137.
K2
Hy 1 + 0.13850 − 0.3 K
= 0.2 G
Fy 1 − 0.277 + 0.62274 + 0.4 I
J = 0.33505.
K3
Hy 1 − 0.277 + 0.62274 − 0.4 K
1
y2 = y1 + (0.277 + 4 × 0.31137 + 0.33505) = 1.54860.
6
(b) For f (x, y) = – y, we get
K1 = – hy0,
FG IJ = FG − h + 1 h IJ y ,
1
K H 2 K
2
H
K2 = – h y0 −
2
hy0 0
F
= – h Gy
F 1 I I
+ hy + 2 G − h + h J y J = (– h + h – h ) y ,
H H 2 K K
2 2 3
K3 0 0 0 0
y1 =y +
0 G − hy + 4 FGH − h + 21 h IJK y + (− h + h − h ) y IJK
1 F
6 H 0
2
0
2 3
0
F 1 1 I
= GH 1 − h + h − h JK y .
2 3
0
2 6
F
= G1 − h + h − h J .
1 1 I
H 6 K
2 3
Therefore, y1
2
Numerical Solution of Ordinary Differential Equations 315
5.22 Use the classical Runge-Kutta formula of fourth order to find the numerical solution at
x = 0.8 for
dy
= x + y , y(0.4) = 0.41.
dx
Assume the step length h = 0.2.
Solution
For n = 0 and h = 0.2, we have
x0 = 0.4, y0 = 0.41,
K1 = hf (x0, y0) = 0.2 (0.4 + 0.41)1/2 = 0.18,
FG h 1IJ L 1 OP 1/ 2
H
K2 = hf x0 +
2 2 K MN
, y0 + K 1 = 0.2 0.4 + 0.1 + 0.41 + (0.18)
2 Q = 0.2,
F
= hf G x
h I L O
+ K J = 0.2 M0.4 + 0.1 + 0.41 + (0.2)P
1 1
1/ 2
K3
H 0 +
2
, y0
2 K 2
N 2 Q
= 0.2009975,
K4 = hf (x0 + h, y0 + K3) = 0.2 [0.4 + 0.2 + 0.41 + 0.2009975]1/2
= 0.2200907.
1
y1 = y0 + (K1 + 2K2 + 2K3 + K4)
6
= 0.41 + 0.2003476 = 0.6103476.
For n = 1, x1 = 0.6, and y1 = 0.6103476, we obtain
K1 = 0.2200316, K2 = 0.2383580, K3 = 0.2391256, K4 = 0.2568636,
y2 = 0.6103476 + 0.2386436 = 0.8489913.
Hence, we have y(0.6) ≈ 0.61035, y(0.8) ≈ 0.84899.
5.23 Find the implicit Runge-Kutta method of the form
yn + 1 = yn + W1 K1 + W2 K2,
K1 = hf (yn),
K2 = hf (yn + a(K1 + K2)),
for the initial value problem y′ = f (y), y(t0) = y0.
Obtain the interval of absolute stability for y′ = λ y, λ < 0.
Solution
Expanding K2 in Taylor series, we get
1
K2 = hfn + ha(K1 + K2) fy + ha2 (K1 + K2)2 fyy
2
1
+ ha3 (K1 + K2)3 fyyy + ......
6
where fy = ∂f (xn) / ∂y.
We assume the expression for K2 in the form
K2 = hA1 + h2A2 + h3A3 + ....
Substituting for K2 and equating coefficients of like powers of h, we obtain
A1 = fn,
A2 = 2a fn fy ,
316 Numerical Methods : Problems and Solutions
h2 h3
+fy fn + (f f 2 + fn f y2 )] + O(h4).
2 6 yy n
To determine the three arbitrary constants a, W1 and W2, the necessary equations are
W1 + W2 = 1,
2W2 a = 1 / 2,
2W2 a2 = 1 / 6,
whose solution is a = 1 / 3, W2 = 3 / 4, W1 = 1 / 4.
The implicit Runge-Kutta method becomes
K1 = hf (yn),
FG 1 IJ
K2 = hf yn +H 3 K
(K 1 + K2 ) ,
1
yn + 1 = yn +
(K1 + 3K2).
4
The truncation error is of the form O(h4) and hence, the order of the method is three.
Applying the method to y′ = λ y, λ < 0, we get
K1 = λh yn = h yn,
FG 1 IJ FG y 1 1 IJ
K2 = hλ yn +H 3
(K1 + K2 )
K =h H n +
3 K
h yn + K 2 .
3
Solving for K2, we get
h [1 + (h / 3)]
K2 = yn
1 − (h / 3)
where h = hλ.
Therefore, yn + 1 = yn +
1
h yn +
3h LM 1 + (h / 3) OP y = LM 1 + (2h / 3) + (h 2
/ 6) OP y
4 4 N 1 − (h / 3) Q N 1 − (h / 3)
n
Q n
K2 = hλ (y + K ) = h M y +
L h O L h + (2h / 3) OP y
y P=M
2
n 1
N 1 − (h / 3) Q N 1 − (h / 3) Q
n n n
Therefore, yn + 1 =M
L 1 + (2h / 3) + (h / 6) OP y .
2
N 1 − (h / 3) Q n
Solution
We have f (t, y) = t2 + y2. Therefore,
LMFG t h IJ + FG y
2
K1 IJ OP .
2
MNH K H K PQ
K1 = n + n +
2 2
We obtain the following results.
n=0: h = 0.1, t0 = 1, y0 = 2.
K1 = 0.1 [(1.05)2 + (2 + 0.5 K1)2] = 0.51025 + 0.2 K1 + 0.025 K12.
This is an implicit equation in K1 and can be solved by using the Newton-Raphson method.
We have
F (K1) = 0.51025 – 0.8 K1 + 0.025 K12 ,
F′ (K1) = – 0.8 + 0.05K1.
(0 )
We assume K 1 = h f (t0, y0) = 0.5. Using the Newton-Raphson method
F ( K 1( s) )
K 1( s + 1) = K1(s) – , s = 0, 1, ......
F ′ ( K 1( s) )
We obtain K 1( 1) = 0.650322, K 1(2) = 0.651059, K 1(3) = 0.651059.
Therefore, K1 ≈ K 1(3) = 0.651059 and y(1.1) ≈ y1 = 2.651059.
n=1: h = 0.1, t1 = 1.1, y1 = 2.65106
K1 = 0.1[(1.15)2 + (2.65106 + 0.5 K1)2]
= 0.835062 + 0.265106 K1 + 0.025 K 12
1 1
We have F ′(K1) = 1 + h (2tj + h) (uj + K ) = 1 + 0.2 (2tj + 0.2) (uj + K1).
2 1 2
The Newton-Raphson method gives
( s)
K 1( s + 1) = K 1(s) – F ( K 1 ) , s = 0, 1, ......
F ′ ( K 1( s) )
F ( K 1( 2) ) = 0.30 × 10–8.
Multistep Methods
5.27 Find the solution at x = 0.3 for the differential equation
y′ = x – y2 , y(0) = 1
by the Adams-Bashforth method of order two with h = 0.1. Determine the starting val-
ues using a second order Runge-Kutta method.
Solution
The second order Adams-Bashforth method is
h
yn + 1 = yn + ( 3 yn′ – yn′ − 1 ), n = 1, 2, .....
2
We need the value of y(x) at x = x1 for starting the computation. This value is deter-
mined with the help of the second order Runge-Kutta method
1
yn + 1 = yn + (K + K2),
2 1
......................................................................................
One of the most useful tools of applied mathematics is differential equation, it may
be ordinary differential equation (ODE) or partial differential equation (PDE). Both
ODE and PDE are widely used to model lots of mathematical and engineering problems.
Unfortunately, it is not possible to find analytical solution of all ODEs or PDEs. Finding
of analytic solution of an ODE or a PDE is a very difficult task. But, several numerical
techniques are available to solve ODEs and PDEs.
Let us consider the following first order differential equation
dy
= f (x, y) (1.1)
dx
with initial condition
y(x0 ) = y0 . (1.2)
If the analytic solution of an ODE is not available then we will go for numerical
solution. The numerical solution of a differential equation can be determined in one of
the following two forms:
(i) A power series solution for y in terms of x. Then the values of y can be obtained
by substituting x = x0 , x1 , . . . , xn .
A finite difference method is convergent if the solution of the finite difference equa-
tion approaches to a limit as the size of the grid spacing tends to zero. But, in general,
there is no guarantee, that this limit corresponds to the exact solution of the differential
equation.
Mainly, two types of numerical methods are used, viz. explicit method and implicit
method. If the value of yi+1 depends only on the values of yi , h and f (xi , yi ) then the
method is called explicit method, otherwise the method is called implicit method.
In this chapter, we discuss some useful methods to solve ODEs.
y1 = y0 + hf (x0 , y0 ). (1.5)
In general,
yn+1 = yn + hf (xn , yn ), n = 0, 1, 2, . . . (1.6)
This is a very slow method. To find a reasonable accurate solution, the value of
h must be taken as small. The Euler’s method is less efficient in practical problems
because if h is not sufficiently small then this method gives inaccurate result.
This method is modified to get more better result as follows:
The value of y1 obtained by Euler’s method is repeatedly modified to get a more
accurate result. For this purpose, the term f (x0 , y0 ) is replaced by the average of
(0) (0)
f (x0 , y0 ) and f (x0 + h, y1 ), where y1 = y0 + hf (x0 , y0 ).
2
1.1. Euler’s method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
(1) h (0)
y1 = y0 + [f (x0 , y0 ) + f (x1 , y1 )] (1.7)
2
(0)
where y1 = y0 + hf (x0 , y0 ).
Note that the value of y1 depends on the value of y1 obtained in previous iteration.
So this method is known as implicit method, whereas Euler method is explicit method.
Other simple methods, viz. Taylor’s series, Picard, Runge-Kutta, etc. are also avail-
able to solve the differential equation of the form (1.1).
Now, we describe Runge-Kutta method. In this method, several function evaluations
are required at each step and it avoids the computation of higher order derivatives.
There are several types of Runge-Kutta methods, such as second, third, fourth, fifth,
etc. order. The fourth-order Runge-Kutta method is more popular. These are single-
step explicit methods.
First we deduce second order Runge-Kutta method from modified Euler’s method.
The modified Euler’s method is
h (0)
y1 = y0 + [f (x0 , y0 ) + f (x1 , y1 )] (1.8)
2
(0)
where y1 = y0 + hf (x0 , y0 ).
(0)
Now, we substitute the value of y1 to the equation (1.8). Then
h
y1 = y0 + [f (x0 , y0 ) + f (x0 + h, y0 + hf (x0 , y0 ))].
2
Let
k1 = hf (x0 , y0 ) and
k2 = hf (x0 + h, y0 + hf (x0 , y0 )) = hf (x0 + h, y0 + k1 ). (1.9)
1
y1 = y0 + (k1 + k2 ). (1.10)
2
3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Runge-Kutta Methods
dy
= f (x, y), y(x0 ) = y0 (1.11)
dx
is of the following form:
where
k1 = hf (x0 , y0 ) and
k2 = hf (x0 + αh, y0 + βk1 ), a, b, α and β are constants.
By Taylor’s theorem
h2 h3
y1 = y(x0 + h) = y0 + hy00 + y000 + y0000 + · · ·
2 6
h 2 h ∂f ∂f i
= y0 + hf (x0 , y0 ) + + f (x0 , y0 ) + O(h3 )
2 ∂x (x0 ,y0 ) ∂y (x0 ,y0 )
df ∂f ∂f
since = + f (x, y)
dx ∂x ∂y
k2 = hf (x0 + αh, y0 + βk1 )
h ∂f ∂f i
= h f (x0 , y0 ) + αh + βk1 + O(h2 )
∂x (x0 ,y0 ) ∂y (x0 ,y0 )
∂f ∂f
= hf (x0 , y0 ) + αh2 + βh2 f (x0 , y0 ) + O(h3 ).
∂x (x0 ,y0 ) ∂y (x0 ,y0 )
h2
y0 + hf (x0 , y0 ) + [fx (x0 , y0 ) + f (x0 , y0 )fy (x0 , y0 )] + O(h3 )
2
= y0 + (a + b)hf (x0 , y0 ) + bh2 [αfx (x0 , y0 ) + βf (x0 , y0 )fy (x0 , y0 )] + O(h3 ).
4
1.1. Euler’s method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Equating the coefficients of f , fx and fy both sides we get the following equations.
1 1
a + b = 1, bα = and bβ = . (1.13)
2 2
Obviously, α = β. Here, number of equations is three and variables is four. Therefore,
the system of equations has many solutions. However, usually the parameters are chosen
1
as α = β = 1, then a = b = .
2
For this set of parameters, the equation (1.12) becomes
1
y1 = y0 + (k1 + k2 ) + O(h3 ), (1.14)
2
where k1 = hf (x0 , y0 ) and k2 = hf (x0 + h, y0 + k1 ). (1.15)
k1 = hf (x0 , y0 )
k2 = hf (x0 + h/2, y0 + k1 /2)
k3 = hf (x0 + h/2, y0 + k2 /2)
k4 = hf (x0 + h, y0 + k3 ).
k1 = hf (x1 , y1 )
k2 = hf (x1 + h/2, y1 + k1 /2)
k3 = hf (x1 + h/2, y1 + k2 /2)
k4 = hf (x1 + h, y1 + k3 ).
5
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Runge-Kutta Methods
for i = 0, 1, 2, . . ..
Example 1.1 Given y 0 = x − y 2 with x = 0, y = 1. Find y(0.2) by second and fourth-
order Runge-Kutta methods.
Now, we calculate,
1
y1 = y(0.1) = y(0) + (k1 + k2 )
2
= 1 + 0.5 × (−0.1 − 0.071) = 0.91450.
Therefore,
1
y2 = y(0.2) = y(0.1) + (k1 + k2 )
2
= 0.91450 + 0.5 × (−0.07363 − 0.05071) = 0.85233.
6
1.1. Euler’s method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Therefore,
1
y2 = y(0.2) = y(0) + (k1 + 2k2 + 2k3 + k4 )
6
1
= 0.91379 + [−0.07350 + 2 × {(−0.06192) + (−0.06294)} − 0.05239]
6
= 0.85119.
7
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Runge-Kutta Methods
Note 1.1 The fourth order Runge-Kutta method gives better result, though, this method
has some disadvantages. In this method, a lot of function calculations are required.
Thus, if the function f (x, y) is complicated, then the Runge-Kutta method is very labo-
rious.
(h/2) h 4(k2 + k3 ) i
y1 = y0 + k1 + + k4 .
3 2
This form is similar to the Simpson’s 1/3 formula with step size h/2. Thus, the local
h5 iv
truncation error of this formula is − y (c1 ), i.e. of O(h5 ). After n steps, the
2880
accumulated error is
n
X h5 iv xn − x0 iv
− y (ci ) = − y (c)h4 = O(h4 ).
2880 5760
i=1
The second and fourth-order Runge-Kutta methods can also used to solve a pair of
first order differential equations.
Let us consider a pair of first-order differential equations
dy
= f (x, y, z)
dx
(1.19)
dz
= g(x, y, z)
dx
with initial conditions
Here, x is the independent variable and y, z are the dependent variables. So, in this
problem we have to determine the values of y, z for different values of x.
8
1.1. Euler’s method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
The fourth-order Runge-Kutta method to find the values of yi and zi for x = xi from
a pair of equations is
1 (i) (i) (i) (i)
yi+1 = yi + [k1 + 2k2 + 2k3 + k4 ],
6
1 (i) (i) (i) (i)
zi+1 = zi + [l1 + 2l2 + 2l3 + l4 ], (1.21)
6
(i)
where k1 = hf (xi , yi , zi )
(i)
l1 = hg(xi , yi , zi )
(i) (i) (i)
k2 = hf (xi + h/2, yi + k1 /2, zi + l1 /2)
(i) (i) (i)
l2 = hg(xi + h/2, yi + k1 /2, zi + l1 /2)
(i) (i) (i) (1.22)
k3 = hf (xi + h/2, yi + k2 /2, zi + l2 /2)
(i) (i) (i)
l3 = hg(xi + h/2, yi + k2 /2, zi + l2 /2)
(i) (i) (i)
k4 = hf (xi + h, yi + k3 , zi + l3 )
(i) (i) (i)
l4 = hg(xi + h, yi + k3 , zi + l3 ).
Hence,
1
y(0.2) = y1 = y(0) + [k1 + 2(k2 + k3 ) + k4 ]
6
1
= 1 + [0 + 2(0.02 + 0.0202) + 0.0408] = 1.0202.
6
1
z(0.2) = z1 = z(0) + [l1 + 2(l2 + l3 ) + l4 ]
6
1
= 0 + [0.2 + 2(0.2020 + 0.20402) + 0.21220] = 0.20404.
6
The above method can be extended to solve a system of first order differential equa-
tions. Let us consider the following system of first order differential equations
dy1
= f1 (x, y1 , y2 , . . . , yn )
dx
dy2
= f2 (x, y1 , y2 , . . . , yn ) (1.23)
dx
··· ··················
dyn
= fn (x, y1 , y2 , . . . , yn )
dx
with initial conditions
and
for i = 1, 2, . . . , n.
Here, ykj is the value of the variable yk evaluated at xj .
The Runge-Kutta methods can be used to solve second order IVP by converting the
IVP to a pair of first order differential equations.
Let the second order differential equation be
This is a pair of first order differential equations. Now, Runge-Kutta methods may
be used to solve this pair of equations (1.31) with initial conditions (1.32). The value
of y is the solution of the given IVP and z is the first order derivatives.
11
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Runge-Kutta Methods
Example 1.3 Find the value of y(0.1) for the following second order differential equa-
tion by fourth-order Runge-Kutta method.
k1 = h × z0 = 0.1 × 0 = 0
l1 = hg(x0 , y0 , z0 ) = 0.1 × [(2 × 0) − 1 + 0 + 1] = 0
k2 = h × (z0 + l1 /2) = 0.1 × 0 = 0
0 0.1
l2 = hg(x0 + h/2, y0 + k1 /2, z0 + l1 /2) = 0.1 × [(2 × 0) − (1 + ) + (0 + ) + 1]
2 2
= 0.1 × [−1 + 0.05 + 1] = 0.005
0.005
k3 = h × (z0 + l2 /2) = 0.1 × = 0.00025
2
l3 = hg(x0 + h/2, y0 + k2 /2, z0 + l2 /2)
= 0.1 × [0.005 − 1 + 0.05 + 1] = 0.0055
k4 = h × (z0 + l3 ) = 0.1 × 0.0055 = 0.00055
l4 = hg(x0 + h, y0 + k3 , z0 + l3 )
= 0.1 × [{2 × (0 + 0.0055)} − (1 + 0.00025) + (0 + 0.1) + 1] = 0.011075.
Therefore,
y(0.1) = y1
1
= y0 + [k1 + 2(k2 + k3 ) + k4 ]
6
1
= 1 + [0 + 2(0 + 0.00025) + 0.00055] = 1.000175
6
0 1
z(0) = y (0.1) = z(0) + [l1 + 2(l2 + l3 ) + l4 ]
6
1
= 0 + [0 + 2(0.005 + 0.0055) + 0.011075] = 0.005346.
6
The required value of y(0.1) is 1.000175. In addition, y 0 (0.1) is 0.005346.
12