% function to plot result of Newton's method

 function  plot_newton(p,a,n)
   tic;
   all_roots=roots(p);
   delta=abs(2*a)/n;
   save_root=zeros(n);
   for k=1:n
      for j=1:n
         z=(-abs(a)+2*abs(a)*j/n)+1i*(-abs(a)+2*abs(a)*k/n);
         [y,iter]=poly_newton(p,z);
          if isnan(y)
              save_root(k,j)=0;
          else
              [m,root_num]=min(abs(all_roots-y));
             save_root(k,j)=root_num;
          end
      end
      k;
   end
   all_roots;
   save_root;
   x=[-a,a];
   y=[-a,a];
   image(x,y,save_root,'CDataMapping','scaled')
   %axis image
   %colormap(flipud(jet(length(all_roots))))
   toc;
return;

