#include #include #include "dopri5.h" #define ndgl 1 #define nrdens 1 #define licont nrdens void func (unsigned n, double x, double *y, double *f) { f[0] = -y[0]; } void solout (long nr, double xold, double x, double* y, unsigned n, int* irtrn) { static double xout,y1; if (nr == 1) { printf ("x=%9.3e y=%9.3e step=%d\n",x, y[0],nr-1); xout = x + 0.1; } else while (x >= xout) { printf ("x=%9.3e y=%9.3e step=%d\n",xout, contd5(0,xout),nr-1); xout += 0.1; } } /* solout */ int main (void) { double y[ndgl]; unsigned icont[licont], i; int res, iout, itoler; double x, xend, atoler, rtoler; iout = 2; x = 0.0; y[0] = 1.0; xend = 1.0; itoler = 0; rtoler = 1.0E-7; atoler = rtoler; icont[0] = 0; res = dopri5 (ndgl, func, x, y, xend, &rtoler, &atoler, itoler, solout, iout, stdout, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, 0, 0, nrdens, NULL, licont); printf ("rtol=%9.3e fcn=%li step=%li accpt=%li rejct=%li\r\n", rtoler, nfcnRead(), nstepRead(), naccptRead(), nrejctRead()); return 0; } /* main */