Chaotic Attractors Tutorial

These, often called Strange Attractors, are iterative systems that don’t seem to go anywhere, but do (approximately) repeat. Unlike most of the formulas in UltraFractal (UF), the iterations don’t diverge to infinity or converge to a point.

A simple example is the Clifford Attractor, named after Clifford Pickover, as in Layer #1 of the upr file at the end of this tutorial. Each step makes a new point from the old (X,Y) point as follows:

```
Xnew = sin(a*Y) + c*cos(b*X)
Ynew = sin(b*X) + d*cos(b*Y)
```

Start with nearly any X and Y, repeat this for a long time, keep track of which pixel each (X,Y) point falls into, and color according to how often each pixel is hit.

Several examples can be found online, with formulas and images. Here are some sites:

http://paulbourke.net/fractals

https://anaconda.org/jbednar/clifford_attractor/notebook

https://softologyblog.wordpress.com/2017/03/04/2d-strange-attractors

My Chaotic Attractors formula is based on code by Mark Townsend, Latööcarfian Attractors in mt.ucl, much changed and augmented..

Load the upr file. There are 15 illustrative layers, all independent. Note that the fractal Formula is Pixel(jp). If Maximum Iterations is set to 1, all points are Inside, so use Inside coloring. If Maximum Iterations is set to 2 or more, all points are Outside, so use Outside coloring.

The coloring formula is Plug-In Coloring (Gradient) in jlb.ufm, which is exactly the same as Plug-In Coloring (Gradient) in Standard.ucl except for the added line, "render = false". (See “render settings” in the UF help for an explanation of why to set render to false.) The plug-in coloring is Chaotic Attractors (CA hereafter) in jlb.ulb. All the work is done in the constructor section of the coloring class (equivalent to the global section in non-class formulas).

Look at layer #1. The parameters are some of those given in the anaconda link, above.

There are two types of plug-ins, Type 1 and Type 2. Type 1 is like the Clifford example above. Type 2 is like the De Jong Attractor, named after Peter De Jong, as in layer #2.

```
Xnew = sin(a*Y) - cos(b*X)
Ynew = sin(c*X) - cos(d*Y)
```

CA generalizes these by allowing sin and cos to be replaced by any of seven “Chaos Functions”:

sin, cos, tanh, J0, J1, sinc, spower

Here J0 and J1 are Bessel functions, sort of like cos and sin except with amplitude decreasing; sinc(x) is defined as sin(x)/x; spower(x,p) is abs(x)^p with the sign of x.

Thus Type 1 is really

```
Xnew = F1(a*Y) + c*F2(b*X)
Ynew = F1(b*X) + d*F2(b*Y)
```

and Type 2 is

```
Xnew = F1(a*Y) – F2(b*X)
Ynew = F1(c*X) – F2(d*Y)
```

For convenience in using the Explore function in UF, parameters a and b in CA are packed into one complex parameter, and similarly for parameters c and d. Try using Explore to change parameters and see how the image changes. You may want to reduce “Sample Density” to make the exploration quicker.

The number of steps is “Sample Density” times the width in pixels times the height in pixels. Experiment.

Also experiment with the “Added Contrast” value. Allowed ranges are from -1 to +1. Zero gives the standard way of converting from counts to color value. Adding contrast often gives a similar result to increasing “Sample Density” and is quicker to calculate

The color index into the gradient will range from 0 to the value of the Color Density setting. All these examples use a Linear Transfer Function, but experiment. A simple gradient works well, but experiment.

Pixels with no hits will get a color index of 0, the left edge of the gradient, or the Solid Color if you check “Use Solid Background.”

Layer #2 is a Fractal Dream attractor, Type 1, with F1 = sin, F2 = sin, and abcd parameters as given in the anaconda link above.

Layer #3 is a De Jong attractor, Type 2, with F1 = sin, F2 = cos, and abcd parameters as given in the anaconda link above.

Users can choose any combination of F1 and F2 functions.

There is also an option to change the “Starting Point” (X,Y) from its default value of (0.1,0.1). I haven’t found any parameters for which this makes much difference.

More Options

Besides using Explore to change the abcd parameters, there are other ways to find new, interesting images.

On layer #1, click “More Options.” You’ll see these three new lines:

F Permutation: 1212

ab Permutation: aabb

cd Permutation: cd

These are the default settings for Type 1. Change 1212 to 2121 and aabb to baba. This means that the equations are now

```
Xnew = F2(b*Y) + c*F1(a*X)
Ynew = F2(b*X) + d*F1(a*Y)
```

where F1 is sin and F2 is cos. This gives the image in layer #1a.

Type 1 has six options for the F Permutation, six for the ab Permutation, and two for the cd Permutation, for a total of 6*6*2 = 72 possibilities for each set of abcd parameters. Experiment.

Look at layer #2. Both F1 and F2 are sin, so the F permutation changes nothing. Set the Rotation Angle on the Location tab to 135 and change the ab Permutation to abab; you’ll get the image in layer #2a,.

Look at the original layer #2 again. Try Explore with ab and with cd. I did this for some time and came up with the values in layer #2b. On the Location tab, I’ve also changed the magnification and the X/Y Stretch.

Look at layer #3, a Type 2 image. Type 2 has six options for the F Permutation, 2 for the ab Permutation, two for the cd Permutation, and 2 for exchanging ab and cd, for a total of 6*2*2*2 = 48 possibilities for each set of abcd parameters. Layer #3a is an example.

Finally, CA can generate random values for the abcd parameters and choose possibly good ones. (The method for this code comes from Mark Townsend’s mt.ucl.) The definition of “good” is having a high enough Lyapunov exponent, an Lvalue, a mathematical concept that I won’t explain here. If you are mathematically inclined, see https://en.wikipedia.org/wiki/Lyapunov_exponent for an explanation.

Goodness as determined by this mathematical criterion is not necessarily correlated with artistic goodness, so feel free to search for images with low goodness.

Layer #4 is an example. It’s Type 1 with permutations 1212, aabb, and dc. I’ve checked “Find good abcd” and “Print abcd.” Other parameters are “How many tries” (they are fast; experiment);“Range” (random values of a, b, c, and d are between -Range and +Range); how good an Lvalue is desired; and a seed for the random number generator. Press the reload symbol or Ctrl-Alt-R. (You may have to do this more than once, and I can’t explain why.) The Compiler Messages window will pop up with the message

a 1.607 b -3.688 c -2.707 d 2.748 goodness 1.39 in 2 tries

CA only prints three decimal digits; more is rarely useful. CA keeps the set of abcd values with the highest Lvalue found so far, and quits when it finds a set with the desired goodness or when it runs out of tries.

If you set the desired goodness to 3, you’ll get

Best result at try #72; goodness 2.09

a -2.899 b -4.574 c -4.676 d 2.726 goodness 2.09 in 100 tries

and a completely different image.

If you set the Range to 8, you’ll get

a 1.25 b 7.942 c -6.873 d 4.391 goodness 3.01 in 49 tries

and a completely different image.

This was using seed 12999. (Seeds have to be a positive integer. The largest integer in UF is 2,147,483,647; larger values will be rejected.) Try changing the seed. Some will give an interesting image, others will not. Some images will be almost blank, meaning that almost all the (X,Y) points lie outside the image area. Some will even be non-chaotic, but periodic, showing only a closed loop.

Layer #4a uses the abcd values from layer #4 and permutations 1122, baba, and cd. (There’s no way to copy the abcd values automatically. You have to open a new layer and type the values into the boxes.)

Layer #5 is another randomly generated one, Type 2 with J1/J0, 1122, ab, cd. Many of the seed settings give totally uninteresting images. For this one I’ve changed the magnification and the rotation angle, and increased the Sample Density and the Added Contrast.

Layer #5a is another randomly generated one, like #5, but permutations 1212.

The last five layers are randomly generated ones with different F1 and F2 combinations.

Enjoy experimenting!

CATutorialFile {

::NItWMgn2tzZTvtNOQY47Fo/HI8e2yiUfZ1F6QbKaBM6pFtnLokotZX9VlobS+3vDltTjjJd6

6ok6aP3SEnhkiikP4d4QPvlnp4Fv51viQUSVhIZ0Vvl85Vq6WJvg8BZhYE5aZuaZyUXXyShc

xSVSI8nF8bFtdJ0QtrZticpqLZ0MZJ5dFrE/NbCLYCzl5NiwrUQdJ5dyqFJ3K6e9r69tvNz4

NKZdVyo/iSuqQOfedbORdbjgwIUGlR4800Rk6GemUdbCFa4fI7kpQHtqWXBlC1y68kyVFKZD

vDq8SeTD0SrreRlS0m4OxlUyXUl46EF86XBNCYPv3iS+NStJM6USjoNbpI7fTqnPnwz/2qOl

u/SmDjCV8SYs5bFpOrmXOS7JU1t3mMqRejo4bNwjkVdycx6hyWeV3coarqrEku6CZeiPbagf

ofQEMiVvStvtFyKBv9Orj9jDjYxBPs5zKufz/RRloVm9xWeuEe0V1FwXuqF9m081sN/7VFwQ

zG/LSfzsP9uve1SetSm9WlSPFoutzkLO/4rLW3A9D97X62/XXsF/30zeULhZT6ZCMPXGNevi

XPq0P7ZffvepMbZyoPrn3QN+eMn+z3e9be3HWVlZxyH5lu3g7+oZ5tBM66EYCvpCaSoGdh9L

3FZPWXk9r0FZQXMruzUBW6il1ti+VEPsAweYxqJXE3AfZqq375f/GaiettJf++tJ8UDewSyy

NZfRTblyY/qtKfz+E71j1uYofB7HokliObjawg6CRi3eP/TLq5FJemcpTIyhxHP/gwop7VKP

NZM1xfC1J0kzZgrTgtt23Pevfm8JNNBqt9rKYyyePMPPxJyYvWxbVwGm6W3gbCYzO9GyBG70

1wmT8Ot7Q5b3BY9Oy1llwfDbG9excOsrN5LFgtkPsGER2aszISXZdNwd0fXbrV8eOx4NfWkV

5ibScJ9tbC1P2nxc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