Chaos, Lyapunov, and entropy increase-MATLAB CODE

Saturday, October 10, 2009

Chaos, Lyapunov, and entropy increase.


Chaotic dynamical systems have sensitive dependence on initial conditions. Thisiscommonly described as the ‘butterfly effect’ (due to Lorenz of the Lorenz attractor): the effects of the flap of a butterfly’s wings in Brazil build up with time until months later a tornado in Texas could be launched. In this exercise, we will see this sensitive dependence for a particular system (the logistic map)and measure the sensitivity by defining the Lyapunov exponents. The logistic map takes the interval (0, 1) into itself:

f(x)=4μx(1 − x),

where the time evolution is given by iterating the
map:
x0,x1,x2,... = x0,f(x0),f(f(x0)),....

In particular, for μ = 1 it precisely folds the unit interval in half, and stretches it (non-uniformly)to cover the original domain. The mathematics community lumps together continuous dynamical evolution laws and discrete mappings as both being dynamical systems.

The general stretching and folding exhibited by our map is often seen in driven physical systems without conservation laws.In this exercise, we will focus on values of μ near one, where the motion is mostly chaotic. Chaos is sometimes defined as motion where the final position depends sensitively on the initial conditions. Two trajectories, starting a distance "delta" apart, will typically drift apart in time as "delta*eλt", where "λ" is the Lyapunov exponent for the chaotic dynamics. Start with μ =0.9 and two nearby points x0 and "y0 = x0 + delta" somewhere between zero and one. Investigate the two trajectories x0,f(x0),f(f(x0)),...,f[n] (x0) and
y0,f(y0),... . How fast do they separate? Why do they stop separating? Estimate the Lyapunov exponent. (Hint: "delta" can be a few times the precision of the machine. so long as you are not near the maximum value of f at x0 =0.5.) Many Hamiltonian systems are also chaotic. Two configurations of classical atoms or billiard balls, with initial positions and velocities that are almost identical, will rapidly diverge as the collisions magnify small initial deviations in angle and velocity into large ones. It is this chaotic stretching, folding, and kneading of phase space
that is at the root of our explanation that entropy increases






MATLAB CODE


close all, clear all, clc
avalues=0.6:0.0001:1;

N=1000;
a=avalues;
x0 = [];
for i=1:length(avalues)
x0=[x0 rand(1)];
% x0=0.1;
end
x(1,:)=x0;
for n=1:.3*N
x(n+1,:)=4*a.*x(n,:).*(1-x(n,:));
end

figure
for n=.3*N:N
x(n+1,:)=4*a.*x(n,:).*(1-x(n,:));
plot(a,x(n+1,:),'.','MarkerSize',4.5) %plot x versus a
hold on

end
zoom
title('F(x) versus a' )
xlabel('a')
ylabel('F(x)')



clear all


muvalues=0.001:0.00000005:1;
muvalues=.9;
N=120;
mu=muvalues;
x0 = [];
y0=[];
e=1e-8;


k=.8;
x(1)=k;
y(1)=k+e;

figure

for n=1:N-1
x(n+1)=4*mu.*x(n).*(1-x(n));

y(n+1)=4*mu.*y(n).*(1-y(n));
plot(x(n),x(n+1),'.') %plot x(n+1) versus x(n)
hold on

end
title('x(n+1) versus x(n) ')
xlabel('x(n)')
ylabel('x(n+1)')

figure
hist(x,100)
title('Histogram of F(x)')


figure
l=1:N;
z=x-y;

plot(l,(x),'.-r'); %plot F(x) and F(y) versus N
hold on
plot(l,y,'-xk');
zoom
title(['F(x) and F(y) versus N (No.of steps)'])
xlabel('N')
ylabel(['F(x)-Red, F(y)-Black','e-initial difference- ',num2str(e)])



figure
plot(l,(abs((z/1))),'.-k') %plot F(x)-F(y) versus N
zoom
title(['[F(x)-F(y)] versus N (No of Steps)','e-initial difference- ',num2str(e)])
xlabel('N')
ylabel('F(x)-F(y)')

figure
g=(((log(abs(z)/1)))); %plot log [F(x)-F(y)]
p=polyfit(l,g,1);
y3=p(1)*l+p(2);
lamda=p(1)

plot(l,g,'.-','MarkerSize',0.5)
hold on
plot(l,y3,'r')

title(lamda)
title(['Log(abs((F(x)-F(y)))) versus N (No of Steps), ',' Lyapunov exponent- ',num2str(lamda)])
xlabel('N')
ylabel('Log(abs( (F(x)-F(y))) ) ')

0 comments

Post a Comment