Review / Part III — Series & Numerical Methods / Ch 17

Runge–Kutta & Stiff ODEs

Ch 17 — Part III — Series & Numerical Methods

Runge–Kutta (RK) methods raise accuracy by evaluating the RHS at multiple clever points within each step. The classical RK4 is fourth-order accurate and widely used.

RK4 formulas

$$k_1 = f(t_n, y_n),\quad k_2 = f(t_n + h/2, y_n + \tfrac{h}{2} k_1),$$ $$k_3 = f(t_n + h/2, y_n + \tfrac{h}{2} k_2),\quad k_4 = f(t_n + h, y_n + h k_3),$$ $$y_{n+1} = y_n + \tfrac{h}{6}(k_1 + 2 k_2 + 2 k_3 + k_4).$$ Global error \(O(h^4)\).

Stiff ODEs

If \(A\) in \(\mathbf{x}' = A\mathbf{x}\) has eigenvalues with vastly different scales (some very negative), explicit methods need tiny steps. Use implicit methods (e.g. backward Euler \(y_{n+1} = y_n + h f(t_{n+1}, y_{n+1})\)) which have larger stability regions.

Adaptive stepping

Modern solvers (e.g. Dormand–Prince RK45 used in \(\mathtt{scipy.integrate.solve\_ivp}\)) compare two embedded RK methods of different orders to estimate error and adjust \(h\).

Practice Problems

Problem 1medium
Compare Euler and RK4 errors for \(y' = y\) with \(h = 0.1\) over \([0,1]\). What's the error ratio roughly?
Hint
Euler \(O(h) = 0.1\), RK4 \(O(h^4) = 10^{-4}\).
Solution

RK4 error is about 1000× smaller, at ~4× the function-evaluation cost per step.

Answer: ~10³ ratio.

Problem 2medium
Write down one step of implicit (backward) Euler for \(y' = -10 y\) starting at \(y_0 = 1\) with \(h = 0.1\).
Hint
\(y_1 = y_0 - 10 h y_1\Rightarrow (1 + 10h) y_1 = 1\).
Solution

\(y_1 = 1/(1 + 1) = 0.5\).

Answer: \(y_1 = 0.5.\)

Problem 3easy
Why is RK4 usually preferred over Euler in practice?
Hint
Same error at much larger step.
Solution

RK4's \(O(h^4)\) accuracy means you can take far bigger steps for the same error tolerance, easily offsetting the ~4× cost per step.

Answer: Far more efficient at equal accuracy.