Copy (carefully) the numerical recipes routine ``rk4'' from NR 16.1 to a file named ``p480.c'' and modify it to produce a function of the following form:
void rk4p480(double y[], double dydx[], int n, double x, double h, double yout[],
void (*derivs)(double, double [], double [],
int, double [], double [], double [], int),
int k, int dk, double f[], double r[], double dr[], int N)
Output:
Input:
Notes:
Be certain to modify ``rk4'' to function entirely in double precision. For this, you must not only declare all variables double precision, but also must replace the calls to ``vector()'' and ``free_vector()'' with calls to to ``dvector()'' and ``free_dvector()'', respectively.
To be able to access the input arrays f[], r[], dr[] properly, treat
the indices
and
as integer versions of
and
: (1) when
``rk4p480()'' defines
with
, define
; (2)
whenever ``rk4p480()'' calls ``derivs()'', add five new appropriate
arguments to the call (k,f,r,dr,N); (3) make sure that the
appropriate value for k (either
,
or
) is passed to each
call to ``derivs()'', paralleling how rk4p480 treats
.
Tomas Arias 2007-02-02