A7 Differential equations 571
This is called themidpoint rule. The fact that the error is of orderh^3 can be verified
by expandingx(t)in a power series intto second order. One can systematically
derive similar rules for higher orders. The most popular one is the fourth order rule:
k 1 =hf(x,0)
k 2 =hf
(
x+
1
2
k 1 ,h/ 2
)
k 3 =hf
(
x+
1
2
k 2 ,h/ 2
)
k 4 =hf(x+k 3 ,h)
x(h)=x( 0 )+
1
6
(k 1 + 2 k 2 + 2 k 3 +k 4 )+O(h^5 ). (A.38)
We shall not present a derivation of this rule, because it involves some tedious
algebra. Although the name ‘Runge–Kutta method’ is used for the method for
arbitrary order, it is usually reserved for the fourth order version.
The Runge–Kutta method owes its popularity mostly to the possibility of using
a variable discretisation step: at every step, one can decide to use a different time
interval without difficulty. A severe disadvantage for some applications is the fact
that the functionf(x,t)has to be evaluated four times per integration step. Espe-
cially when integrating Newton’s equations for many-particle systems, as is done
in molecular dynamics, the force evaluations demand a major part of the com-
puter time, and the Runge–Kutta method with its large number of force evaluations
becomes therefore very inefficient.^1
It is possible to implement the Runge–Kutta method with a prescribed maximum
error,δ, to the resulting solution, by adapting the step size automatically. In this
method the fact that the Runge–Kutta rule has an orderh^5 error is used to predict for
which time step the desired accuracy will be achieved. For each time stept, the value
ofxat timet+his calculated twice, first using a time intervalhand then using two
intervals, each of lengthh/2. By comparing the two results, it is possible to estimate
the time step needed to determine the resulting value with the prescribed precision
δ. If the absolute value of the difference between the two results is equal to, the
new time steph′is given byh′=( 15 / 16 )h(δ/)^1 /^5 , as can easily be verified. It
is recommended to use the Runge–Kutta rule only in this implementation, because
when using a constant time step the user gets no warning whatsoever about this
step being too large (for example when the functionfis varying strongly) and the
solution may deviate appreciably from the exact one without this being noticed.
(^1) The fact that Runge–Kutta methods are not symplectic is another reason why they are not suitable for this
application – see Chapter 8.