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:
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:
\( y_{i+1} = y_i + \frac{1}{6}[k_1 + 2k_2 + 2k_3 + k_4] \) for \( i = 0, 1, \dots, n-1 \)
where:
\( k_1 = h \cdot f(x_i, y_i) \)
\( k_2 = h \cdot f(x_i + \frac{h}{2}, y_i + \frac{k_1}{2}) \)
\( k_3 = h \cdot f(x_i + \frac{h}{2}, y_i + \frac{k_2}{2}) \)
\( k_4 = h \cdot f(x_i + h, y_i + k_3) \)
The local truncation error is of the order \( O(h^5) \) and in principle decreases as \( h \) decreases.
Equations Used in This Demo
- \( y' = x^2 \), \( y(0) = 1 \), exact solution: \( y = \frac{x^3}{3} + 1 \)
- \( y' = x^4 \), \( y(0) = 1 \), exact solution: \( y = \frac{x^5}{5} + 1 \)
- \( y' = e^x \), \( y(0) = 1 \), exact solution: \( y = e^x \)
- \( y' = \frac{1}{1+x} \), \( y(0) = 1 \), exact solution: \( y = \ln(1+x) + 1 \)
Tutorial
All differential equations in this demo have the same initial value \( y(0) = 1 \) and exact solutions for comparison.
- Select the first differential equation \( y' = x^2 \). At the start, \( h = 1.25 \) and \( n = 8 \).
- Examine the exact (blue curve) and approximate (red points) solutions on the graph.
- Decrease \( h \) by increasing \( n \) (or decrease \( h \) directly) and observe how the approximation improves.
- Select the other differential equations and analyze the results.
- Compare the exact and approximate values in the table below the graph.
Runge-Kutta Calculator
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: