image thumbnail
from Newton fractal by Ankur Pawar
These scripts generate 7 different Newton fractals.

newtonfractal.m
%newton fractal
%Note: this script takes about 11 seconds to complete 
%the fractal

xres = 1000;  
yres = 1000;

  x = linspace(-1.5,1.5,xres);
  y = linspace(-1.5,1.5,yres);
  c = zeros(length(y),length(x));
iter= 30;    %number of iterations
len_x = length(x);
len_y = length(y);

for n=1:len_x
    c(n,:) = y(n)+i*x(:);
end

h_msg   = msgbox(' Please Wait ',' ');
zvalues = zeros(len_x,len_y);
    z   = 0+i*0; 
  rough = 0; 
 rough1 = 0; 

     m  =  1;
     n  =  len_x*len_y;
tic
for m=1:n
     
    k = 0;
    z = c(m);
    rough1 = 0.06;
    rough  = 0;
     while ((k<=iter)&&(abs(rough1)> 0.05))
              z = z - 0.33334*z + 0.33334/(z^2) ;   
              %simplified expression of  z- (z^3-1)/(3*z^2);
             
         rough1 = z - rough;
         rough  = z;
             k  = k+1;
     end
   zvalues(m) =k;

end
close(h_msg);
ho=flipud(colormap(hot));
colormap(ho)
image(x,y,zvalues)
axis tight square
toc

Contact us at files@mathworks.com