RK4 (and RK3) Schemes
Equations
RK4 — four slope samples, Simpson-weighted:
RK3 — three samples:
Physical meaning
Numerical quadrature applied to slopes: probe the derivative at the start, middle (twice), and end of the step, then average with Simpson-like weights so the Taylor errors cancel through 4th (3rd) order. See the Runge–Kutta concept page for the family logic.
Variables
\(h = \Delta t\) — step size · \(k_i\) — stage slopes (note RK4's \(k_i\) include the \(h\) factor as written; RK3's do not — follow one convention in code!).
Properties
| RK3 | RK4 | |
|---|---|---|
| Global error | \(\mathcal{O}(h^3)\) | \(\mathcal{O}(h^4)\) |
| Evaluations/step | 3 | 4 |
| Halving \(h\) divides error by | 8 | 16 |
| Symplectic? | no | no |
Applications & limitations
The default for smooth, non-Hamiltonian ODEs and moderate horizons: benchmark trajectories, Rutherford scattering, field-line tracing (also the streamline tracer in the fluids potential-flow widget). For long-time orbital dynamics, its non-symplectic energy drift loses to leapfrog; for stiff systems, explicit RK stability limits bite — use implicit methods.
Related equations
- Leapfrog update — conservation-first alternative
- CFL condition — the analogous stability constraint for PDEs
Quiz
Q1 (computational). One RK4 step for \(\dot y = y\), \(y_0 = 1\), \(h = 1\): compute \(y_1\) and compare with \(e = 2.71828\).
Answer
\(k_1 = 1\), \(k_2 = 1.5\), \(k_3 = 1.75\), \(k_4 = 2.75\); \(y_1 = 1 + (1 + 3 + 3.5 + 2.75)/6 = 1 + 10.25/6 = 2.7083\). Error 0.01 with a huge step — that's 4th order for you.
Q2 (MCQ). RK4's four stages per step mean that at equal cost, comparing with forward Euler at step \(h/4\), RK4's error advantage is roughly a factor of:
- (a) 4 (b) \(h\) (c) \(h^{-3}/64\)... hard to say without \(h\) (d) none
Answer
(c) — the honest answer: Euler at \(h/4\) has error \(\mathcal{O}(h/4)\), RK4 has \(\mathcal{O}(h^4)\); the ratio \(\sim h^3/4^{-1}\) depends on \(h\), overwhelmingly favoring RK4 once \(h\) is small. Order comparisons must be made at stated cost and step size.