#include "nr3.h" #include "poly.h" #include "interp_1d.h" #include "ludcmp.h" #include "pade.h" #include using namespace std; int main() { ofstream out("out.txt"); for (int N=4; N<17; N+=3) { const double PI=acos(-1); // define PI to machine accuracy VecDoub coef(N); // the power series coefficients VecDoub x(81); // the interpolation grid points, x-abcissa VecDoub y(81); // the interpolation grid points, function value double rms[5]; // for the RMS for (int i=0; i<81; i++) { // fill the x,y vectors x[i]=0.25*i-10; y[i]=log(fabs(x[i]+PI)); } Poly_interp pol(x,y,N); // pol does Nth-order interpolation Spline_interp splin(x,y); // the natural cubic spline coef[0]=log(PI); // function value at x=0 for (int i=1; i-PI } Ratfn rt=pade(coef); // rt = pade function for (int i=0; i<4; i++) rms[i]=0; for (double xx=-10; xx<10.01; xx+=0.01) { double yy = xx; if (xx<-PI) yy=-2*PI-xx; double power=0; for (int i=0; i