% Return the period of logistic map vector
%
% NOTE : CRUDE COMPUTATIONS !!!!
% 

function N=log_period(a)


f =@(a,x)(a*x.*(1-x));

% Warm up interations
M = 2000;

% Real iterations
N = 2000;

N_old = 1;

z = 0.5;

for i=1:1:M
  z = f(a,z);
end
  
Z = [];

for i=1:1:M
  z = f(a,z);
  Z = [Z z];
end

N = period(Z);


function N=period(v)

M = length(v)/2;

N = 1;

tol = 1e-6;

while N < M
  
  I1 = (length(v)-N+1):length(v);
  I2 = (length(v)-2*N+1):(length(v)-N);
  
  if(norm( v(I1) -v(I2) )< tol)
    return;
  end

  N =N+1;
end
