The

Runge-Kutta method for integrating an

ODE dy/dx = f(x,y) is derived by assuming the general form

y_{n+1} = y_{n} + ak_{1} + bk_{2} + ...

where

k_{1} = h f(x_{n}, y_{n})

k_{2} = h f(x_{n}+alpha*h, y_{n}+beta*k_{1})

etc. and h is the step size

and substituting in

Taylor expansions to find coefficients (a, b, ..., alpha, beta, ...) that will cancel out error terms.

The most popular RK method is the 4th order Runge Kutta where

y_{n+1} = y_{n} + (k_{1} + 2k_{2} + 2k_{3} + k_{4})/6

k_{1} = h f(x_{n}, y_{n})

k_{2} = h f(x_{n}+h/2, y_{n}+k_{1}/2)

k_{3} = h f(x_{n}+h/2, y_{n}+k_{2}/2)

k_{4} = h f(x_{n}+h, y_{n}+k_{3})

The 4th order Runge-Kutta has

local truncation error of order O(h

^{5}), giving total

error of order O(h

^{4}). It is fairly

stable,

self-priming, and simple to implement, making it popular for quick-n-dirty applications. Generally Runge-Kutta is used with an

adaptive step size algorithm to control the error.