Neville's algorithm to interpolate without calculating the coefficients.
xy | It is a matrix the first column of which contains the x values, the second contains the corresponding y values. It is expected to be sorted by x. |
return value | Interpolating polynomial. |
In comparison, the function polynLagrange calculates the coefficients, and hence is probably more efficient for many evaluation of the same interpolating polynomial.
xy = [-1,4; 4,8; 42,-88; 444, 827];
xunit = 1J;
yunit = 1V;
xmin = min(xy[...;0]);
xmax = max(xy[...;0]);
eps = (xmax-xmin)/200;
xmin -= 2*eps;
xmax += 2*eps;
x = (xmin..eps..xmax)*xunit;
y = (@(x) polynInterp(xy * [xunit,0;0,yunit], x))(#x);
plot(x,y)