function newton_fractal(f,fprime,z0,width,N,max_iter,max_size)     
      xs = real(z0)+(-1:2/N:1)*width;
      ys = imag(z0)+(-1:2/N:1)*width;
      [x,y] = meshgrid(xs,ys);
      z = x+1i*y;
      steps = zeros(size(z));
      for k = 1:length(z(:))
         [z(k),steps(k)] = newton(f,fprime,z(k),max_iter,max_size);
      end
   
      figure(1)
      levels = log2(min(steps(:)):max(steps(:)));
      steps = log2(steps);
      contourf(xs,ys,steps,levels,'edgecolor','none')
      colorbar
      colormap(jet)
      axis square
   
       figure(2)
       slice = round(atan2(imag(z),real(z))/pi);
       contourf(xs,ys,slice,-1:1)
       colorbar('Ticks',(2/3)*(-1:1),'Ticklabels',{'-2\pi/3',0,'2*\pi/3'})
       c = [1 1 0; 0 1 1; 1 0 1];
       colormap(c)
       axis square
   end 