# include<iostream.h> # include<math.h> # include<iomanip.h> double func(double x) { double aa; aa = x * exp(-x) / ((x - 1) *(x-1) + 1); return aa; } void main() { //program d2r2 //driver for routine ratint int i,npt = 6; double x[7], y[7],xx,yexp,yy,dyy; for (i = 1; i<=npt; i++) { x[i] = double(i*2)/double(npt); y[i] = func(x[i]); } cout<<"Diagonal rational function interpolation"<<endl; cout<< " x interap. accuracy actual"<<endl; for (i = 1; i<=10; i++) { xx = 0.2 * double(i); ratint(x, y, npt, xx, yy, dyy); yexp = func(xx); cout<<setprecision(6)<<setiosflags(ios::fixed); cout<<setw(10)<<xx; cout<<setw(14)<<yy; cout<<setw(14)<<dyy; cout<<setw(14)<<yexp<<endl; } }