// // integrators.C // // basic integrators for the vector class. // void rk4(vector & x, vfunc_ptr f, double h, int & first_call) { static vector kx1,kx2,kx3,kx4; kx1 = f(x)*h; kx2 = f(x+kx1*0.5)*h; kx3 = f(x+kx2*0.5)*h; kx4 = f(x+kx3)*h; x += (kx1+2*(kx2+kx3)+kx4)*0.166666666666666666666666667; } void leapfrog(vector & x, vfunc_ptr f, double h, int & first_call) { static vector fprev; if (first_call != 0){ fprev = f(x); first_call = 0; } for(int i = 0; i tol) h /= 2; }