Skip to main content

Explicit Methods for ODEs

Computational Math
Error Analysis
Compare Euler, midpoint and RK4 on the same initial value problem.
Author

Apurva Nakade

Published

July 13, 2026

Given \(y' = f(t, y)\), \(y(0) = y_0\), an explicit method computes each \(y_{i+1} \approx y(t_{i+1})\) directly from already-known values, using \(h\) for the step size and \(t_i = t_0 + ih\). Compare Euler’s method (one slope evaluation per step):

\[ y_{i+1} = y_i + h\,f(t_i, y_i), \]

Improved Euler (averages the slope at both endpoints of the step):

\[ \begin{aligned} k_1 &= f(t_i, y_i), \\ k_2 &= f(t_{i+1},\, y_i + h k_1), \\ y_{i+1} &= y_i + \frac{h}{2}(k_1 + k_2), \end{aligned} \]

and RK4 (averages four slope estimates):

\[ \begin{aligned} k_1 &= f(t_i, y_i), \\ k_2 &= f\!\left(t_i + \tfrac{h}{2},\, y_i + \tfrac{h}{2}k_1\right), \\ k_3 &= f\!\left(t_i + \tfrac{h}{2},\, y_i + \tfrac{h}{2}k_2\right), \\ k_4 &= f(t_{i+1},\, y_i + h k_3), \\ y_{i+1} &= y_i + \frac{h}{6}(k_1 + 2k_2 + 2k_3 + k_4). \end{aligned} \]

More evaluations per step buys higher accuracy.

When f depends on t alone

If \(f(t, y) = g(t)\) has no \(y\) in it, solving the ODE is integration: \(y(b) = y_0 + \int_0^b g(t)\,dt\). Each method then becomes a quadrature rule from Numerical Integration, applied on the grid \(t_i\):

What each method does when \(f(t, y) = g(t)\).
Method Adds each step Quadrature rule Error
Euler \(h\,g(t_i)\) Left Riemann sum \(O(h)\)
Improved Euler \(\frac{h}{2}\big(g(t_i) + g(t_{i+1})\big)\) Trapezoidal rule \(O(h^2)\)
RK4 \(\frac{h}{6}\big(g(t_i) + 4g(t_i + \tfrac{h}{2}) + g(t_{i+1})\big)\) Simpson’s rule \(O(h^4)\)

For RK4, \(k_2 = k_3 = g(t_i + \tfrac{h}{2})\), so \(n\) steps of RK4 are Simpson’s rule on \(2n\) subintervals.

For example, the equation \(y' = 4/(1 + t^2)\), \(y(0) = 0\) (try it) has \(y(1) = \pi\), the same number as \(\int_0^1 \frac{4}{1+t^2}\,dt\).

NoteConvergence plots