#include <stdio.h>
#include <math.h>
int main()
{
int x=115,x0=100,x1=121,x2=144;
double y,y0,y1,y2,h,h1;
float f1,f2,f3,l0,l1,l2;
y0=sqrt(x0);
y1=sqrt(x1);
y2=sqrt(x2);
f1=(float)(y0-y1)/(x0-x1);
f2=(float)(y1-y2)/(x1-x2);
f3=(f1-f2)/(x0-x2);
h=y0+(x-x0)*f1+(x-x0)*(x-x1)*f3;
printf("Newton插值为:%f\n",h);
l0=(float)(x-x1)*(x-x2)/((x0-x1)*(x0-x2));
l1=(float)(x-x0)*(x-x2)/((x1-x0)*(x1-x2));
l2=(float)(x-x0)*(x-x1)/((x2-x0)*(x2-x1));
h1=y0*l0+y1*l1+y2*l2;
printf("Lagrange二次插值为:%f\n",h);
}