rk4_step

View page source

A Fourth Runge-Kutta ODE Step

Problem

Given \(f : \B{R}^n \rightarrow \B{R}^n\) , \(y(0) = y_0 \in \B{R}^n\) , and \(y^{(1)} (t) = f( y(t) )\) for all \(t\) . Approximate \(y(h)\) for some \(h \neq 0\) .

Method

The following algorithm computes the approximation \(y^1 = y(h) + O( h^5 )\) where \(O( h^5 )\) means that the error in the approximation is order \(h\) to the fifth power.

\[\begin{split}k_1 & = f \left( y_0 \right) \\ k_2 & = f \left( y_0 + \frac{h}{2} k_1 \right) \\ k_3 & = f \left( y_0 + \frac{h}{2} k_2 \right) \\ k_4 & = f \left( y_0 + h k_3 \right) \\ y_1 & = y_0 + \frac{h}{6} \left( k_1 + 2 k_2 + 2 k_3 + k_4 \right)\end{split}\]