function logphase(rv)
%
% logphase.m - this MATLAB file solves the 
% discrete logistic equation x(i+1)=r*x(i)*(1-x(i))
% for various r values and illustrates bifurcations

    n=100;
    x0=.2;

    if nargin<1
        rv=0.8:0.1:4;
    end
figure
    
for r=rv,    
% Initialize
x=zeros(n+1,1);
t=zeros(n+1,1);
x(1)=x0;
tt(1)=0;

% Iterate the Logistic difference equation
for i=1:n
t(i)=i-1;
x(i+1)=r*x(i)*(1-x(i));
end

plot(r,x(end-20:end),'o');
hold on
end
