clear all

% 
% Run test of lyapunov.m on random numbers => lyexp should not converge, or
%       it should grow without bound. 
%

n=1000;
ptime=[1:n]'; % orbit length of n
d=1; % dimension of the orbit.
ppnts=rand(n,d);%ppnts=normrnd(3,10,[50,2]);

lyexp=lyapunov(ptime,ppnts) % Lyapunov exponent, log base 2.

figure(22)
hold off

plot(ppnts(1:end-1,1),ppnts(2:end,1),'r.')
 
%%
%
% Run test of lyapunov.m on periodic points => lyexp should be 0
%
n=100;
ptime=[1:n]'; % orbit length of n
ppnts=repmat([[1 2 3];[0 -1 0]],n/2,1); % An artificial per-2 orbit

lyexp=lyapunov(ptime,ppnts) % Lyapunov exponent, log base 2.

figure(24)
hold off

plot(ppnts(1:end-1,1),ppnts(2:end,1),'r.')

%%
%
% Run test of lyapunov.m on a converging orbit => lyexp should be 0
%
n=1000;
ptime=[1:n]'; % orbit length of n
ppnts=1./ptime; % A converging sequence, at the harmonic rate
%ppnts=1./2.^ptime; % A converging sequence, at an exponential rate

lyexp=lyapunov(ptime,ppnts) % Lyapunov exponent, log base 2.

figure(24)
hold off

plot(ppnts(1:end-1,1),ppnts(2:end,1),'r.')
 
return
%%
