RUNGE-KUTTA (RK) METHODS
CONNECTION OF RK METHODS TO EULER’S METHOD
In our previous lecture, we explored Euler's Method, which is one of the simplest
numerical techniques for solving initial value problems (IVPs) in ordinary differential
equations (ODEs). While it is easy to implement, we observed that Euler's method
has limitations in terms of accuracy and error, especially for larger step sizes or when
solving complex problems.
To overcome these challenges, mathematicians developed Runge-Kutta (RK)
Methods, which improve accuracy without significantly increasing computational
effort. These methods build upon the idea of step-wise approximation from Euler's
method but incorporate additional evaluations of the function to refine the solution.
For instance, the RK-2 method, often considered a modified version of Euler's
method, calculates an intermediate slope to approximate the solution more accurately.
This intermediate step reduces the local truncation error and enhances the overall
stability of the method.
Application in IT/CS
To understand the significance of Runge-
Kutta methods, consider their application in Using Euler's method for such a problem
predicting the trajectory of a satellite. The might result in significant errors, causing the
motion of a satellite is governed by Newton's predicted trajectory to deviate from the actual
laws, expressed as a system of differential one. In contrast, Runge-Kutta methods, such
equations. These equations describe how the as RK-2 or RK-4, provide more accurate
satellite's position and velocity change over results with the same step size, making them
time under the influence of gravitational ideal for space mission simulations.
forces.
RK METHOD OF ORDER 2
MATHEMATICAL REPRESENTATION
RK- method of order 2 is actually a different form of Modified Euler method. Since RK-
2 and Modified Euler methods are almost same, we will use only one of them that is RK-
2 method. That is for IVP
𝑑𝑦
= 𝑓(𝑥, 𝑦) , 𝑦(𝑥0 ) = 𝑦0
𝑑𝑥
Then RK-2 method is given by
1
𝑦𝑖+1 = 𝑦𝑖 + [𝑘1 + 𝑘2 ], 𝑖 = 0, 1, 2, …
2
where
𝑘1 = ℎ𝑓(𝑥𝑖 , 𝑦𝑖 ), and 𝑘2 = ℎ𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘1 )
EXAMPLES
Qs. Solve the initial value problem 𝑦 𝑦 ′ = 𝑥, 𝑦(0) = 1, using the RK-2 method in 0 ≤
𝑥 ≤ 0.8, with ℎ = 0.2. If the exact solution of the differential equation is y = √(𝑥 2 +
1). Compare the result with the exact solution at 𝑥 = 0.8.
Solution
We know that the RK-2 method is given by
1
𝑦𝑖+1 = 𝑦𝑖 + [𝑘1 + 𝑘2 ], 𝑖 = 0,1,2, …
2
where
𝑘1 = ℎ𝑓(𝑥𝑖 , 𝑦𝑖 ) and 𝑘2 = ℎ𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘1 )
𝑥 𝑥𝑛 −𝑥0
Here 𝑓(𝑥, 𝑦) = , 𝑦(0) = 1 implies 𝑥0 = 0, 𝑦0 = 1, and 𝑛 = =4
𝑦 ℎ
𝑥𝑖
So 𝑘1 = ℎ𝑓(𝑥𝑖 , 𝑦𝑖 ) = 0.2
𝑦𝑖
𝑥𝑖 +ℎ
and 𝑘2 = ℎ𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑘1 ) = 0.2
𝑦𝑖 +𝑘1
𝑥0 0
Now for 𝒊 = 𝟎, 𝑘1 = ℎ𝑓(𝑥0 , 𝑦0 ) = 0.2 = 0.2 ( ) = 0,
𝑦0 1
𝑥0 +ℎ 0+0.2
𝑘2 = ℎ𝑓(𝑥0 + ℎ, 𝑦0 + 𝑘1 ) = 0.2 ( ) = 0.2 ( 1+0 ) = 0.04
𝑦0 +𝑘1
𝟏 𝟏
𝒚𝟏 = 𝒚𝟎 + [𝒌𝟏 + 𝒌𝟐 ] = 𝟏 + (𝟎 + 𝟎. 𝟎𝟒) = 𝟏. 𝟎𝟐, at 𝑥1 = 0.2
𝟐 𝟐
𝑥1
For 𝒊 = 𝟏, 𝑘1 = ℎ𝑓(𝑥1 , 𝑦1 ) = 0.2 = 0.03922,
𝑦1
𝑥1 +ℎ
𝑘2 = 0.2 ( ) = 0.07553
𝑦1 +𝑘1
𝟏 𝟏
𝒚𝟐 = 𝒚𝟏 + [𝒌𝟏 + 𝒌𝟐 ] = 𝟏. 𝟎𝟐 + (𝟎. 𝟎𝟑𝟗𝟐𝟐 + 𝟎. 𝟎𝟕𝟓𝟓𝟑) = 𝟏. 𝟎𝟕𝟕𝟑𝟕, at 𝑥2 = 0.4
𝟐 𝟐
𝑥2
For 𝒊 = 𝟐, 𝑘1 = 0.2 = 0.07425,
𝑦2
𝑥2 +ℎ
𝑘2 = 0.2 ( ) = 0.10420
𝑦2 +𝑘1
𝟏
𝒚𝟑 = 𝒚𝟐 + [𝒌𝟏 + 𝒌𝟐 ] = 𝟏. 𝟏𝟔𝟔𝟔𝟎, at 𝑥3 = 0.6
𝟐
𝑥3
For 𝒊 = 𝟑, 𝑘1 = 0.2 = 0.10286,
𝑦3
𝑥3 +ℎ
𝑘2 = 0.2 ( ) = 0.12604
𝑦3 +𝑘1
𝟏
𝒚𝟒 = 𝒚𝟑 + [𝒌𝟏 + 𝒌𝟐 ] = 𝟏. 𝟐𝟖𝟏𝟎𝟓, at 𝑥4 = 0.8
𝟐
Since at 𝑥 = 0.8, the exact value is y(0.8) = √(0.82 + 1)=1.28062
Error = |1.28062-1.28105|= 0.00043
We can see that RK-2 method is more accurate than Euler’s method for the same h.
Qs. Use RK-2 method to approximate the solutions for the initial value problem
𝑦 ′ = 𝑡𝑒 3𝑡 − 2y, 𝑦(0) =0, in 0 ≤ 𝑡 ≤ 1, with ℎ = 0.25. If the exact solution of the
1 1 1
differential equation is y(t) = 𝑡𝑒 3𝑡 − 𝑒 3𝑡 + 𝑒 −2𝑡 , find error at 𝑡 =1.
5 25 25
Solution: We know that the RK-2 method is given by
1
𝑦𝑖+1 = 𝑦𝑖 + [𝑘1 + 𝑘2 ], 𝑖 = 0,1,2, …
2
where
𝑘1 = ℎ𝑓(𝑡𝑖 , 𝑦𝑖 ) and 𝑘2 = ℎ𝑓(𝑡𝑖 + ℎ, 𝑦𝑖 + 𝑘1 )
for f(t, y) = 𝑡𝑒 3𝑡 − 2y, 𝑡0 = 0, 𝑦0 = 0
For 𝑖 = 0, 𝑘1 = 0, 𝑘2 = 0.13231,
1
𝑦1 = 𝑦0 + [𝑘1 + 𝑘2 ] = 0.066155, at 𝑡1 = 0.25
2
For 𝑖 = 1, 𝑘1 = 0.099235,
𝑘2 = 0.477516,
1
𝑦2 = 𝑦1 + [𝑘1 + 𝑘2 ] = 0.354531, at 𝑡2 = 0.5
2
For 𝑖 = 2, 𝑘1 = 0.382946,
𝑘2 = 1.410212,
1
𝑦3 = 𝑦2 + [𝑘1 + 𝑘2 ] = 1.251110, at 𝑡3 = 0.75
2
For 𝑖 = 3, 𝑘1 = 1.153395,
𝑘2 = 3.819132,
1
𝑦4 = 𝑦3 + [𝑘1 + 𝑘2 ] = 3.737374 , at 𝑡4 = 1
2
At t = 1, the exact solution is y(1) = 3.21910,
Error = |3.2191-3.73737| = 0.51827
Qs. Use RK-2 method to approximate the solutions for the initial value problem 𝑦 ′ =
1 + y/t, 𝑦(1) = 2, in 1 ≤ 𝑡 ≤ 2, with ℎ = 0.25. Find error if the exact solution of the
differential equation is y(t) = 𝑡 ln 𝑡 + 2𝑡.
Solution: We know that the RK-2 method is given by
1
𝑦𝑖+1 = 𝑦𝑖 + [𝑘1 + 𝑘2 ], 𝑖 = 0,1,2, …
2
where
𝑘1 = ℎ𝑓(𝑡𝑖 , 𝑦𝑖 ) and 𝑘2 = ℎ𝑓(𝑡𝑖 + ℎ, 𝑦𝑖 + 𝑘1 )
𝑦
where 𝑓(𝑡, 𝑦) = 1 + , 𝑡0 = 1, 𝑦0 = 2
𝑡
For 𝑖 = 0, 𝑘1 = 0.75,
𝑘2 = 0.80,
𝟏
𝒚𝟏 = 𝒚𝟎 + [𝒌𝟏 + 𝒌𝟐 ] = 𝟐. 𝟕𝟕𝟓, at 𝑡1 = 1.25
𝟐
For 𝑖 = 1, 𝑘1 = 0.805,
𝑘2 = 0.846667,
𝟏
𝒚𝟐 = 𝒚𝟏 + [𝒌𝟏 + 𝒌𝟐 ] = 𝟑. 𝟔𝟎𝟎𝟖𝟑𝟒, at 𝑡2 = 1.5
𝟐
For 𝑖 = 2, 𝑘1 = 0.850139,
𝑘2 = 0.885853,
𝟏
𝒚𝟑 = 𝒚𝟐 + [𝒌𝟏 + 𝒌𝟐 ] = 𝟒. 𝟒𝟔𝟖𝟖𝟑, at 𝑡3 = 1.75
𝟐
For 𝑖 = 3, 𝑘1 = 0.888404,
𝑘2 = 0.919654,
𝟏
𝒚𝟒 = 𝒚𝟑 + [𝒌𝟏 + 𝒌𝟐 ] = 𝟓. 𝟑𝟕𝟐𝟖59, at 𝑡4 = 2
𝟐
At 𝑡 = 2, exact solution is y(2) = 5.386294,
Therefore, Error = 0.013435
PRACTICE QUESTIONS
Question.
In a satellite trajectory prediction system, the rate of change of a satellite’s angular
velocity is modeled by the differential equation:
y 2⁄
𝑦′ = (1 + t)
where 𝑦(𝑡) represents the angular velocity of the satellite at time 𝑡, and the initial
condition is 𝑦(1) = −(ln 2)−1 .
The system uses the RK-2 method to approximate the solution of this equation for 1 ≤
𝑡 ≤ 2, with a step size of ℎ = 0.1.
a. Use the RK-2 method to approximate the values of angular velocity.
−1
b. If the exact solution of the differential equation is given by y(t) = , find
ln(𝑡+1)
the values of error at 𝑡 = 1.5 and 𝑡 = 2.
Question.
Water flows from an inverted conical tank with circular orifice (opening) at the rate
𝑑𝑥 √𝑥
= −0.6𝜋𝑟 2 √2𝑔
𝑑𝑡 𝐴
where 𝑟 is the radius of the orifice, 𝑥 is the height of the liquid level from the vertex of
the cone,
and 𝐴 is the function of 𝑥 and it represents the area of the cross section of the tank 𝑥
units above the orifice. Suppose 𝑟 = 0.1 𝑓𝑡, 𝑔 = 32.1 𝑓𝑡/𝑠 2 , and the tank has an
1 𝜋
initial water level of 8 𝑓𝑡. The initial volume given by 𝑉 = (𝑥𝐴) is 512( ) 𝑓𝑡 3 .
3 3
a. Use the RK-2 Method to find the water level after 1 𝑚𝑖𝑛 with ℎ = 20 𝑠.
b. Will the tank be empty at any time during the first 1 𝑚𝑖𝑛𝑢𝑡𝑒?