d2r2.txt
来自「visual c++查过能用数值算法 附带光盘里面的源代码」· 文本 代码 · 共 38 行
TXT
38 行
# 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;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?