Caotic Mechanics Maxima
Caotic Mechanics Maxima
Email: amorante,[email protected]
Abstract
We present an introduction to the study of chaos in discrete and continuous dynam-
ical systems using the CAS Maxima. These notes are intended to cover the standard
topics and techniques: discrete and continuous logistic equation to model growth popu-
lation, staircase plots, bifurcation diagrams and chaos transition, nonlinear continuous
dynamics (Lorentz system and Duffing oscillator), Lyapunov exponents, Poincare sec-
tions, fractal dimension and strange attractors. The distinctive feature here is the use
of free software with just one ingredient: the CAS Maxima. It is cross-platform and
have extensive on-line documentation.
Contents
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . 2
2 The logistic equation: continuous case . . . . . . . . . . . . . . 2
3 The logistic equation: discrete case . . . . . . . . . . . . . . . 4
4 Staircase diagrams . . . . . . . . . . . . . . . . . . . . . 6
5 Bifurcations and chaos . . . . . . . . . . . . . . . . . . . . 7
6 The Lorenz attractor . . . . . . . . . . . . . . . . . . . . 10
7 Lyapunov exponents . . . . . . . . . . . . . . . . . . . . 13
8 The Duffing oscillator . . . . . . . . . . . . . . . . . . . . 15
9 Poincare sections . . . . . . . . . . . . . . . . . . . . . 19
10 Fractal dimension . . . . . . . . . . . . . . . . . . . . . 22
1
1 Introduction
The use of a computer is a natural way to explore those notions related to dynamical
systems; here, we present the basics of chaotic dynamics using Maxima. This is a free,
cross-platform, general purpose computer algebra system [Max 11], capable also of doing
numerical computations, that we have used in short introductory summer courses (about
10 hours). The following notes are the outcomes of such courses, and given the target
audience, we have made every effort to keep them at an elementary level, relegating the
most technical points to the footnotes.
Of course, it is impossible to include all topics one would wish, so we have excluded
those theoretical results which are hard to implement using the computer, because they
involve irrational numbers. Explicitly, we only make some brief remarks about results such
as the density of periodic orbits or sensitivity to initial conditions and leave aside topological
transitivity.
In writing this paper, we have used Maxima version 5.24.0 and its graphical interface
wxMaxima version 11.04.0. The version of Gnuplot was 4.4 patchlevel 3, everything running
on a generic desktop PC with Slackware Linux 13.1.
2
We will use Maxima to solve equation (4) (note the use of the apostrophe to define an
equation. The command for solving first or second-order ODEs is ode2):
(%i1) diff(x,t)=k*x*(1-x);
d
(%o1) x = k (1 x) x
dt
(%i2) ode2(%,x,t);
(%i3) ic1(%,t=0,x=x[0]),logcontract;
x
log x1 k t + log x0x1
0
(%o3) =
k k
and solving the last equation we get
(%i4) solve(%,x);
x0 e k t
(%o4) [x = ]
x0 e k t x0 + 1
Thus, we have the explicit solution (note that the outcome (%o4) is a list a collection of
elements enclosed between brackets and we want to define our solution as the right-hand
side of its first element):
(%i5) define(x(t),rhs(first(%o4)))$
Let us note that normalization (3) implies that for all initial conditions 0 < x0 , the
solutions x(t) 1 when t . In fact, even if we had not known the solutions explicitly, a
simple continuity argument would show that all solutions bounded by the steady states x = 0
and x = 1, tend monotonically to x = 1 1 . Also, in the unbounded region x > 1 all solutions
tend monotonically to the steady state x = 1. For x < 0 there is no solution (populations
are non negative). In general, in a one dimensional continuous system, solutions either
converge monotonically to a steady state or diverge.
The parameter k affects the slope of the solutions, as we can see by graphing them
together for different values of k (in this example, varying from k = 0.25 to k = 1.75 with
step 0.25).
For a system x = f (x), in the region between two consecutive steady states x(t) = x with f (x ) = 0,
1
x1< x2 , the mapping f (and therefore the derivative x) has constant sign, so a solution x(t) with initial
condition x0 such that x1 < x0 < x2 , is strictly monotonic. This solution is bounded, so limt x(t) = x2 if
x(t) is increasing, and limt x(t) = x1 if x(t) is decreasing. Finally, because of the uniqueness theorem for
the Cauchy problem, x(t) can not reach the values x1 , x2 . A similar reasoning can be used for unbounded
regions.
3
(%i6) wxplot2d(makelist(subst([k=d*0.25,x[0]=0.1],x(t)),d,1,7),
[t,0,15],cons(legend,makelist(k=d*0.25,d,1,7)),
[gnuplot_preamble,"set key right bottom"]);
(%t6) (%o6)
Next, we use the evolution command (included in the dynamics package) to calculate,
for a fixed r, the n + 1 points xi+1 = F (r, xi ) from i = 0 to i = n, where the initial value
x0 is given (here we use a pseudo-random initial condition between 0 and 1).
2
This sentence deserves a clarification. Actually, closed solutions do exist, although defined throuh
implicit functional formulas which are hardly useful for computational purposes, see [Bru 98] and ref-
erences therein. However, there are well-known explicit solutions for particular values of k, see http:
//en.wikipedia.org/wiki/Logistic_map#Solution_in_some_cases.
4
This set of points is a segment of the orbit of x0 . We start with r = 0.25 making 15
iterations:
(%i9) load(dynamics)$
(%o11) .8886589561406515
(%i12) evolution(F(0.25,x),x[0],15,[y,0,1]);
(%t12) (%o12)
If 0 < r 1 and x0 r1 1
r , r , the population eventually dies, independently of the
initial condition.
If 1 < r 2 and x0 ]0, 1[, the population quickly approaches the value (r 1)/r,
independently of the initial condition.
If 2 < r 3 and x0 ]0, 1[, the population tends again to the value (r 1)/r, but in
an oscillating way (maybe after a short transient). The rate of convergence is linear,
except for r = 3, where the rate of convergence is quite slow, in fact it is sub-linear.
If 3 < r < 1 + 6 (with 1 + 6 ' 3.45), the population oscillates between two values,
almost independently of the initial condition. These two values, which depend on r,
are said to have primary period two.
If 3.45 < r < 3.54 (approximately), for almost all initial condition the population
oscillates between four periodic points.
If r increases over 3.54, for almost all initial condition the population oscillates between
8 periodic points, then 16, 32, etc. The size of the intervals formed by the values of the
5
parameter producing oscillations of a given length, becomes small, and the quotient
of the size for two consecutive period-doubling intervals approaches the so called
Feigenbaum constant F = 4.669... This behavior is called a period-doubling cascade.
Let us note that when the parameter r increases, the dynamics differs from that observed
in the continuous case.
Let us show some examples. For our initial pseudo-random x0 and r = 1.3:
(%i13) evolution(F(1.3,x),x[0],15,[y,0,1]);
(%t13) (%o13)
We note that (1.3 1)/1.3 ' 0.23. For r = 3.5 and the initial condition x0 = 0.3, we
observe the transient and four periodic points:
(%i14) evolution(F(3.5,x),0.3,25,[y,0,1]);
(%t14) (%o14)
4 Staircase diagrams
There is another graphical method to study the phenomenon of the emergence of attract-
ing periodic points that we have seen in the last example, based on the particular form of
the evolution equation: xn+1 = f (xn ). For the logistic map (f (x) = r x (1 x)), if the
coordinates of the points in the plane represent two consecutive values in the orbit of x0 ,
the point (x, y) = (xn , xn+1 ) can be obtained graphically as the intersection of the vertical
line x = xn and the graph of the function y = f (x). Once xn+1 is known, in order to get
xn+2 we just have to let xn+1 play the role of xn in the previous step. So, we take the
6
intersection of the horizontal line y = xn+1 with the diagonal y = x. Now xn+2 = f (xn+1 ),
and by iterating the process a predetermined number of times, we get a segment of the orbit
of x0 . Maxima implements this construction with the staircase command:
(%i15) staircase(F(3.1,x),x[0],250,[x,0,1],[y,0,1]);
(%t15) (%o15)
Here we see the orbit oscillating between the periodic points (x ' 0.56) and (x ' 0.76).
We can also reproduce the behavior of (%o14), where there is a period-four orbit (we make
500 iterations to get a distinguishable path). Let us note that each rectangle intersecting
the diagonal defines two periodic points:
(%i16) staircase(F(3.5,x),x[0],500,[x,0,1],[y,0,1]);
(%t16) (%o16)
7
and n = 200, for a given initial condition x0 . The range of the values of r is [2.5, 4]:
(%i17) orbits(F(r,x), x[0], 150, 200, [r, 2.5, 4], [style, dots]);
(%t17) (%o17)
The diagram so obtained displays a special property: it is self-similar. This means that
after a change of scale, the resulting picture has the same structure that the original one.
For example, if we magnify (%o17) centering the zoom on the second bifurcation of the
lower branch, we get:
(%i18) orbits(F(r,x),x[0],150,200,[r,3.5,3.6],[x,0.3,0.4],
[style,dots]);
(%t18) (%o18)
A measure of the self-similarity of a set is its fractal dimension which, unlike the dimen-
sion of a vector space, can be a non integer number. In Section 10 we show an example of
a set having non integer fractal dimension.
The period-doubling cascade and the appearance of sets with fractal dimension, are
usually signs of chaotic behavior. A dynamical system with whose evolution is described
by a continuous function f : I R I is said to be chaotic 3 if:
(a) It has sensitivity to initial conditions: a small variation in the initial condition x0 of an
orbit can produce, in the long run, another orbit far away from the original one.
3
For simplicity we consider only one-dimensional systems, but the case of multidimensional systems is
analogous. For further details on the chaos definition see [Ban 92], [Dev 89], [VB 94]
8
(b) Periodic points are dense in the phase space I of the system: in general, a set S is
dense in the set I R if for any point p I and any > 0, the interval ]p , p + [
intersects S.
(c) It has the mixing property (we also say that the system is topologically transitive): for
any two intervals J, K I there exist points of J whose orbits eventually enter K, that
is, there exists an n > 1 such that
fn (J) K 6= ,
n)
with fn = f f . This property is satisfied if and only if the system has an orbit
{fn (x0 ) : n N {0}} that is dense in I. 4
We illustrate each one of these conditions using the logistic map in the examples below.
(%i19) evolution(F(4,x),3/4,50,[style,[lines,2]]);
(%t19) (%o19)
Choosing small enough (pseudo-random) we see how drastically these orbits diverge
(we will see how to measure this divergence in section 7):
(%i20) eps:random(0.000000000001);
4
The equivalence is as follows: if the orbit of x0 is dense in I, there exists an infinity of points xn = fn (x0 )
in any pair of intervals J, K, so f is transitive. Conversely, if f is transitive, for a given interval J let {Aj }jN
be the basis of open intervals with rational end points that are contained in J; from the transitivity of f
the family of open sets Bj = pN fp (An ) is dense in J (since, if U J, there exists a number p such that
fp (U ) An 6= , that is, U fp (An ) = U Bn 6= ). From the Baire theorem, jN Bj is dense in J too. But
this intersection consists of points with dense orbits, since if x jN Bj , for each n N there is a pn N
such that fpn An . The sequence {fpn }nN has points in each An and therefore is dense.
9
(%t21) (%o21)
(b) The set of periodic points is dense in the interval I = [0, 1]. This is clearly seen in
(%o17), where the right side of the unit square is filled with periodic points.
(c) There exists a dense orbit. Again, we can exemplify this behavior with k = 4 and the
initial condition x0 = 0.2 after 50, 000 iterations. Its orbit fills the phase space:
(%i22) evolution(F(4,x),0.2,50000,[style,dots]);
(%t22) (%o22)
5
We have already seen that one dimensional continuous systems can not display chaotic behavior (nor
even periodic behavior). For autonomous systems in the plane (or second order differential equations with
time-independent coefficients), the uniqueness of solutions together with the Poincare-Bendixson theorem
rule out the existence of chaos. The problem of setting the minimal conditions to ensure the existence of
chaos is still an open question. An interesting report on this topic is [SL 00].
10
chaotic dynamics were explicitly seen, in 1963 [Lor 63]:
x = 10y 10x
y = xz + 28x y
z = xy 8z/3
To numerically study the orbits, we use the 4th-order Runge-Kutta method. The following
commands compute the orbit with initial condition (8, 8, 27) after 50 time units (with a
step of 0.01):
(%i23) numer:false$
(%i26) lsolution:rk(latractor,[x,y,z],linitial,[t,0,50,0.01])$
(%i28) load(draw)$
The following command needs that the package draw be previously loaded (do load(draw)
otherwise). Note that the output is actually a separate Gnuplot window, so (by pressing
the left button of the mouse and dragging around) the reader can rotate the whole picture
to better appreciate its details.
(%i29) wxdraw3d(point_type=none,points_joined=true,color=orange,
xlabel="x(t)",ylabel="y(t)",zlabel="z(t)",
xtics=10,ytics=10,ztics=10,points(lpoints));
(%t29) (%o29)
The phrase order within chaos is frequently found. It means that in some systems, even
though the orbits can appear unpredictable and very complex, there is some regularity. For
example, in the Lorenz system, the sensitivity to initial conditions prevents us from making
accurate predictions, but we can assert that in the long run the orbit will be restricted to a
11
bounded region of the space called an attractor 6 . This seems clear in figure (%o29), but we
can prove it analytically with the aid of Maxima. Let us consider a general Lorentz system,
where , and are parameters:
x = (y x)
y = x( z) y , (6)
z = xy z
(%i30) remfunction(x)$
(%i31) gradef(x(t),%sigma*(y(t)-x(t)))$
We consider the set of those points belonging to an orbit that, for a given instant t,
lie on the sphere with center (0, 0, + ) and radius R( + ), with R a constant to be
determined:
Differentiating equation (%o34) (using the chain rule) and substituting (6), we get:
(%i35) facsum(diff(%,t),x(t),y(t),z(t));
This looks like an ellipsoid, and we can prove it is one by completing the squares:
(%i36) factor(solve((sqrt(2*%beta)*z(t)-u)^2-u^2=
2*%beta*z(t)^2-2*%beta*(%sigma+%rho)*z(t),u));
( + )
(%o36) [u = ]
2
So, the points (x(t), y(t), z(t)) should satisfy
2
( + )2
2 2 +
2x(t) 2y(t) 2 z(t) + = 0,
2 2
which is the equation of an ellipsoid with center (0, 0, ( + )/2). The semi-axis along
directions OX, OY and OZ are, respectively:
6
Attractors are classified as strange and no strange if they have fractal or integer dimension, respectively.
In section 10 we will see how to compute the fractal dimension of an attractor.
12
(%i37) solve(1/a = sqrt(2*%sigma/(%beta*(%sigma +%rho)^2/2)),a);
| + |
(%o37) [a = q ]
2
(%i38) solve(1/b = sqrt(2/(%beta*(%sigma +%rho)^2/2)),b);
| + |
(%o38) [b = q ]
2 1
(%i39) solve(1/c = sqrt(2*%beta/(%beta*(%sigma +%rho)^2/2)),c);
| + |
(%o39) [c = ]
2
These lengths depend only on the pparameters , and . Thus, taking R large enough
+
(explicitly R > 2 max{2, 1 + , 1 + /}), we obtain a sphere containing the initial
conditions (here (x(0), y(0), z(0)) = (0, 0, 0) for simplicity) and such that when they evolve
in time, all orbits remain inside this sphere.
As already pointed, the presence of attractors having fractal structure (strange attrac-
tors) is a signal for chaotic dynamics, but it is neither a necessary nor a sufficient condition.
There are attractors derived from chaotic dynamics that are not strange (for example, in
the logistic equation with k = 4 the attractor is the whole interval [0, 1]) and there are
non-chaotic systems displaying attractors with fractal dimension (see [GOPY 84]).
7 Lyapunov exponents
We have seen that a feature of chaotic dynamical systems is the sensitivity to initial con-
ditions. Lyapunov exponents are introduced to qualitatively measure this property. The
idea is quite simple: By choosing a fixed orbit, we compare it with other orbits having close
initial conditions, and then measure the distance between them with a factor of the form
exp(t). Here is the Lyapunov exponent. If it is positive, the orbits diverge asymptot-
ically and there is sensitivity to initial conditions (greater when when is large). If the
exponent is negative, the orbits must asymptotically approximate each other and there
is no sensitivity to initial conditions. A value of = 0 indicates that the orbit considered
is a stable fixed point.
Let us consider, for simplicity, a one-dimensional dynamical system
xn+1 = f (xn )
with f : R R derivable except for a finite number of points (this is the case, for example,
of the logistic map). We consider the orbits starting at the points x0 and x0 + . After
N iterations the points on the orbits will be, respectively, fN (x0 ) and fN (x0 + ), where
fN = f f . So, after N iterations the distance between the orbits is |fN (x0 +)fN (x0 )|,
which can be written in the form
|fN (x0 + ) fN (x0 )| = eN (x0 )
13
for a suitable (x0 ) R that is called the Lyapunov exponent at the point x0 . Is in this way
that the Lyapunov exponent gives a measure of how the initial separation is amplified
when the orbits evolve.
Solving the last equation for (x0 ):
(%i40) assume(%epsilon>0,N>0)$
(%i41) remvalue(x[0])$
(%i42) solve(abs(f[N](x[0]+%epsilon)-f[N](x[0]))=
%epsilon*exp(N*%lambda),%lambda);
log |fN (+x0 )fN (x0 )|
(%o42) [ = ]
N
and taking limits with 0 and N (taking into account the continuity of log and
the definition of the derivative), we have:
1 dfN
(x0 ) = lim log (x0 ) .
N N dx
Just to show the symbolic capabilities of Maxima, we will use it to evaluate the derivative
in the last expression. First, we declare the derivative of the function f by giving it a name
(the usual f 0 ):
(%i43) gradef(f(x),f\(x))$
df
Then, we set the values x1 = f (x0 ) and f 0 (x0 ) = dx (x0 ):
(%i44) atvalue(f(y),y=x[0],x[1])$
(%i45) atvalue(diff(f(y),y),y=x[0],f\(x[0]))$
14
(%i48) define(dF(r,x),diff(F(r,x),x))$
(%i49) r:3$
(%i50) maxiter:50000$
(%i51) x[1]:random(1.0);
(%o51) .4823905248516196
(%i53) L:0$
(%i55) %lambda=L/maxiter;
For this case, r = 3, we get ' 0. The reader can experimentally check that for the logistic
map (x0 ) = , that is, the Lyapunov exponent does not depend on the initial condition
x0 ]0, 1[, it only depends on the parameter r. For values of r lesser than (approximately)
3.569945, we have that 0, but if r > 3.569945, the behavior of as function of r
becomes quite complicated.
15
If F = F (x) = dV /dx, we say that the system is conservative and the function V = V (x)
is called the potential. For example, the system
1
(t) = x3 (t) + x(t)
x
4
(%i56) V(x)=integrate(x^3/4-x,x);
x4 x2
(%o56) V (x) =
16 2
The graph of this function is:
(%i57) wxplot2d(integrate(x^3/4-x,x),[x,-3,3],[ylabel,"V(x)"]);
(%t57) (%o57)
1 1
(t) = x3 (t) + x(t) x(t)
x
4 10
The system is no longer conservative, since the damping term dissipates energy in the form
of heat. As a result, the oscillations made by the system decrease in amplitude until there is
no motion. We illustrate this by computing the trajectory with initial conditions x(0) = 3,
x(0)
= 10:
(%i58) duff:[v,-v/10+x-x^3/4]$
(%i59) icduff:[3,10]$
(%i60) solduff:rk(duff,[x,v],icduff,[t,0,100,0.1])$
(%i61) curveduff:map(lambda([x],rest(x,-1)),solduff)$
(%i62) pointsduff:map(lambda([x],rest(x)),solduff)$
16
(%i63) wxdraw2d(point_type=none,points_joined=true,
xlabel="t",ylabel="x(t)",points(curveduff));
(%t63) (%o63)
We can also represent the dynamics of the system in the plane (x, v = dx/dt) (the phase
plane):
(%i64) wxdraw2d(point_type=none,points_joined=true,
xlabel="x(t)",ylabel="v(t)",points(pointsduff));
(%t64) (%o64)
Note that this result coincides with (%o63), where it is clear that the system evolves to the
stable equilibrium x = 2, oscillating around this value with decreasing amplitude until it
stops.
The Duffing oscillator is obtained including in the previous system and oscillating force
(the forcing term) sin(t):
1 1
(t) = x3 (t) + x(t) x(t)
x + sin(t)
4 10
The effect of the forcing term is to restore the energy dissipated by the damping term.
If the frequency of the forcing term is the appropriated one, the system will oscillate in
a stable way, but if there is no synchronization with respect to the non-forced system, a
chaotic behavior will appear. For example, for = 1 starting from the unstable equilibrium
(x = 0, v = 0), after a short transient the system will evolve to a stable oscillating regime
(a limit cycle):
17
(%i65) duffing:[v,-v/10+x-x^3/4+sin(t)]$
(%i66) icduffing:[0,0]$
(%i67) sduffing:rk(duffing,[x,v],icduffing,[t,0,100,0.1])$
(%i68) cduffing:map(lambda([x],rest(x,-1)),sduffing)$
(%i69) pduffing:map(lambda([x],rest(x)),sduffing)$
(%i70) wxdraw2d(point_type=none,points_joined=true,color=magenta,
xlabel="t",ylabel="x(t)",points(cduffing));
(%t70) (%o70)
The corresponding phase plane diagram shows that the system tends to a limit cycle,
oscillating around the two stable equilibria, instead of approaching just one of them, as
happens for the non-forced case:
(%i71) wxdraw2d(point_type=none,points_joined=true,color=magenta,
xlabel="x(t)",ylabel="v(t)",points(pduffing));
(%t71) (%o71)
The behaviors considered do not exhaust the possibilities for the dynamics of the Duffing
oscillator. In the next section we will see how to analyze the chaotic case.
18
9 Poincar
e sections
In general, for a second order differential equation of the form
x
(t) = F (t, x, x)
(%i73) icduffing1:[0,0]$
(%i74) sduffing1:rk(duffing1,[x,v],icduffing1,[t,0,100,0.1])$
(%i75) pduffing1:map(lambda([x],rest(x)),sduffing1)$
(%i76) wxdraw2d(point_type=none,points_joined=true,color=coral,
xlabel="x(t)",ylabel="v(t)",points(pduffing1));
(%t76) (%o76)
Poincare introduced a very useful technique to study the dynamics in these situations.
It consists in reckoning a trajectory in the phase space (x, v, t) by using hyperplanes equally
spaced in time as check points, and then projecting the resulting points on the plane
(x, v):
Of course, if the time interval between these hyperplanes (called the Poincare strobo-
scopic sections) is T and the system is periodic with period T , we will see just a point on the
19
Figure 1: Poincare sections
phase plane. In the figure we see a quasiperiodic system: on the phase plane the trajec-
tories are circumferences, but several points can appear in the sections projection, showing
that the system oscillates between several equilibria with a frequency different from the
time interval between the Poincare sections.
When the dynamics is chaotic, the diagram obtained by projecting the Poincare sections
can be really complicated, usually displaying fractal structure.
Let us compute the Poincare sections for the case of the Duffing oscillator. First, we consider
the case of a period T = 2 corresponding to the frequency = 1 (that is, the forcing term
is sin(t)). We register the points in the orbit at time intervals of length T = 2 = 2:
(%i77) miter:25$
(%i78) %tau:bfloat(%pi)$
(%i79) sduffing2:rk(duffing,[x,v],icduffing,
[t,0,miter*2*%tau,%tau/30])$
(%i80) pduffing2:create_list(sduffing2[i],i,makelist(i*60,i,1,miter))$
(%i81) poinduffing2:map(lambda([x],rest(x)),
makelist(pduffing2[i],i,1,miter))$
(%i82) wxdraw2d(point_type=filled_circle,color=magenta,xtics=1,
ytics=1,xrange=[-4,1.5],yrange=[0,4],points(poinduffing2));
20
(%t82) (%o82)
With the exception of some sparse points representing the transient, we see that all the
points tend to a cluster (oscillations occur close to a limit cycle). To show that the most
distant points corresponds to the transient, we eliminate, for example, the first four samples
(corresponding to the sections at t = 0, 2, 4 and 6):
(%i83) transient:map(lambda([x],rest(x)),
makelist(pduffing2[i],i,5,miter))$
(%i84) wxdraw2d(point_type=filled_circle,color=magenta,xtics=1,
ytics=1,xrange=[-4,1.5],yrange=[0,4],points(transient));
(%t84) (%o84)
Of course, increasing the number of samples we get a more illustrative picture. But the
computational effort is not worth in this case. There are more interesting situations, as it is
the case of the Duffing oscillator with forcing term 2.5 sin(2t). Now the period corresponds
to the frequency = 2, that is, T = 2 2 = . We let the system evolve for a long time in
order to get a large sample via the Poincare sections:
(%i85) duffing3:[v,-v/10+x-x^3/4+2.5*sin(2*t)]$
(%i86) icduffing3:[0,0]$
(%i87) maxiter:1000$
21
(%i88) sduffing3:rk(duffing3,[x,v],icduffing3,
[t,0,maxiter*%tau,%tau/30])$
(%i89) pduffing3:
create_list(sduffing3[i],i,makelist(i*30,i,1,maxiter))$
(%i90) poinduffing3:map(lambda([x],rest(x)),
makelist(pduffing3[i],i,1,maxiter))$
(%i91) wxdraw2d(point_size=0.3,point_type=circle,
xrange=[-5,5],yrange=[-7,3],xtics=1,ytics=1,
color=coral,points(poinduffing3),grid=true);
(%t91) (%o91)
10 Fractal dimension
As we have pointed out in previous sections, the appearance of strange attractors is a usual
feature of chaotic systems. These are sets around which the orbits move asymptotically
(thus justifying the name of attractor) and frequently have fractal dimension. We will
introduce a particular notion of fractal dimension (there are other possibilities) in the case
of a two dimensional dynamical system, so the attracting set A will be a subset of the plane.
An example of this situation is given by the Duffing oscillator. The box-counting dimension
of A is defined as follows: we start with a square of side length l enclosing A. In the next
step, we divide the square in r subsquares, each having side length l/r, and so on. In the
l
kstep we have a grid with rk1 squares, each with side length k = rk1 , that cover the
set A as in (%o91). For each step k, let N (k) be the number of squares containing at least
some point of A.
Let us observe that if A were a smooth curve (and, therefore, homeomorphic to a segment
of R, to which we would assign a topological dimension 1), for a small enough value of the
side of the squares each of them would contain a piece of the curve with length as close as
we wish to the side length of the square. So, in the case of a smooth curve, we would have
lim N (k) k = L,
k
22
with L the length of the curve. In this case we say that the scale of N (k) goes as k1 ,
that is, N (k) ' k1 . Analogously, if A were a measurable set on the plane (a set having
an area and, thus, of dimension 2), we would have N (k) ' k2 . Let us note that in these
cases, that can be called regular ones, the exponent D in the relation N (k) ' kD equals
the topological dimension of the set. Then, a fractal set can be defined as a set for which
a relation of the kind N (k) ' kD holds, with D a positive real number (not necessarily
an integer). In general, we call this number D the box counting dimension of the set, and
remar that it satisfies
log N (k)
D = lim .
k log k
This is a constructive definition that suggest how to perform the calculation of the box-
counting dimension for a given set. Explicitly, we can plot log N (k) versus log k , then we
can fit the data and finally estimate D as the slope of the regression line. As an example,
let us calculate the dimension of the Duffing attractor (%i85) with this procedure. We note
that the Duffing attractor is contained in the box [5, 5] [7, 3]. We divide this box in
10 10, 20 20,..., 200 200 boxes, counting how many points are inside them. As a detail,
we first normalize the coordinates in such a way that they lie in the box [0, 10] [0, 10].
The algorithm starts with a matrix filled with zeros and changes the scale at successive
steps multiplying these lengths by 2, 3, ..., 20:
(%i92) resolution:20$
(%i94) fitdim:makelist(
[log(n)/log(10),log(boxcount[n])],n,1,resolution),numer$
(%i95) wxdraw2d(point_size=1,point_type=filled_circle,
color=dark_violet,points(fitdim));
23
(%t95) (%o95)
The first values are outliers (since the boxes are in fact too big), so we can safely discard
them. In the same way, for the last values the boxes are too small, counting nearly one
point per box, so again we can discard them. This situation, of data that gives a wrong
contribution to the estimation of the box-counting dimension, is a well known problem
discussed in the literature (see [Kli 94]); in fact, there are several algorithms aimed to
automatically selecting the most representative data, but for our (limited) purposes, we
just use the visual information in the graph (%o95). According with this, it seems a good
choice to eliminate the first 7 values and the two last ones to make the fitting. The result
is:
(%i96) fitdimension:rest(rest(fitdim,7),-2)$
(%i97) load(stats)$
(%i98) simple_linear_regression(fitdimension)$
(%i99) fiteqn:take_inference(
model,simple_linear_regression(fitdimension));
(%o100) .6534032420835236
Since our approximation is very rough, we can round-off the value so obtained. Therefore,
we can say that the fractal dimension of the Duffing attractor is approximately 0.65 (between
0 and 1, as it should be expected).
24
References
[Ban 92] J. Banks et al.: On Devaneys definition of chaos. The American Mathematical
Monthly 99 4 (1992) 332-334.
[Bri 89] K. Briggs: How to calculate the Feigenbaums contants in your PC. Australian
Mathematical Society Gazette 16 n.4 (1989) 8992.
[Bru 98] M. Bruschi: Determinantal solutions of the logistic maps. Journal of Physics A:
Mathematical and General 31 (1998) L153155.
[GOPY 84] C. Grebogi, E. Ott, S. Pelikan, J. A. Yorke: Strange attractors that are not
chaotic. Physica D 13 (1984) 261-268.
[Kli 94] B. Klinkenberg: A review of methods used to determine the fractal dimension of
linear features. Mathematical Geology 26 1 (1994) 23-46.
[Lor 63] E. N. Lorenz: Deterministic non-periodic flow. Journal of the atmospheric sciences
20 (1963) 130-141.
[May 76] R. M. May: Simple mathematical models with very complicated dynamics. Nature
261 (1976) 459-467.
[SL 00] J. C. Sprott, S. J. Linz: Algebraically simple chaotic flows. International Journal of
chaos theory and applications 5 2 (2000) 3-22.
25