% Program 0.1 Nested multiplication
% Evaluates polynomial from nested form using Horner's Method
% Input: degree d of polynomial,
%       array of d+1 coefficients c (constant term first),
%       x-coordinate x at which to evaluate, and,
%       array of d base points r, if needed
%
% Output: value y of polynomial at x
% function y=nest(d,c,x,r) 
  function y=nest(d,c,x,r); if nargin < 4, r=zeros(d,1); end
y=c(d+1);
for i = d:-1:1
    y = y.*(x-r(i))+c(i);
end
