?? lagrange.cpp
字號:
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
double Lagrange(double x[],double y[],int n,double xx)
{
double yy=0.0;
for(int k=0;k<n;k++)
{
double temp=1.0;
for(int j=0;j<n;j++)
{
if(j==k)
continue;
temp*=(xx-x[j])/(x[k]-x[j]);
}
yy+=temp*y[k];
}
return yy;
}
void main()
{
double x=115;
/* double y=Simpson(100,10,121,11,144,12,x);
cout<<"the square root of the "<<x<<": "<<y<<endl;*/
//x=115;
double x0[3]={100,121,144};
double y0[3]={10,11,12};
double y=Lagrange(x0,y0,3,x);
cout<<"the square root of the "<<x<<": "<<y<<endl;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -