% Matlab/Octave program to compute the Lyapunov exponent of a sequence
lambda = 4;

% Number of iterates
niter = 100000;
x = zeros(niter,1);

% Initial x
%x(1) = 1/sqrt(2);
x(1) = pi/10;

% Calculate iterates
for i=2:niter
  x(i) = logistic_f(lambda,x(i-1));
end

% We're going to use Matlab's array computation capabilities 
% to calculate the Lyapunov exponent as a one-liner:
mu = mean(log(abs(dlogistdx(lambda,x))))
