8.6 Runge-Kutta Methods: 8.6.1 Taylor Series of A Function With Two Variables
8.6 Runge-Kutta Methods: 8.6.1 Taylor Series of A Function With Two Variables
in
x′ (t) = f (t, x)
x(2) (t) = ft + fx x′ = ft + fx f
x(3) (t) = ftt + ftx f + (ft + fx f )fx + f (fxt + fxx f )
..
.
Here subscripts denote partial derivatives, and the chain rule of differentiation is used re-
peatedly. Using these derivatives of x, the Taylor series can be can be written as
∆t2
x(t + ∆t) = x + ∆t f + (ft + f fx ) + O(∆t3 )
2
∆t ∆t
= x+ f + (f + ∆t ft + ∆t f fx ) + O(∆t3 )
2 2
∆t ∆t
= x+ f + (f (t + ∆t, x + ∆tf ) + O(∆t2 )) + O(∆t3 )
2 2
∆t ∆t
= x+ f + (f (t + ∆t, x + ∆tf )) + O(∆t3 )
2 2
Lecture Notes MA5470 Numerical Analysis 81
which is equivalent to
1
x(t + ∆t) = x(t) + (K1 + K2 ) where (8.12)
2
K1 = ∆t f (t, x)
K2 = ∆t f (t + ∆t, x + K1 )
where w1 , w2 , α, and β are parameters at our disposal. Comparing (8.13) with the Taylor
series in two variables (8.11) gives
1 1
w1 + w2 = 1, w2 α = , w2 β = (8.15)
2 2
One solution is w1 = w2 = 21 , α = β = 1, which is the Heun’s method. Another solution is
w1 = 0, w2 = 1, α = β = 12 . This is the modified Euler method given by
The summation in the (8.17) is nothing but the weighted average of the function values of
f . Also notice that any Kj involves only up to Kj−1 only, therefore, the general RK method
given by (8.17) are explicit in nature. The general scheme is also can be written as
R
xi+1 = xi + ∑ wj Kj (8.18)
j=1
K1 = ∆t f (t, x)
j−1 j−1
Kj = ∆t f (t + ∆taj , x + ∑ bjk Kk ) , aj = ∑ bjk , j = 2, 3, ⋯, R
k=1 k=1
82 Sanyasiraju V S S Yedida [email protected]
1 1 1
w1 + w2 + w3 = 1, w2 a2 + w3 a3 = , w2 a22 + w3 a23 = , w3 a2 b32 = (8.19)
2 3 6
1
xi+1 = xi + (K1 + 3K3 ) where (8.20)
4
K1 = ∆t f (ti , xi ),
∆t K1
K2 = ∆t f (ti + , x+ )
3 3
2∆t 2K2
K3 = ∆t f (ti + , x+ )
3 3
1
xi+1 = xi + (K1 + 2K2 + 2K3 + K4 ) where (8.21)
6
K1 = ∆t f (ti , xi ),
∆t K1
K2 = ∆t f (ti + , x+ )
2 2
∆t K2
K3 = ∆t f (ti + , x+ )
2 2
K4 = ∆t f (ti + ∆t, x + K3 )
Stage 2 3 4 5 6 7 8
Order 2 3 4 4 5 5 6
2. Use the Runge-Kutta method of order four with ∆t = 0.2, to obtain the numerical
solution of the initial-value problem x′ = xt2 + 1, in the interval 0 ≤ t ≤ 2, x(0) = 0.5.
Solution :
x0 =
0.5
K1 =
0.2 ∗ f (0, 0.5) = 0.2(1.5) = 0.3
K2 =
0.2f (0.1, 0.65) = 0.328
K3 =
0.2f (0.1, 0.664) = 0.3308
K4 =
0.2f (0.2, 0.8308) = 0.35816
1
x1 = 0.5 + (0.3 + 2(0.328) + 2(0.3308) + 0.35816) = 0.8292933
6
The comparison of the numerical and exact solutions along with error is given in the
following Table.
ti Exact RK - 4 Error
0.0 0.5000000 0.5000000 0
0.2 0.8292986 0.8292933 0.0000053
0.4 1.2140877 1.2140762 0.0000114
0.6 1.6489406 1.6489220 0.0000186
0.8 2.1272295 2.1272027 0.0000269
1.0 2.6408591 2.6408227 0.0000364
1.2 3.1799415 3.1798942 0.0000474
1.4 3.7324000 3.7323401 0.0000599
1.6 4.2834838 4.2834095 0.0000743
1.8 4.8151763 4.8150857 0.0000906
2.0 5.3054720 5.3053630 0.0001089
3. Compare the solutions of Euler (with step length ∆t = 0.025), Modified Euler (with
step length ∆t = 0.05) and RK-4 (with step length ∆t = 0.1) solutions of x′ = xt2 + 1,
in the interval 0 ≤ t ≤ .5, x(0) = 0.5.
8.6.7 Problems
1. Use the Modified Euler method to approximate the solutions to each of the following
IVPs, and compare the results to the actual values.
Lecture Notes MA5470 Numerical Analysis 85
(a) x′ = te3t − 2x, 0 ≤ t ≤ 1, x(0) = 0, with ∆t = 0.5; actual solution x(t) = 15 te3t −
−2t .
25 e + 25 e + e
1 3t 1 3t
2. Prove that when the fourth-order Runge-Kutta method is applied to the problem
x′ = λx, the formula for advancing this solution is
hλ h2 λ2 h4 λ4
x(t + h) = (1 + + ++ ) x(t)
2 6 24
3. Use the Runge-Kutta method of order four to approximate the solutions to each of the
following initial-value problems, and compare the results to the actual values.
(a) x′ = 2−2tx
t2 +1 , 0 ≤ t ≤ 1, x(0) = 1, ∆t = 0.2; Exact solution x(t) = 2t+1
t2 +1 .
−1
(b) x′ = x2
t+1 , 0 ≤ t ≤ 2, x(1) = − ln2
1
, ∆t = 0.25; Exact solution x(t) = ln(1+t) .
x2 +x
(c) x′ = t , 0 ≤ t ≤ 3, x(0) = −2, ∆t = 0.5; Exact solution x(t) = 2t
1−2t .
√
(d) x′ = −tx + 4t
x , 0 ≤ t ≤ 1, x(0) = 1, ∆t = 0.2; Exact solution x(t) = 4 − 3e−t .