% Generate bifurcation diagrams for 1-D maps.
% 
% For a range of different mu values, iterate the map for N steps and plot
% the last L points. The assumption is that the last L points reflect the
% asymptotic behavior.
%
% Example: bifdiag(0,0.001,1,1000,100)

function bifdiag(mu_start, mu_interval, mu_stop, N, L)

figure;
hold on;
x0=0.1;       % initial condition
for mu = mu_start:mu_interval:mu_stop
  x = x0*ones(N,1);
  for i = 1:N-1
      x(i+1) = 4*mu*x(i)*(1-x(i)); % logistic map
  end
  Mu = mu*ones(L+1, 1);
  plot(Mu, x(length(x) - L: length(x)),'.',color='black');
end

