Linear and polynomial interpolation using Lagrange polynomial
try from wikipedia using info from:
Linear interpolation
(x0,y0) (x1,y1) succesive data points
y1 - y0
y = y0 + (x - x0) ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
x1 - x0
Lagrange polynomial
xi, yi : data points
n ⎛ x - xj ⎞
p(x) = ∑ ⎜ ∏ ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ ⎟ yi
i=0 ⎝ 0≤j≤n xi - xj ⎠
j≠i
Lagrange polynomial in second barycentric form
xj, yj: data points, wj: barymetric weight
wj = ∏ (xj - xm)⁻¹
m≠j
k ⎛ wj ⎞
∑ ⎜ ⎯⎯⎯⎯⎯⎯⎯ yj ⎟
j=0 ⎝ x - xj ⎠
p(x) = ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
k ⎛ wj ⎞
∑ ⎜ ⎯⎯⎯⎯⎯⎯⎯ ⎟
j=0 ⎝ x - xj ⎠