function z=NewtonRoots(a)
% NEWTONROOTS computes zeros of a polynomial 
%   z=NewtonRoots(a) computes zeros of the polynomial given by the
%   coefficients in the vector a using Newton's method

n=length(a); degree=n-1; z=[];
y=1+sqrt(-1);
for m=degree:-1:1             
  p=1; h=0;                              % Newton iteration 
  while abs(p)>10*eps*h
    x=y; p=0; ps=0; h=0;
    for k=1:m+1
      ps=p+ps*x; p=a(k)+p*x; h=abs(a(k))+h*abs(x);
    end
    y=x-p/ps;
  end
  b(1)=a(1);                             % deflation 
  for k=2:m
    b(k)=b(k-1)*y+a(k);
  end
  z=[z; y];
  a=b;
end