© 2001 by CRC Press LLC
The errors are 0.000247% and 0.000260% for x
1
and x
2
, respectively. Per-step
error for the fourth-order Runge-Kutta method is difficult to estimate because the
method is derived by matching terms in Equation 12 with Taylor-series expansions
of x
1
and x
2
about t
i
through and including the h
4
terms. But approximately, the per-
step error is of order h
5
. For better accuracy, the fifth-order Runge-Kutta method
should be applied. For general use, the classic fourth-order Runge-Kutta method is,
however, easier to develop a computer program which is to be discussed next.
SUBROUTINE RKN
A subroutine called RKN has been written for applying the fourth-order Runge-
Kutta method to solve the initial-value problems governed by a set of first-order
ordinary differential equations. It has been coded according to the procedure
described in the preceding section. That is, the equations must be in the form of
Equation 3 by having the first derivatives of the dependent variables (x
1
through x
N
)
all on the left sides of the equations and the right sides be called F
1
through F
N
.
These functions are to be defined in a Function subprogram F.
The FORTRAN version of Subroutine RKN is listed below. There are seven
arguments for this subroutine, the first four are input arguments where the last is an
output argument. The fifth argument P keeps the Runge-Kutta parameters generated
in this subroutine. The sixth argument XT is needed for adjusting the input argument
XIN. These two arguments, P and XT, are included for handling the general case
of N variables. Listing them as arguments makes possible to specify them as matrix
and vector of adjustable sizes.
FORTRAN VERSION