function bif(ni,x0)

% Diagrama de bifurcacao,(no interacoes, x inicial)

if nargin<1 ni=1000; end
if nargin<2 x0=.55; end
figure(1); clf;
im(1001,4000)=0;
for col=1:4000
    mi=col/1000
    x=x0;
    for i=1:ni
        x=mi*x*(1-x);
        lin=round(x*1000);
        im(1001-lin,col)=im(1001-lin,col)+1;
    end
    im(:,col)=im(:,col)/max(im(:,col)); % Normaliza coluna
end
imagesc(im); colormap(gray);
save im;
imwrite(im,'bifurc.bmp');
