% animation of Henon's attractors vs a parameter
% Barnett 9/30/15

N = 1e3;                                     % # iters (any more and is slow)
x = zeros(2,N+1); b = 0.4;  % Fig 2.17 p.75.  b=-0.3 was for HW2 expt 2.1.
figure;
for a=0:0.003:1.3
  f = @(x) [a-x(1,:).^2+b*x(2,:);  x(1,:)];  % Henon map w/ params a,b
  x(:,1) = [.5;.5];                          % initial value, better than (0,0)
  for n=1:N, x(:,n+1) = f(x(:,n)); end       % iterate
  nn = 500:N;                 % only plot the final 500 iters
  plot(x(1,nn), x(2,nn), 'k.'); axis(2*[-1 1 -1 1]); title(sprintf('a=%.3g',a))
  vline(0); hline(0); axis equal; drawnow; pause(0.01);
end

