The Runge-Kutta
Method
A powerful numerical technique for solving ordinary differential equations when exact solutions are impossible: step forward with precision.
Why Do We Need Numerical Methods?
Most real-world differential equations of the form \( \frac{dy}{dx} = f(x,y) \) cannot be solved exactly. When integration fails, we turn to numerical approximation: computing \( y \) values step by step across an interval.
Starting Simple: Euler's Method
The simplest numerical method is Euler's method. It approximates the next value by using a single slope evaluation at the current point:
Euler's method is first-order accurate: the error is proportional to \( h \). The Runge-Kutta method improves this dramatically.
The Big Idea Behind Runge-Kutta
Instead of using one slope at the beginning of the interval (like Euler), the 4th-order Runge-Kutta method (RK4) samples the slope at four strategic points within each step and takes a weighted average.
The RK4 Formulas
Visualizing the Four Slopes
Each slope builds on the previous one. The \( k_1 \) slope informs where we evaluate \( k_2 \), which informs \( k_3 \), which informs \( k_4 \). The final value \( y_{n+1} \) is found by adding a weighted average of these increments to \( y_n \): \( y_{n+1} = y_n + \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4) \).
Why the 1-2-2-1 Weighting?
The coefficients in \( \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4) \) are not arbitrary. They come from matching the method's Taylor series expansion to the true solution through fourth-order terms.
Euler vs RK4: Key Differences
| Euler's Method | RK4 | |
|---|---|---|
| Slope evaluations per step | 1 | 4 |
| Order of accuracy | \( O(h) \) | \( O(h^4) \) |
| Local truncation error | \( O(h^2) \) | \( O(h^5) \) |
| Stability | Poor for stiff problems | Much better |
| Computation cost | Low | Moderate (\(4 \times\) Euler) |
| Practical use | Teaching only | Industry standard |
How to Apply RK4
Worked Example: \( \frac{dy}{dx} = y \)
Here \( f(x,y) = y \). The exact solution is \( y = e^x \), so the true answer is \( e^{0.1} \approx 1.1051709 \). Let's see how close RK4 gets in one step.
Example Result: Remarkable Accuracy
With just one step and \( h = 0.1 \), RK4 is accurate to 6 decimal places. Euler's method with the same step gives \( y_1 = 1.1 \), an error of \( 0.00517 \): about \(50,000 \times\) worse.
Example 2: \( \frac{dy}{dx} = x + y \)
Multi-Step Example: Building a Solution Curve
For \( \frac{dy}{dx} = -2xy \) with \( y(0) = 1 \) and \( h = 0.5 \), here are three RK4 steps compared to the exact solution \( y = e^{-x^2} \):
Common Mistakes to Avoid
Summary of Numerical Methods
| Method | Order | Slope Evals | Error / Step |
|---|---|---|---|
| Euler | 1st | 1 | \( O(h^2) \) |
| Improved Euler (Heun) | 2nd | 2 | \( O(h^3) \) |
| Midpoint Method | 2nd | 2 | \( O(h^3) \) |
| RK4 (Classical) | 4th | 4 | \( O(h^5) \) |
Question 1 of 5
In the classical RK4 method, how many slope evaluations of \( f(x,y) \) are performed per step?
Question 2 of 5
What is the global truncation error order of the classical RK4 method?
Question 3 of 5
When computing \( k_3 \) in RK4, at what \( x \)-value is the function \( f \) evaluated?
Question 4 of 5
In the RK4 weighted average \( \frac{1}{6}(k_1 + 2k_2 + 2k_3 + k_4) \), why do \( k_2 \) and \( k_3 \) receive double weight?
Question 5 of 5
If you halve the step size \( h \) in RK4, by approximately what factor does the global error decrease?