Differential Equations - Runge Kutta Method

About the Runge-Kutta Method

This is an interactive tool to explore the numerical Runge Kutta method. This method is used to approximate solutions to differential equations and is very powerful for solving a wide range of problems in science and engineering.

Consider the differential equation:

y' = f(x, y) with y(x₀) = K (initial value)

We wish to approximate the solution over an interval [a, b]. We divide this interval into n smaller intervals of size h. The 4th order Runge Kutta method provides an approximation as follows:

Let y₀ = K (starting value)
yᵢ₊₁ = yᵢ + (1/6)[k₁ + 2k₂ + 2k₃ + k₄] for i = 0, 1, ..., n-1

where:
k₁ = h·f(xᵢ, yᵢ)
k₂ = h·f(xᵢ + h/2, yᵢ + k₁/2)
k₃ = h·f(xᵢ + h/2, yᵢ + k₂/2)
k₄ = h·f(xᵢ + h, yᵢ + k₃)

The local truncation error is of the order O(h⁵) and in principle decreases as h decreases.

Equations Used in This Demo

Tutorial

All differential equations in this demo have the same initial value y(0) = 1 and exact solutions for comparison.

  1. Select the first differential equation y' = x². At the start, h = 1.25 and n = 8.
  2. Examine the exact (blue curve) and approximate (red points) solutions on the graph.
  3. Decrease h by increasing n (or decrease h directly) and observe how the approximation improves.
  4. Select the other differential equations and analyze the results.
  5. Compare the exact and approximate values in the table below the graph.

Runge-Kutta Calculator

Your browser does not support the HTML5 canvas element.

Results

Comparison between exact solution and Runge-Kutta approximation:

Step (i) xᵢ Approximate yᵢ Exact y(xᵢ) Error k₁ k₂ k₃ k₄

Additional Resources

More references on differential equations:

Introduction to Differential Equations