/* nag_ode_ivp_rk_range(d02pcc) Example Program * * Copyright 1992 Numerical Algorithms Group. * * Mark 3, 1992. * Mark 7 revised, 2001. * */ #include #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif static void f(Integer neq, double t1, double y[], double yp[], Nag_User *comm); #ifdef __cplusplus } #endif #define NEQ 2 #define ZERO 0.0 #define ONE 1.0 #define TWO 2.0 #define FOUR 4.0 int main(void) { Integer neq; Nag_RK_method method; double hstart, pi, tgot, tend, tinc; double tol, tstart, twant; Integer i, j, nout; double thres[NEQ], ygot[NEQ], ymax[NEQ], ypgot[NEQ], ystart[NEQ]; Nag_ErrorAssess errass; Nag_ODE_RK opt; Nag_User comm; Vprintf("d02pcc Example Program Results\n"); /* Set initial conditions and input for d02pvc */ neq = NEQ; pi = X01AAC; tstart = ZERO; ystart[0] = ZERO; ystart[1] = ONE; tend = TWO*pi; for (i=0; i=0; j--) { twant = tend - j*tinc; d02pcc(neq, f, twant, &tgot, ygot, ypgot, ymax, &opt, &comm, NAGERR_DEFAULT); Vprintf("%8.3f %8.3f %8.3f\n", tgot, ygot[0], ygot[1]); } Vprintf("\nCost of the integration in evaluations of f is %ld\n\n", opt.totfcn); d02ppc(&opt); } return EXIT_SUCCESS; } static void f(Integer neq, double t, double y[], double yp[], Nag_User *comm) { yp[0] = y[1]; yp[1] = -y[0]; }