
zmax = 1;
x = linspace(-zmax,zmax,500); 
y = x'*1i;
[x,y]=meshgrid(x,y);
Z = x+y;
%%
c = -0.835-0.2321i;
N = 80;
% m = zeros(500);
% for k = 1:500
%     for p = 1:500
%         m(k,p) = escapeVelocity(Z(k,p),c,N);
%     end
% end


tic; m = arrayfun(@(x)escapeVelocity(x,c,N),Z);toc
Zp = gpuArray(Z);
tic; M = arrayfun(@(x)escapeVelocity(x,c,N),Zp); ;toc


%imagesc(atan(0.1*m))




function n = escapeVelocity(z0,c,N)
% Function computes the necessary number of iterations to escape from orbit
% of z0 in Prisoner set iteration
n = 0;
zn = z0^2+c;
while(n<=N&&abs(zn)<=2)
    zn=zn^2+c;
    n=n+1;
end
end
