function p=horner2(a,x)

% horner's rule for evaluating the polynomial 
% p(x)= a(1)x^(n-1)+ a(2) x^[n-2] + ... a(n)

n=length(a); 
p=a(1); 
for k=2:n
    p=p*x+ a(k); 
end