The code for my integration package is given at the end. It consists of a source file integ.c with routines for Euler, LeapFrog, and 4th-order Runge-Kutta (the latter adapated from NRiC's rk4()), a header file integ.h with prototypes and a macro for specifying float or double precision, and a Makefile for building the implementation specific to this problem set. The routines in integ.c roughly follow the NRiC rk4() calling style. Each function expects a derivatives function to be supplied (the prototype is the same for each). I have left provision for arbitrary data to be passed to this function via a generic (void *) pointer (this will be useful for PS6).
To reduce these equations to first order, introduce
and
, so
The code for solving this system is given at the end
(integ2.c). It is analogous to integ1.c except now
x[] and dxdt[] have four components each (e.g.,
x[] contains
,
,
, and
, in that order).