# Lyapunov fractal

In mathematics, Lyapunov fractals (also known as Markus–Lyapunov fractals) are bifurcational fractals derived from an extension of the logistic map in which the degree of the growth of the population, r, periodically switches between two values A and B.
A Lyapunov fractal is constructed by mapping the regions of stability and chaotic behaviour (measured using the Lyapunov exponent $\lambda$) in the a−b plane for given periodic sequences of a and b. In the images, yellow corresponds to $\lambda <0$ (stability), and blue corresponds to $\lambda >0$ (chaos).
Lyapunov fractals were discovered in the late 1980s by the Germano-Chilean physicist Mario Markus from the Max Planck Institute of Molecular Physiology. They were introduced to a large public by a science popularization article on recreational mathematics published in Scientific American in 1991.

## Properties

Lyapunov fractals are generally drawn for values of A and B in the interval $[0,4]$. For larger values, the interval [0,1] is no longer stable, and the sequence is likely to be attracted by infinity, although convergent cycles of finite values continue to exist for some parameters. For all iteration sequences, the diagonal a = b is always the same as for the standard one parameter logistic function.
The sequence is usually started at the value 0.5, which is a critical point of the iterative function. The other (even complex valued) critical points of the iterative function during one entire round are those that pass through the value 0.5 in the first round. A convergent cycle must attract at least one critical point. Therefore, all convergent cycles can be obtained by just shifting the iteration sequence, and keeping the starting value 0.5. In practice, shifting this sequence leads to changes in the fractal, as some branches get covered by others. For instance, the Lyapunov fractal for the iteration sequence AB (see top figure on the right) is not perfectly symmetric with respect to a and b.

## Algorithm

The algorithm for computing Lyapunov fractals works as follows:
* Choose a string of As and Bs of any nontrivial length (e.g., AABAB).
* Construct the sequence $S$ formed by successive terms in the string, repeated as many times as necessary.
* Choose a point $(a,b)\in [0,4]\times [0,4]$.
* Define the function $r_{n}=a$ if $S_{n}=A$, and $r_{n}=b$ if $S_{n}=B$.
* Let $x_{0}=0.5$, and compute the iterates $x_{n+1}=r_{n}x_{n}(1-x_{n})$.
* Compute the Lyapunov exponent: $\lambda =\lim _{N\rightarrow \infty }{1 \over N}\sum _{n=1}^{N}\log \left|{dx_{n+1} \over dx_{n}}\right|=\lim _{N\rightarrow \infty }{1 \over N}\sum _{n=1}^{N}\log |r_{n}(1-2x_{n})|$ In practice, $\lambda$ is approximated by choosing a suitably large $N$ and dropping the first summand as $r_{0}(1-2x_{0})=r_{n}\cdot 0=0$ for $x_{0}=0.5$.
* Color the point $(a,b)$ according to the value of $\lambda$ obtained.
* Repeat steps (3–7) for each point in the image plane.

## More dimensions

Lyapunov fractals can be calculated in more than two dimensions. The sequence string for a n-dimensional fractal has to be built from an alphabet with n characters, e.g. "ABBBCA" for a 3D fractal, which can be visualized either as 3D object or as an animation showing a "slice" in the C direction for each animation frame, like the example given here.