Using points to generate quadratic equation to interpolate data

喜你入骨 提交于 2019-12-04 09:38:08
Daniel Fischer

You can use Lagrange polynomial interpolation, the curve is given by

y(x) = y_1 * (x-x_2)*(x-x_3)/((x_1-x_2)*(x_1-x_3))
     + y_2 * (x-x_1)*(x-x_3)/((x_2-x_1)*(x_2-x_3))
     + y_3 * (x-x_1)*(x-x_2)/((x_3-x_1)*(x_3-x_2))

If you collect the coefficients, you obtain

a = y_1/((x_1-x_2)*(x_1-x_3)) + y_2/((x_2-x_1)*(x_2-x_3)) + y_3/((x_3-x_1)*(x_3-x_2))

b = -y_1*(x_2+x_3)/((x_1-x_2)*(x_1-x_3))
    -y_2*(x_1+x_3)/((x_2-x_1)*(x_2-x_3))
    -y_3*(x_1+x_2)/((x_3-x_1)*(x_3-x_2))

c = y_1*x_2*x_3/((x_1-x_2)*(x_1-x_3))
  + y_2*x_1*x_3/((x_2-x_1)*(x_2-x_3))
  + y_3*x_1*x_2/((x_3-x_1)*(x_3-x_2))

you can formulate it in a matrix form: aX=b

    1 x1 x1^2
a=  1 x2 x2^2
    1 x3 x3^2

   y1
b= y2
   y3

then solve by inverting the matrix a (can be done via gauss method pretty straight forward) http://en.wikipedia.org/wiki/Gaussian_elimination

X = a^-1*b

and X in this case are the [c b a] coefficients your are looking for.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!