function niutonf
% niutonf Niutono stiliaus Fraktalas, 
% http://www.willamette.edu/~sekino/fractal/universe.htm
% z_{n+1}=z_n-g(z_n)/g'(z_n),
% g(z)=z^10+3*iz^2-1
% aplinkoje tashko z_0=(0.71,0.935)

cmax=100; h=[rand(cmax,1),ones(cmax,1),ones(cmax,1)]; 
rgb=hsv2rgb(h);
e=sqrt(-1);
km=0;
N=65; 
ep=0.00001; ep=ep*ep;
u=zeros(N,N,3); N2=round(N/2); 
for i=-N2:N2, for j=-N2:N2,
  z0=2*(i+e*j)/N2+0.71+e*0.935; k=0; p=1;
  while (k<cmax)&(p>ep), 
    z1=z0-(z0^(10)+3*e*z0^2-1)/(10*z0^9+6*e*z0); 
    k=k+1; p=(real(z1-z0))^2+(imag(z1-z0))^2; z0=z1; end;
  if (abs(i)<3) & (abs(j)<3), disp(p); end;
  if p<=ep, u(i+N2+1,j+N2+1,:)=rgb(k,:); km=max(k,km); end;
end; end;
image(u); axis equal; axis off;
title('Niutono fraktalas: g(z)=z^{10}+3*iz^2-1');
km