数值分析--经过三点的二次函数

经过三点(x1,y1),(x2,y2),(x3,y3)的二次函数用c++语言表示如下:

double quad(double x1,double y1,double x2,double y2,double x3,double y3,double x) { double m1 = (x-x2)(x-x3)*y1/((x1-x2)(x1-x3)), m2 = (x-x1)(x-x3)*y2/((x2-x1)(x2-x3)), m3 = (x-x1)(x-x2)*y3/((x3-x1)(x3-x2));

return (m1+m2+m3);

}

THE END