function y = horner(x, coeff) % function y = horner(x, coeff) % % Written by Avery Sterk in conjunction with MATH 335, Spring 2009 % % Inputs % x value or values at which polynomial is to be evaluated % coeff Coefficients of polynomial to evaluate % coeffs(1) is the constant term % coeffs(last) is coefficient of the leading term % Output % y a vector with same shape as x containing corresponding % values of the polynomial y = zeros(size(x)); for i = length(coeff):-1:1 y = y.*x; y = y + coeff(i); end end