Runge-Kutta order - Mid-Point method
The Euler and Mid-Point
methods of order and
respectively.
This can be seen via a Taylor
series expansion of the solution of the differential
equation. Let the equation be
The Mid-Point method takes into account of the next term in the
series. This requires knowing
.
For simplicity in the derivation, let us assume that
depends only on
. Then
Calculating could be complicated and expensive. Instead this
term can be approximated in terms of a Taylor series expansion
of
and substituted in the original expansion yielding
error of order
. Use
The Runge-Kutta of second order yields the four steps we previously deduced from an analogy with the symmetric form of the finite difference formula for the first derivative of a function on a grid:
Predictor-Corrector Improved Euler revisited
Predictor-Corrector Improved Euler is of the same order as the Mid-Point method. Its derivation in terms of a Taylor series expansion illustrates this fact. It also shows that different methods result from different choice in canceling higher order terms.
Runge-Kutta order
Higher order terms in the Taylor series expansion can be
included in the method of solution. The most popular
extension of the Runge-Kutta of order 2 is the one of order 4.
This method of solution only neglects terms of order
in each time step. The formula in this case corresponds to the
following steps:
The Runge-Kutta order time step
approach is illustrated in the following figure.
The C implementation of a Runge-Kutta order time
step is a generalization of our previous time step general functions
(e.g., Euler and Mid-Point time step functions):
rk4_step.c
The C implementation of a Runge-Kutta order time
step with a rhs function pointer is given in:
rk4_step_pointer.c
Numerical Recipes says: For many scientific users, fourth-order Runge-Kutta is not just the first word on ODE integrators, but the last word as well.
Exercise: Solve the Harmonic Oscillator using the
Runge-Kutta order integrator. Vary the time
step and compare the results to the Euler and Mid-Point solutions.