Runge-Kutta RK4 Method

As we know, Taylor’s series is a numerical method used for solving differential equations and is limited by the work to be done in finding the derivatives of the higher-order. To overcome this, we can use a new category of numerical methods called Runge-Kutta methods to solve differential equations. These will give us higher accuracy without performing more calculations. These methods coordinate with the solution of Taylor’s series up to the term in hr, where r varies from method to method, representing the order of that method. One of the most significant advantages of Runge-Kutaa formulae is that it requires the function’s values at some specified points.

Before learning about the Runge-Kutta RK4 method, let’s have a look at the formulas of the first, second and third-order Runge-Kutta methods.

Consider an ordinary differential equation of the form dy/dx = f(x, y) with initial condition y(x0) = y0. For this, we can define the formulas for Runge-Kutta methods as follows.

1st Order Runge-Kutta method

y1 = y0 + hf(x0, y0) = y0 + hy’0 {since y’ = f(x, y)}

This formula is same as the Euler’s method

2nd Order Runge-Kutta method

y1 = y0 + (½) (k1 + k2)

Here,

k1 = hf(x0, y0)

k2 = hf(x0 + h, y0 + k1)

3rd Order Runge-Kutta method

y1 = y0 + (â…™) (k1 + 4k2 + k3)

Here,

k1 = hf(x0, y0)

k2 = hf[x0 + (½)h, y0 + (½)k1]

k3 = hf(x0 + h, y0 + k1) such that k1 = hf(x0 + h, y0 + k1)

What is Fourth Order RK Method?

The most commonly used Runge Kutta method to find the solution of a differential equation is the RK4 method, i.e., the fourth-order Runge-Kutta method. The Runge-Kutta method provides the approximate value of y for a given point x. Only the first order ODEs can be solved using the Runge Kutta RK4 method.

Runge-Kutta Fourth Order Method Formula

The formula for the fourth-order Runge-Kutta method is given by:

y1 = y0 + (â…™) (k1 + 2k2 + 2k3 + k4)

Here,

k1 = hf(x0, y0)

k2 = hf[x0 + (½)h, y0 + (½)k1]

k3 = hf[x0 + (½)h, y0 + (½)k2]

k4 = hf(x0 + h, y0 + k3)

Read more:

Runge-Kutta RK4 Method Solved Examples

Example 1:

Consider an ordinary differential equation dy/dx = x2 + y2, y(1) = 1.2. Find y(1.05) using the fourth order Runge-Kutta method.

Solution:

Given,

dy/dx = x2 + y2, y(1) = 1.2

So, f(x, y) = x2 + y2

x0 = 1 and y0 = 1.2

Also, h = 0.05

Let us calculate the values of k1, k2, k3 and k4.

k1 = hf(x0, y0)

= (0.05) [x02 + y02]

= (0.05) [(1)2 + (1.2)2]

= (0.05) (1 + 1.44)

= (0.05)(2.44)

= 0.122

k2 = hf[x0 + (½)h, y0 + (½)k1]

= (0.05) [f(1 + 0.025, 1.2 + 0.061)] {since h/2 = 0.05/2 = 0.025 and k1/2 = 0.122/2 = 0.061}

= (0.05) [f(1.025, 1.261)]

= (0.05) [(1.025)2 + (1.261)2]

= (0.05) (1.051 + 1.590)

= (0.05)(2.641)

= 0.1320

k3 = hf[x0 + (½)h, y0 + (½)k2]

= (0.05) [f(1 + 0.025, 1.2 + 0.066)] {since h/2 = 0.05/2 = 0.025 and k2/2 = 0.132/2 = 0.066}

= (0.05) [f(1.025, 1.266)]

= (0.05) [(1.025)2 + (1.266)2]

= (0.05) (1.051 + 1.602)

= (0.05)(2.653)

= 0.1326

k4 = hf(x0 + h, y0 + k3)

= (0.05) [f(1 + 0.05, 1.2 + 0.1326)]

= (0.05) [f(1.05, 1.3326)]

= (0.05) [(1.05)2 + (1.3326)2]

= (0.05) (1.1025 + 1.7758)

= (0.05)(2.8783)

= 0.1439

By RK4 method, we have;

y1 = y0 + (â…™) (k1 + 2k2 + 2k3 + k4)

y1 = y(1.05) = y0 + (â…™) (k1 + 2k2 + 2k3 + k4)

By substituting the values of y0, k1, k2, k3 and k4, we get;

y(1.05) = 1.2 + (â…™) [0.122 + 2(0.1320) + 2(0.1326) + 0.1439]

= 1.2 + (â…™) (0.122 + 0.264 + 0.2652 + 0.1439)

= 1.2 + (â…™) (0.7951)

= 1.2 + 0.1325

= 1.3325

Example 2:

Find the value of k1 by Runge-Kutta method of fourth order if dy/dx = 2x + 3y2 and y(0.1) = 1.1165, h = 0.1.

Solution:

Given,

dy/dx = 2x + 3y2 and y(0.1) = 1.1165, h = 0.1

So, f(x, y) = 2x + 3y2

x0 = 0.1, y0 = 1.1165

By Runge-Kutta method of fourth order , we have

k1 = hf(x0, y0)

= (0.1) f(0.1, 1.1165)

= (0.1) [2(0.1) + 3(1.1165)2]

= (0.1) [0.2 + 3(1.2465)]

= (0.1)(0.2 + 3.7395)

= (0.1)(3.9395)

= 0.39395

Runge-Kutta RK4 Method Problems

  1. Using the Runge-Kutta method of order 4, find y(0.2) if dy/dx = (y – x)/(y + x), y(0) = 1 and h = 0.2.
  2. Find the value of y(0.3) from the differential equation dy/dx = 3ex + 2y; y(0) = 0, h = 0.3 by the fourth order Runge-Kutta method.
  3. Using RK4 method to find y(0.2) and y(0.4) if dy/dx = 1 + y + x2; y(0) = 0.5

Frequently Asked Questions on Runge-Kutta RK4 Method

Q1

What is the formula of the Runge-Kutta fourth order method?

The formula of the Runge-Kutta fourth order method is given as:

y1 = y0 + (â…™) (k1 + 2k2 + 2k3 + k4)

Q2

What order is RK4?

The name RK4 itself indicates that it is the fourth order Runge-Kutta method. That means, the order is 4.
Q3

How many gradient evaluations are required for each iteration of a fourth-order Runge Kutta algorithm?

Four gradient evaluations are required for each iteration of a fourth-order Runge Kutta algorithm.

Comments

Leave a Comment

Your Mobile number and Email id will not be published.

*

*