Augustin Grudet

The attractor specimen: Clifford, de Jong and chaos

Two maps of the plane made of sines and cosines, iterated tens of thousands of times. Chaos, density histograms and filtering out the parameters that collapse into cycles.

  • 6 min read
  • #specimens
  • #maths
  • #simulation

This post was machine-translated from the original version.

Contents

Posts tagged maths get a specimen drawn from a strange attractor. This post’s specimen carries the label specimen 0x17da · attractor · de-jong a=2.008 b=-2.503 c=1.542 d=-0.349: a Peter de Jong map and its four parameters. The whole drawing comes down to two lines of trigonometry repeated about 80,000 times.

specimen 0x5741 · attractor · clifford a=1.061 b=-1.359 c=-0.955 d=1.62
A Clifford or Peter de Jong attractor, rendered as a density histogram. The sliders move a and b by at most ±0.2 around the specimen's values; c and d stay those of its genome.

Two maps of the plane

A discrete attractor comes from a map f:R2→R2f : \mathbb{R}^2 \to \mathbb{R}^2 that is iterated: (xn+1,yn+1)=f(xn,yn)(x_{n+1}, y_{n+1}) = f(x_n, y_n). The engine knows two.

The Clifford map, attributed to Clifford Pickover and popularised in Chaos in Wonderland:

xn+1=sin⁡(a yn)+c cos⁡(a xn)yn+1=sin⁡(b xn)+d cos⁡(b yn)\begin{aligned} x_{n+1} &= \sin(a\,y_n) + c\,\cos(a\,x_n) \\ y_{n+1} &= \sin(b\,x_n) + d\,\cos(b\,y_n) \end{aligned}

The Peter de Jong map, published in the Computer Recreations column of Scientific American in July 1987, according to Paul Bourke:

xn+1=sin⁡(a yn)−cos⁡(b xn)yn+1=sin⁡(c xn)−cos⁡(d yn)\begin{aligned} x_{n+1} &= \sin(a\,y_n) - \cos(b\,x_n) \\ y_{n+1} &= \sin(c\,x_n) - \cos(d\,y_n) \end{aligned}

Both are bounded by construction: a Clifford orbit stays in the rectangle ∣x∣≤1+∣c∣|x| \le 1 + |c|, ∣y∣≤1+∣d∣|y| \le 1 + |d|, a de Jong orbit in the square [−2,2]2[-2, 2]^2. Nothing escapes to infinity; the question is where the orbit spends its time.

Chaos and sensitivity to initial conditions

For many values of (a,b,c,d)(a, b, c, d) the orbit converges neither to a point nor to a cycle. It fills a layered set, folded onto itself, the same whatever starting point is chosen in its basin: a strange attractor. Motion on it is chaotic: two orbits starting from points infinitely close drift apart exponentially fast, until they have nothing to do with each other. This is the sensitivity to initial conditions that Lorenz brought to light in 1963 on a convection model.

The figure below measures it for the de Jong preset (2.01,−2.53,1.61,−0.33)(2.01, -2.53, 1.61, -0.33), from which this post’s specimen descends. Two orbits start 10−1210^{-12} apart.

0.0000000000010.000000000010.00000000010.0000000010.000000010.00000010.0000010.000010.00010.0010.010.11Distance between the two orbits010203040506070Iteration n0.0000000000010.000000000010.00000000010.0000000010.000000010.00000010.0000010.000010.00010.0010.010.11Distance between the two orbits0204060Iteration n
Euclidean distance between two de Jong orbits (a = 2.01, b = -2.53, c = 1.61, d = -0.33) starting from (0.1, 0.1) and (0.1 + 10⁻¹², 0.1). Computed at build time.

On a log scale the growth is roughly linear, then saturates at the size of the attractor after about sixty iterations. The average slope is the Lyapunov exponent λ\lambda; an estimate over 100,000 iterations gives λ≈0.43\lambda \approx 0.43 per iteration for these parameters, so the gap doubles about every 1.6 iterations.

In practice, a single-bit difference, around 10−1610^{-16}, becomes macroscopic in under a hundred iterations. And a Math.sin can differ by one bit between two JavaScript engines. That is why the engine computes sine and cosine with its own functions, made only of operations that IEEE 754 defines exactly (see the post on specimens). The individual orbit has no physical meaning, but the drawing has to be identical at build time and in the browser.

The density histogram

Joining successive points would only give a scribble: the orbit jumps from one end of the attractor to the other at every step. As Bourke does, we count instead how many times the orbit visits each cell of the character grid. This estimates the attractor’s invariant measure, which no longer depends on the starting point (taken in the basin) once the orbit is long enough.

That density spans several orders of magnitude: the folds concentrate the visits, the spread-out regions get few. A linear scale would show only the folds. So the engine normalises the logarithm of the count:

value(i)=ln⁡(1+ni)ln⁡(1+max⁡jnj),\text{value}(i) = \frac{\ln(1 + n_i)}{\ln(1 + \max_j n_j)},

which gives a value in [0,1][0, 1], then turned into a character by a ramp such as .·:-=+*#%@.

const norm = max > 0 ? 1 / log(1 + max) : 0;
for (let i = 0; i < out.length; i++) out[i] = out[i] > 0 ? log(1 + out[i]) * norm : 0;

The number of points is proportional to the area: 4848 per cell, multiplied by a density between 0.7 and 1.5 set by the secondary tags, so 80,640 points for a 120 × 14 banner at density 1. Before counting, the orbit runs 200 transient iterations, then 4,000 scouting ones to measure its bounding box (enlarged by 4%). If that box is clearly taller than wide (by more than 15%), the axes are swapped. The attractor is then fitted to the width of the grid, taking the 0.6 ratio of a character cell into account, with a vertical squash of at most 2.2 and a centred crop for the rest. For grids under 8 rows, such as the 3-row strips, the engine shows the band of rows with the most ink rather than the middle one, which often falls in a hole.

When chaos collapses

The seed does not draw (a,b,c,d)(a, b, c, d) from the whole space. It picks one of fifteen presets (eight Clifford, seven de Jong, most of them taken from Bourke’s pages) and adds a uniform jitter of ±0.08\pm 0.08 to each parameter. But the set of chaotic parameters is riddled with periodic windows. A small jitter can drop the system into a window where the orbit converges to a fixed point or a cycle of a few points. The specimen would then be a handful of characters on an empty background.

The coverage test

Before accepting parameters, the engine puts them to the test: 3,100 iterations from (0.1,0.1)(0.1, 0.1), the first 100 discarded, then the remaining 3,000 points placed in a 24 × 24 grid laid over their bounding box. The share of the 576 cells that get hit measures coverage. A cycle of a few points hits a few cells; a well-spread strange attractor hits many more.

Some orbits fool this first test: they look chaotic for thousands of iterations, then fall onto a short cycle, or fold back onto a small attractor in one corner of the box. So the engine measures again later in the orbit, on 3,000 points taken after 20,000 iterations: at least 20% of the cells must then be hit, and the bounding box must keep at least half the width and half the height of the first one.

for (let attempt = 0; attempt < 8; attempt++) {
  const j = attempt < 4 ? 0.08 : 0.04;
  const p = {
    type: preset.type,
    a: quantize(preset.a + range(rng, -j, j), 3),
    // b, c, d: same
  };
  if (dense(p)) return p; // early coverage > 30%, then late coverage > 20%
}
return { type: preset.type, a: preset.a, b: preset.b, c: preset.c, d: preset.d };

After four failures, the jitter is halved; after eight, the preset is kept as is. On a sample of 4,500 jitters of ±0.08\pm 0.08 (300 per preset), about 16% fail the full test, with large differences between presets: 1% around the de Jong preset (−2,−2,−1.2,2)(-2, -2, -1.2, 2), over 40% around the second Clifford preset.

Coexisting attractors

A map can have several attractors at once, for example a strange attractor and a short cycle, each with its own basin of attraction. Which one the orbit ends up on then depends on the starting point.

An earlier version of the engine did not start from the same point for the coverage test and for the drawing. Parameters could pass the test on the strange attractor, then produce an almost empty drawing because the drawn orbit fell onto the cycle. The fix is one shared constant:

/**
 * Start of every orbit. Some parameter sets have several coexisting attractors (a strange one and a
 * short cycle); starting where `coverage` checked the parameters guarantees the drawn orbit is the
 * one that passed.
 */
const START = 0.1;

On the same sample of 4,500 jitters, 105 (about 2%) change verdict depending on whether the test starts from (0,0)(0, 0) or from (0.1,0.1)(0.1, 0.1).

Symmetry and variants

The secondary tags set three things: the point density, mirror symmetry (with probability 0.25, each cell’s count is added to that of the cell mirrored across the vertical axis) and the character ramp, out of three. The type (Clifford or de Jong) and the four parameters depend only on the seed: they make up the specimen’s identity and appear in its label.

Sources

  1. P. Bourke, Clifford Attractors (2004) (Nov 25, 2026)
  2. P. Bourke, Peter de Jong Attractors (1989, images 2014) (Nov 25, 2026)
  3. C. A. Pickover, Chaos in Wonderland: Visual Adventures in a Fractal World, St. Martin's Press, 1994 (Nov 25, 2026)
  4. E. N. Lorenz, Deterministic Nonperiodic Flow, Journal of the Atmospheric Sciences 20 (1963) 130-141 (Nov 25, 2026)