拉格朗日插值
#include <iostream> using namespace std; int main() { double x[4]={1.1275,1.1503,1.1735,1.1972}; double y[4]={0.1191,0.13954,0.15932,0.17903}; double yy=0; double xx=1.13; for(int i=0;i<4;i++) { double p=1; for(int j=0;j<4;j++) { if(j!=i) p=p*(xx-x[j])/(x[i]-x[j]); } yy+=p*y[i]; } cout<<yy<<endl; return 0; }