#include"stdio.h"
#define N 5
int i,j,k;
float m,s,n;
float xx[]={0.4,0.55,0.65,0.80,0.95,1.05};
float yy[]={0.41075,0.57815,0.69675,0.90,1.00,1.25382};
float New()
{
m=0;
for(j=0;j<=N;j++)
m+=yy[j]/(xx[j]-xx[i]);
return m;
}
float Newton(float x)
{
s=0,n=1;
for(i=0;i<=N;i++)
if(j!=i)
{
n*=(x-xx[i]);
s=n*New();
}
return s;
}
main()
{
clrscr();
printf("%f\n",Newton(0.596));
}
题目是用Newton插值多项式计算函数的近似值
不胜感谢!