function JuliaSet(c,w,p)

% Compute Julia set. f(z) = z² + c.
% i: iteration number. 
% p: number of points on abscissa.

if nargin < 3
    c = 0.2+0.65i;
    w = 14;
    p = 500;
end

u = max(abs(c),2);
g = linspace(-u,u,p);
M = ones(p,1)*g+i*(ones(p,1)*g)';

N = zeros(p,p);

for s = 1:w
    N = N+(abs(M)<=u);
    M = M.*M+ones(p,p).*c;
end;

imagesc(N);

% colormap(hot);
% colormap(1-Gray);
colormap(jet);

hold off;
%axis off;

% "Complex and Chaotic Nonlinear Dynamics. 
% Advances in Economics and Finance, 
% Mathematics and Statistics" 
% T.Vialar, Springer 2009.
% copyright (c) 