iconEuler Examples

Lorenz Attractor

by Alain Busser

This notebook computes the famous Lorenz attractor, an unstable
iteration.

Press Ctrl-R to run all commands at once.
> //
>function compute () ...
global pts,n,s,b,r,dt,M;
for i=1 to n;
x=M[1];
y=M[2];
z=M[3];
pts[1,i]=(s*(y-x))*dt+x;
pts[2,i]=(r*x-y-x*z)*dt+y;
pts[3,i]=(x*y-b*z)*dt+z;
M[1]=pts[1,i];
M[2]=pts[2,i];
M[3]=pts[3,i];
end;
return 0;
endfunction
>n=10000;
>pts=ones(3,n);
>s=10;
>b=8/3;
>r=27;
>dt=0.01;
>M=normal(1,3)/1000000;
>compute();
Zoom now with +/-, or use the cursor keys to turn. You need red/green
glasses to see this properly.
>plot3d(pts[1],pts[2],pts[3],wire=1,user=1,anaglyph=1,frame=0,scale=1.2);  ...
>  insimg(antialias=1);

Lorenz Attractor

The same in simple 3D.
>plot3d(pts[1],pts[2],pts[3],wire=1,user=1);  ...
>  insimg(antialias=1);

Lorenz Attractor

>

Examples Homepage