The Lorenz Attractor

I decided to write some code to draw trajectories in the lorenz system. Below is an image showing the trajectories of two very close initial conditions for the lorenz system.

For some time they stay close, then then diiverge

Here is the code i used

clear;
x(1) = 3;
y(1) = 15;
z(1) = 5;
x1(1) = 3.02;
y1(1) = 15.01;
z1(1) = 5.02;
dt = 10^-3;
pran = 10;
ray = 28;
phy = 8/3;
N = 20/dt;
for j=1:N
        x1(j+1) = x1(j) + dt*(pran*(y1(j)-x1(j)));
    y1(j+1) = y1(j) + dt*(x1(j)*(ray-z1(j))-y1(j));
    z1(j+1) = z1(j) + dt*(x1(j)*y1(j) - phy*z1(j));

    x(j+1) = x(j) + dt*(pran*(y(j)-x(j))); 
    y(j+1) = y(j) + dt*(x(j)*(ray-z(j))-y(j));
    z(j+1) = z(j) + dt*(x(j)*y(j) - phy*z(j));
	j/N
end
plot3(x,y,z);
hold on;
plot3(x1,y1,z1,'r');

This is just a small taste of what ive been up to.

Leave a comment