⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d2r2.txt

📁 Visual C++ 常用数值算法集 源代码
💻 TXT
字号:
# 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -