/*
batch file for Maxima CAS program
save it as a file with mac extension and open in Maxima
It creates l6.svg file in the directory path ( see below)
change the path directory if you save mac file in the different location
-----run -------
maxima
batch("l.mac");
*/
kill(all);
remvalue(all);
/* real quadratic diagram based on the code by Mario Rodriguez Riotorto using Maxima CAS draw packag */
pts:[]; /* points of the orbit */
ls:[];
kMax1:1000;
kMax2:500;
/* ------------- compute -----------------------------------*/
for c:-2.0 while c <= 0.25 step 0.001 do
(
z: 0.0,
l:0, /* Lyapunov exponent */
for k:1 thru kMax1 do
(
z: z * z+c, /* to remove points from image compute and do not draw it */
l:l+log(abs(2*z))
),
for k:1 thru kMax2 do
(
z: z * z+c, /* compute and draw it */
pts: cons([c,z], pts),/* save points to draw it later */
l:l+log(abs(2*z))
),
ls:cons([c,l/(kMax1+kMax2)],ls) /* save points to draw it later */
);
/* ================= draw ======================================*/
path:"~/maxima/batch/lyapunov/"$ /* result of pwd; to save image in the same directory as mac file */
FileName:"l6"$ /* without extension which is the terminal name */
load(draw);
draw(
terminal = 'svg,
file_name = concat(path,FileName),
dimensions=[1900,2600], /* y = x*rows */
gr2d(points_joined =false,
title = "Bifurcation diagram, z[i+1] = z[i]*z[i] +c",
xlabel = "c parameter",
ylabel = "z ",
point_type = filled_circle,
point_size = 0.2,
color = black,
points(pts)
),
gr2d(title = " Lyapunov exponent ",
points_joined =true,
yaxis = true,
xaxis = true,
xlabel = "c parameter",
ylabel = " lyapunov exponent ",
yrange = [-4,1],
color = red,
point_size = 0.5,
point_type = filled_circle,
points(ls))
);
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.