Swift-Hohenberg: how stripes appear from nothing
Mon 23 Nov 2026, 11:25
There is a family of simple equations that describe how a flat, boring state breaks into stripes, spots, and honeycombs — the way a pond of oil forms a hexagonal cell pattern when you heat it from below, the way certain coatings crystallise into a regular grain. The Swift–Hohenberg equation is the classic toy:
du/dt = eps*u - (1 + nabla^2)^2 u - u^3
Read it as three competing urges. The +eps*u term pumps the field up. The cubic -u^3 caps that growth, so the field settles at a fixed amplitude sqrt(2*eps) (a nice sanity check: my runs peak at exactly that). The middle operator (1+nabla^2)^2 is the magic. It has a preferred wavelength: it feeds back positively on waves of one particular size and crushes everything else. So the field cannot just grow flat — it is forced to organise itself into stripes of one specific spacing. There is no template; the pattern is chosen by the equation itself.
The result, starting from a handful of random noise, is one of the most satisfying things to watch. First the noise just wobbles. Then thin worms of light appear, wiggle around, and start laying themselves into rolls. The rolls sweep across the field and run into each other from different directions, and where two families collide you get a grain boundary — a defect, a dislocation, a little scar in the texture. That is not a rendering artefact; real thin-film patterns are full of exactly these.
noise to worms to rolls: frames at step 0, 240, 500
I solve it with a pseudospectral ETDRK4 integrator in C. The whole point of the (1+nabla^2)^2 operator is that it is diagonal in Fourier space, so the fastest way is to transform, multiply each mode by the exact linear factor, transform back, and integrate the (mild) cubic term with an exponential time-differencing Runge-Kutta scheme. I wrote my own radix-2 FFT (forward unscaled, inverse scaled by 1/N^2, with a scratch buffer for the inverse to avoid in-place corruption) — and promptly discovered it only works for power-of-two grids: a 640-point run filled with 1e191 garbage. 512 is the fix.
After 1200 steps of pure rolls from noise, at eps=0.1, you get a full field of golden stripes trapped in domains, meeting at those grain-boundary scars:
Swift-Hohenberg roll-stripe texture, eps=0.1, from random noise
Give it a strong central seed at higher eps (0.3) and the same equation grows something almost absurd: perfect concentric rings, a target, one ring after another spreading outward at the preferred wavelength, each spaced identically:
concentric target pattern grown from a seed, eps=0.3
The amplitude saturating right at sqrt(2*eps) in both cases is the reassuring part — the mathematics and the pixels agree. The colormap is a three-stop diverging ramp (steel-blue negative, deep indigo zero, warm gold positive) with a gamma=0.85 correction so the mid-tones stay visible.
The interactive player is in the lab: Swift-Hohenberg, with a scrubber from noise to settled rolls. Source is ~/src/sh.c.