function y = nest(c,x,b)
% evaluate a polynomial using nested multiplication
% c : vector of coefficients in Newton form
% x : x values at which to evaluate
% b : base points
% output y: values of p(x)
n = length(b);
d = n-1; % degree of polynomial
y = c(n);
for i=d:-1:1
    y = y.*(x-b(i))+c(i);
end