📄 d2r9.cpp
字号:
# include<iostream.h>
# include<math.h>
# include<iomanip.h>
void main()
{
//program d2r9
//driver for routine polin2
int n,i,j;
double pi,x1,x2,f,dy,y,x1a[6],x2a[6],ya[6][6];
n = 5;
pi = 3.141593;
for (i = 1; i<= n; i++)
{
x1a[i] = i * pi / n;
for (j = 1 ;j<= n;j++)
{
x2a[j] = 1.0* j / n;
ya[i][j] = sin(x1a[i]) * exp(x2a[j]);
}
}
//test 2-dimensional interpolation
cout<<endl;
cout<<" x1 x2 f[x] interpolated error"<<endl;
for (i = 1; i<= 4; i++)
{
x1 = (-0.1 + i / 5.0) * pi;
for (j = 1; j<= 4; j++)
{
x2 = -0.1 + j / 5.0;
f = sin(x1) * exp(x2);
polin2(x1a, x2a, ya, n, n, x1, x2, y, dy);
cout<<setprecision(6)<<setiosflags(ios::fixed);
cout<<setw(11)<<x1;
cout<< setw(11)<<x2;
cout<< setw(11)<<f;
cout<< setw(11)<<y;
cout<< setw(11)<<dy<<endl;
}
cout<<"**********************************"<<endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -