lorenz_lyap
Andre Carvalho and Graham Dennis
The Lorenz Attractor, an example of chaos. Includes the calculation of the largest Lyapunov exponent.
real sigma = 10.0; real b = 8.0/3.0; real r = 28.0; real d0 = 1.0e-8; // separation between the main path and the 'test' path
t
x y z xe ye ze
x = 1.; y = 1.; z = 1.; xe= x + d0; ye= y; ze= z;
lyap
5000 100
position lyapunov
real dlx=(xe - x); real dly=(ye - y); real dlz=(ze - z); real d1 = sqrt(dlx*dlx + dly*dly + dlz*dlz); real df = d1/d0; xe = x + (xe-x)/df; ye = y + (ye-y)/df; ze = z + (ze-z)/df; lyap += log(df);
position
dx_dt = sigma*(y-x); dy_dt = r*x - y - x*z; dz_dt = x*y - b*z; dxe_dt = sigma*(ye-xe); dye_dt = r*xe - ye - xe*ze; dze_dt = xe*ye - b*ze;
xR yR zR le
position lyapunov
xR = x; yR = y; zR = z; le=lyap/t; // This value should asymptotically approach ~0.906
distance
position
distance = sqrt(x*x + y*y +z*z);