function y = sloweval(a,x)
% SLOWEVAL  Given coeffs
%   a(1),...,a(n+1)
% compute P(x) by naive method
%   P(x) = a(1) + a(2) x + a(3) x^2 + ... + a(n+1) x^{n+1}.
% Note n >= 1 is required for this implementation.

n = length(a) - 1;
y = a(1);
for j=2:n+1
  xpow = x;
  for k = 1:j-1
    xpow = xpow * x;
  end
  y = y + a(j) * xpow;
end
