function [y,z,w] = horner(a,x)
%
% [y,z,w] = horner(a,x)
%
% This is Horner's Method used to evaluate the polynomial q(x) with
% coefficients (with descending degree) in a at the point x.  The
% returned values are y=q(x), z=q'(x), and w=q''(x).
%

% Troy Henderson
% Assistant Professor
% University of Mobile
% Updated 7 February, 2008

n=length(a);
y = a(1);
z = y;
w = 2*z;
for j=2:n-2
	y = x*y + a(j);
	z = x*z + y;
	w = x*w + 2*z;
end
y = x*y + a(n-1);
z = x*z + y;
y = x*y + a(n);
if (n<=1), w=0; end
if (n==0), z=0; w=0; end
