%
%	Filename: mandelbrot.m
%
function [m]=mandelbrot(edge,x1,x2,y1,y2)
maxloop=64;
maxsize=16;
if edge<1
   edge=10;
end
m=zeros(edge);
ystep=(y2-y1)/edge;
xstep=(x2-x1)/edge;
iy=1;
for y=y1:ystep:y2
   ix=1;
   for x=x1:xstep:x2
      mx=x;
      my=y;
      for i=1:maxloop
         realnum=mx*mx;
         imagnum=my*my;
         if(realnum+imagnum)>maxsize
            break
         end
         my=(mx*my)+y;
         mx=(realnum-imagnum)*.5 +x;
      end
      m(iy,ix)=maxloop-i;
      ix=ix+1;
   end
   iy=iy+1;
end