%computes lyapunov exponent clear; r = 3.6; x0 = 0.3; %initial data %%%%% first converge to attractor x = x0; for i=1:200; x = r*x*(1-x); %apply logistic map end; %%%%% find (1/n) Sum ln(f'(x_i)) - limit should be lyapunov exponent sum = 0; for i=1:200; x = r*x*(1-x); %logistic map sum = sum + log(abs(r - 2*r*x)); % note that f' = r - 2*r*x %print out average average(i) = sum/i; %collect into vector for later plotting end; plot(average); %plots sucessive averages so a trend can be observed xlabel('N'); ylabel('(1/N)\Sigma_{i=1}^N ln| df/dx(x_i) |');