#include #include #include "nr.h" using namespace std; DP NR::dfridr(DP func(const DP), const DP x, const DP h, DP &err) { const int NTAB=10; const DP CON=1.4, CON2=(CON*CON); const DP BIG=numeric_limits::max(); const DP SAFE=2.0; int i,j; DP errt,fac,hh,ans; Mat_DP a(NTAB,NTAB); if (h == 0.0) nrerror("h must be nonzero in dfridr."); hh=h; a[0][0]=(func(x+hh)-func(x-hh))/(2.0*hh); err=BIG; for (i=1;i= SAFE*err) break; } return ans; }