-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLyapunov
36 lines (33 loc) · 806 Bytes
/
Lyapunov
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* A Copy of the C example of the Lyapunov exponent taken from C.A.Pickovers Chaos In Wonderland... */
Lsum = 0;
n = 0;
x = 0.1;
y = 0.1;
xe = x + 0.000001;
ye = y;
REPEAT 10,000,000 TIMES
xx = sin(y*b) + c*sin(x*b) ;
yy = sin(x*a) + d*sin(y*a) ;
xsave = xx;
ysave = yy;
x = xe;
y = ye;
n++;
/* "Re-Iterate" for computing Lyapunov Exponent, L */
xx = sin(y*b) + c*sin(x*b) ;
yy = sin(x*a) + d*sin(y*a) ;
dLx = xx - xsave;
dLy = yy - ysave;
dL2 = dLx*dLx + dLy*dLy;
df = 1000000000000.*dL2;
rs = 1./sqrt(df);
xe = xsave + rs*(xx - xsave);
ye = ysave + rs*(yy - ysave);
xx = xsave;
yy = ysave;
Lsum = Lsum + log(df);
L = 0.721347*Lsum/n;
x = xx;
y = yy;
/* L is the value for the Lyapunov exponent */
END REPEAT