作业帮 > 综合 > 作业

怎么用c++语言实现拉格朗日插值

来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/04/28 08:38:34
怎么用c++语言实现拉格朗日插值
把源代码写一下,
怎么用c++语言实现拉格朗日插值
#include
#include
#include
typedef struct data
{
float x;
float y;
}Data;//变量x和函数值y的结构
Data d[20];//最多二十组数据
float f(int s,int t)//牛顿插值法,用以返回插商
{
if(t==s+1)
return (d[t].y-d[s].y)/(d[t].x-d[s].x);
else
return (f(s+1,t)-f(s,t-1))/(d[t].x-d[s].x);
}
float Newton(float x,int count)
{
int n;
while(1)
{
coutn;
if(n