1. The RK4 Formula
Theorem – Classical Runge–Kutta 4th order
For , :
Interpretation
| Slope | Where it is evaluated | Uses | Weight |
|---|---|---|---|
| start of step | – | 1 | |
| midpoint | 2 | ||
| midpoint (improved) | 2 | ||
| end of step | 1 |
The step uses the weighted average slope . (Extra: the weights over start/middle/end are Simpson’s 1/3 rule from 5.2 applied to the slope.)
flowchart LR K1["k₁ at xᵢ"] --> K2["k₂ at xᵢ + h/2<br/>using k₁"] K2 --> K3["k₃ at xᵢ + h/2<br/>using k₂"] K3 --> K4["k₄ at xᵢ + h<br/>using k₃"] K4 --> Y["yᵢ₊₁ = yᵢ + h(k₁ + 2k₂ + 2k₃ + k₄)/6"]
⚠️ and are evaluated at the same (the midpoint) but with different : uses , uses . And steps a full using , not .
2. Worked Example – Cooling Ball
Example (slides)
⚠️ The slide’s problem statement says “Runge–Kutta 2nd order”; this section is the 4th-order method.
Step 1: ,
| Slope | Evaluated at | Value |
|---|---|---|
Step 2: ,
| Slope | Evaluated at | Value |
|---|---|---|
⚠️ Slide typo in step 2: it writes inside ; it must be the current value (the numbers on the slide do use 675.65).
Exact: K.
3. Effect of Step Size
Table (slides)
| (s) | % | ||
|---|---|---|---|
| 480 | −90.278 | 737.85 | 113.94 |
| 240 | 594.91 | 52.660 | 8.1319 |
| 120 | 646.16 | 1.4122 | 0.21807 |
| 60 | 647.54 | 0.033626 | 0.0051926 |
| 30 | 647.57 | 0.00086900 | 0.00013419 |
Once , each halving of divides the error by ≈ 40 here, much faster than Euler’s ≈ 2 or RK2’s ≈ 4.
4. Comparison of All ODE Methods
, exact K (slides + extra RK4 column)
| (s) | Euler | Heun | Midpoint | Ralston | RK4 |
|---|---|---|---|---|---|
| 480 | −987.84 | −393.87 | 1208.4 | 449.78 | −90.278 |
| 240 | 110.32 | 584.27 | 976.87 | 690.01 | 594.91 |
| 120 | 546.77 | 651.35 | 690.20 | 667.71 | 646.16 |
| 60 | 614.97 | 649.91 | 654.85 | 652.25 | 647.54 |
| 30 | 632.77 | 648.21 | 649.02 | 648.61 | 647.57 |
| Method | Slopes per step | Global error order |
|---|---|---|
| Euler | 1 | |
| RK2 (Heun / Midpoint / Ralston) | 2 | |
| RK4 | 4 |
⚠️ At the very coarse , Ralston (error 42 K) actually beats RK4 (error 53 K). High order guarantees fast improvement as ; it doesn’t guarantee being best at every large . From down, RK4 is by far the most accurate.
⚠️ Cost comparison: RK4 with uses 16 evaluations of and is off by 1.4 K. Euler with uses 16 evaluations too and is off by 14.8 K. For the same work, RK4 is about 10× more accurate here.