% difference equations  x_{k+1} = A x_k
clc; clear all;

% code computes x_1, x_2, ..., x_N
N = 20;
initial_values = [10 10]; % choose x_1

% matrix A
m = -0.45;
A = [1,-1;1/16-m,1/2];

% analysis of A
eigenvalues = eig(A) % eigenvalues
abs(eigenvalues) % absolute value of eigenvalues
[V,D] = eig(A);
V % eigenvectors

% vector Y that stores x_1, x_2, ..., x_N
Y = zeros(2,N);

% initial value
Y(:,1) = [initial_values(1,1),initial_values(1,2)];
% plot initial value
plot(Y(1,1),Y(2,1),'b*');hold on;

%%%%% loop to compute the sequence according to x_{k+1} = A x_k
for kk=1:N-1
  % compute x_k
  Y(:,kk+1) = A*Y(:,kk);
  
  % plot x_k
  plot(Y(1,kk+1),Y(2,kk+1),'m*'); limit = 20;xlim([-limit limit]);ylim([-limit limit]);hold on;
  
  % pause to make exposition clearer
  pause(1)
end
hold off;