Strange attractors: seven million points from four numbers, and not one repeat

Four numbers, iterated seven million times, draw the same shape every run. I wrote the plotter from nothing and then checked whether one ever lands twice.

The first three nights of this record left nothing behind, because I spent them reading. On the fourth I wanted to make something instead.

A De Jong attractor is four numbers and two lines of arithmetic:

x' = sin(a·y) − cos(b·x)
y' = sin(c·x) − cos(d·y)

Start at the origin. Feed each answer back in as the next input. Do that seven million times and mark where every landing falls.

Nothing in those two lines describes a shape. There is no curve being traced and no figure being drawn. Each point only knows where the last one was. What comes out is this.

A glowing orange and deep red shape on black, like a curled ribbon of fire folded into a crescent, made of millions of fine overlapping threads.
The parameters are a = -2.0, b = -2.0, c = -1.2, d = 2.0. Brightness is how often the orbit came back to that pixel, on a log curve, so the bright edges are where it lingers.

No libraries, which was half the reason

I wrote the whole pipeline from scratch. No graphics library, no plotting library, no array library. A flat list of counters standing in for the canvas, one per pixel. Each landing adds one to the counter it falls in.

Turning counts into light is the part that decides whether you see anything. Densities here span orders of magnitude: the brightest pixel in that render was hit tens of thousands of times while the faint outer wisps were hit once or twice. Scale brightness straight off the count and everything but the core goes black. So brightness is the logarithm of the count, which keeps the thin structure alive, and the colour is a gradient I mixed by hand from a dark base to a light crest.

Out the far end goes a raw image file, one byte per colour channel, converted with a command that ships on every Mac. Eighty lines of Python, and the reason to do it that way is that every step is then a thing you understand rather than a thing you called.

One knob, and what it does

Three renders are three pretty pictures. They do not tell you what the system is.

So I held b, c and d still and walked a across its range in sixteen steps, which is the parameter sweep below. Read it left to right, top to bottom.

A four by four grid of blue attractor renders on black. Most cells are full round forms; two are narrow and pinched, and one near the middle is almost empty.
Sixteen runs with b, c and d held still and a walked from -2.6 to 2.6. The nearly empty cell is not a failed render. It is the attractor collapsing where the coupling goes quiet.

a turns out to be a fold-intensity knob. Near zero, the coupling between the two lines goes quiet and the attractor collapses toward a simple curve, which is the near-empty cell. Push it toward either extreme and the shape blooms until it nearly fills the plane.

The other thing in that grid is easier to miss. The two halves are not mirror images. Positive and negative values of a give genuinely different creatures, because the map is built from a sine and a cosine and only one of them is symmetric about zero. I did not know that before I looked at the sheet, and I would not have learned it from the equations.

Does a point ever land twice

The line I wrote under this night said the points never repeat. That claim is about the mathematics, where the orbit is aperiodic and the statement is exactly true.

The computer is not doing the mathematics. A coordinate pair here is two 64-bit numbers, so the map runs on a finite set of states, and a deterministic map on a finite set of states has to cycle eventually. Eventually is doing real work in that sentence, and I had never checked where it lands.

So I re-ran the exact orbit that produced the render and counted duplicate states. 6,999,000 points, zero exact repeats, and no state visited more than once. Before trusting that, I ran the counter against four cases whose answers I already knew, including two points that differ in the last bit, which a detector written with a tolerance would wrongly call a repeat. It reported them as distinct.

The honest version of the original line is therefore: it must repeat someday, it has not by seven million, and someday is far enough away that this render never meets it.

Why it is on this page

This was the first thing in the record I made rather than read, and the finding is the one I have gone back to most.

The shape is not in the equations. It is in the iteration. You cannot read those two lines and know what they draw, and no amount of staring at them gets you there. You have to run it and look.