Runge-Kutta method (source code)

= Runge-Kutta method
{c}
{wiki}

= RK method
{c}
{synonym}

A Runge-Kutta method advances an <initial value problem> $y'=f(t,y)$, $y(t_0)=y_0$, by sampling its <vector field> at several trial states within one time step. These samples are <Runge-Kutta stages>; a weighted combination of their slopes produces the next state. The construction improves on the single <tangent line> used by the <Euler method> while requiring evaluations of $f$, rather than explicit higher <derivatives> of the solution. It applies to scalar equations and systems of <ordinary differential equations> alike. The coefficient choices distinguish methods such as <Heun's method>, the <classical fourth-order Runge-Kutta method> and <implicit Runge-Kutta methods>.

For $s$ stages, write $A=(a_{ij})$ for the stage <matrix>, $c_i$ for relative time nodes and $b_i$ for output weights. A time step of length $h$ computes
$$
Y_i=y_n+h\sum_{j=1}^s a_{ij}k_j,\qquad k_i=f(t_n+c_i h,Y_i),\qquad y_{n+1}=y_n+h\sum_{i=1}^s b_i k_i.
$$
Here $k_i$ is a slope, with units of state per time; $hk_i$ is a state increment. Another common convention writes $K_i=hk_i$, so its stage states are $Y_i=y_n+\sum_j a_{ij}K_j$ and its output is $y_n+\sum_i b_iK_i$. These are equivalent conventions: including $h$ both inside $K_i$ and again in the output would count the time step twice. The textbook formulation uses the increment convention.<Fundamentals of Numerical Computation by Tobin A. Driscoll and others/6.4 Runge-Kutta methods>[Fundamentals of Numerical Computation, §6.4.3, equations 6.4.10–6.4.11: multistage recipe and tableau]{ref}

Usually the <Butcher tableau> obeys $c_i=\sum_ja_{ij}$, called internal consistency. Stage $i$ then combines slopes over an effective time $c_i h$. The <second-order conditions with independent Runge-Kutta abscissae> explain what changes when time nodes are specified independently. A <Runge-Kutta stage> is generally an auxiliary approximation, not a separate accepted solution value at its node. Several stages can even have the same time node but different state arguments, as in the <classical fourth-order Runge-Kutta method>.

The useful idea is to approximate the <integral> $y(t_n+h)-y(t_n)=\int_{t_n}^{t_n+h}f(t,y(t))\,dt$ without knowing the intermediate exact trajectory. Trial states provide places to sample $f$, and <Butcher order conditions> make the resulting combination agree with the exact <Taylor expansion>. More stages alone do not guarantee a higher <order of a numerical method>: their coefficients must satisfy the appropriate conditions. <Embedded Runge-Kutta pairs> reuse these same samples for a second output and a practical <local error estimator>.