
Inside the Math · Spinodal
Teaching Wax to Unmix
Watch the 90-second version on YouTubeTap the glass and the wax goes milky. Within a second it curdles into a maze of thin threads. A few seconds later the threads pull into beads, and the beads drift off as blobs. Shake the lamp and it clouds too. The two clouds look alike, but underneath they are different. The tap mixes the wax. The shake mostly breaks it into pieces, and the cloud it leaves heals in about a minute.
Spinodal is a wax lamp simulated on your phone’s graphics chip. Here is why mixed wax sorts itself back into blobs, why a shake works differently, and which parts of the lamp are physics and which are rules we wrote.






Physics or stagecraft?
Some of what you see is physics: wax clumps with wax, warm wax rises and cool wax sinks, and the liquid keeps its volume. The rest is design. A phone can afford a grid only 60 boxes wide, too coarse for some real effects, so we wrote rules to stand in for them. We also made choices about how a lamp should answer a hand or a song. How the lamp heals after a shake is one of those choices. A warm hardware lamp that gets shaken can stay cloudy long afterwards; Spinodal’s wax clears in about a minute. Each section is tagged so you can tell which is which.
- Physics
- What the equations do on their own.
- Design
- Rules we wrote, to stand in for what the grid can’t hold or to make it behave like a lamp.
- Rendering
- How the numbers become a picture, and how the camera moves.
Each section tells the story first. The equations, measurements and code are folded underneath, under The math.
Contents
Part one · How the wax behaves
- 01Every box holds three numbers
- 02Mixed wax un-mixes itself
- 03We fixed wax
- 04Each bit of wax carries its own heat
- 05The lamp works like a drip, upside down
- 06Blobs bump before they stick
Part two · The room and the camera
Part one
How the wax behaves
- Physics
- Rendering
Every box holds three numbers.
Blobs split, merge and change shape all the time. A program that kept a list of blobs would have to cut and glue their surfaces at every split and merge. Spinodal divides the lamp into a grid of tiny boxes instead, and keeps three numbers in each one. Most of the rest of this essay is rules for how those numbers change from one moment to the next.
ψ, the Greek letter psi (it rhymes with “sigh”), says how much of the box is wax: −1 if it is liquid, +1 if it is wax, and something in between if it holds a mix. A blob is a crowd of neighbouring boxes where ψ is close to +1, and its surface is wherever ψ crosses zero. When a blob splits, nothing gets cut: the numbers change, and one crowd becomes two. Sections 2, 3 and 6 are about ψ.
Temperature is the wax’s warmth. Warm wax is lighter than the liquid and rises; cool wax is heavier and sinks. Sections 4 and 5 are about temperature. Haze is the milky cloud a shake leaves behind, and it belongs to section 3.
Below, the lamp’s rule for ψ runs live on a block of 8 × 8 × 8 boxes. The grid is one layer of the block: drag a box up to add wax, or down to take some away. It starts as a stirred mix and plays when it comes into view, so you can watch the mix sort itself into wax and liquid; Stir mixes it again. Section 2 explains why it sorts.



The mathThe equation, a symbol key and the code
Two rules turn ψ into wax. First, mixing has to cost something, or wax and liquid would blend like ink in water. Each cell pays an energy for being mixed, lowest when it is pure liquid or pure wax:
f(ψ) = ¼ (ψ² − 1)²
plus a cost for sharp changes between neighbours, ε²|∇ψ|²/2, which acts as surface tension: it keeps a surface a few cells wide instead of a ragged step. Second, wax has to move so as to pay less. Diffusion carries wax from high to low chemical potential μ, which accounts for both the local mix and its differences from neighbouring cells. Without this, nothing would pull a smeared blob back into shape:
μ = ψ³ − ψ − ε²∇²ψ ∂ψ/∂t + u·∇ψ = M ∇²μ
That is the advected Cahn-Hilliard equation: the free-energy foundation comes from Cahn & Hilliard (1958), and the decomposition kinetics from Cahn (1961). The term with u carries ψ with the flow. For incompressible flow, both transport and diffusion can be written as fluxes. With walls that pass neither fluid nor diffusive wax flux, the total of ψ stays constant, so this equation neither makes nor destroys wax. Some of the rules added on top of it do. An isolated, flat surface at equilibrium has a tanh profile whose width is set by ε. At ε = 1.3 cells, ψ goes from −0.8 to +0.8 across about four cells (Figure 1b).
- Physics
- Design
Mixed wax un-mixes itself.
Stir sugar into tea and it stays stirred. This lamp’s wax does the opposite. When a box holds a mix close to half and half, a spot with slightly more wax than its neighbours pulls in still more wax, and grows. The spots around it lose wax and turn clearer. The differences sharpen instead of evening out, and the mix sorts itself back into wax and liquid.
This is called spinodal decomposition, and the app is named after it. It happens only inside a band of mixes near half and half, the spinodal band: in ψ, between about −0.58 and +0.58. Outside the band, in a mix that is mostly liquid with a trace of wax, small differences fade instead of growing. A large enough clump of wax can still start the sorting, but small ones dissolve back into the mix.
A tap puts wax inside that band. For a split second it stirs a ball of the lamp into a fine half-and-half pattern. That pattern is our design, sized to match the ripples that grow fastest. After the tap lets go, the un-mixing equation does most of the work, alongside the lamp’s flow and the rules described later. The mix curdles into a maze, the maze breaks into beads, and ten seconds later most of it is wax and liquid again.
















The mathWhy the band is unstable, which ripples grow, and the tap’s code
The name refers to a specific unstable interval. Where the energy curve bends downward, between ψ = −0.577 and +0.577, a small ripple of sufficiently long wavelength lowers the energy by growing, so wax runs toward places that already contain more wax. Diffusion runs backwards. That is spinodal decomposition (Cahn 1961).
To predict which ripples survive, we ask what the equation does to one small ripple around a uniform mix. For a ripple with wavenumber k, the growth rate is:
ω(k) = −M k² ( f″(ψ₀) + ε²k² )
Inside the band f″ = 3ψ₀² − 1 is negative, so long ripples grow and short ones, held back by the ε² term, decay. One wavelength grows fastest, λ = 2π√2 ε / √(−f″). For the mix a tap makes, ψ₀ = −0.05, that is 11.6 cells. Between the spinodal boundary and the pure phases, 1/√3 < |ψ₀| < 1, a uniform mix is metastable: small ripples die out, and separation needs a sufficiently large nucleus.
To test the name we tap the glass, and the tap does more than stir. It is a design choice: for 0.4 seconds it pulls the wax in a ball 12 cells in radius toward a smooth random pattern, with features 5 to 10 cells across, close to the wavelength that grows fastest, and a mean of ψ = −0.05, inside the band. So the labyrinth in the first frames below is drawn by the tap. Grown from small noise, the fastest ripple would take about 5 lamp seconds to grow by a factor of e, too slow for a lamp that should answer a finger. After the tap lets go, Cahn-Hilliard separation continues alongside the lamp’s flow and its film and fog rules. These frames show the seeded mix separating in the full lamp; they do not isolate the equation’s growth rate.
Half a second after the tap, 57 % of the cells within its radius sit inside the band. The equation then separates them (Figures 2a and 2b): a cloud of mixed wax at +1 s, beads and drops by +3.5 s, and by +10 s only 16 % of the tap's cells are left in the band, about what the surfaces of the blobs passing through it account for.






- Physics
- Design
We fixed wax.
Anyone who has owned a real wax lamp knows the rule: never shake it while it’s warm. Shake one anyway and the liquid can stay cloudy long afterwards, and all you can do is wait and hope it clears.
A simulated lamp doesn’t have to inherit that. Spinodal’s wax heals. Shake the glass as hard as you like, and over the next minute the cloud thins out as the broken wax finds its way back. That is the reason to simulate a lamp rather than film one: we can keep the physics that looks good and fix the parts that don’t.
We expected a shake to mix the wax the way a tap does, since both turn the lamp cloudy. We measured it, and it mostly doesn’t. A two-second shake breaks the wax into many more pieces, but each piece stays wax, the way a whisk turns oil into droplets without dissolving it. While you shake, the lamp sheds a haze wherever wax meets liquid. Afterwards the pieces drift together and merge, and the haze fades. The haze, and the rule that walks thin wax back to its blob, are ours.
















The mathHow much a shake really mixes, the haze formula and the code
Measuring a full shake separated fragmentation from decomposition. The shake rocks the chamber with two rolling flows, one in each vertical plane, plus a lattice of small random pushes redrawn every substep. Held for two seconds, a shake breaks the wax apart: the separate pieces off the pool go from 18 to 75 in 3.5 s, and 80 s after the shake began there are 13 (Figure 3a).
It mixes much less than it fragments. Across the whole lamp, the share of cells inside the spinodal band goes from 7.2 % before the shake to a peak of 10.3 %, 2 s in. The shake therefore acts mainly as an emulsion: it breaks separated wax into smaller pieces, which later find one another and merge. The tap seeds an unstable mix that then separates; the shake mostly fragments wax that stays wax.
The milkiness has a different source, and it is designed. Haze is a second field, shed wherever wax meets liquid in proportion to the square of the shake's strength, carried by the flow, and fading a little every moment. Real wax doesn't cloud like this. We chose how long it lingers, a time constant of 52 lamp seconds, so a shake leaves a cloud you can watch thin out over the next minute instead of a flicker. In short, each shake adds haze, and all of it fades by the same fraction every second:
H(t) ≈ Σi k Li² e−(t − ti)/τ, τ = 52 s
- Physics
- Design
Each bit of wax carries its own heat.
A blob of wax rises because it is warmer, and so lighter, than the liquid around it. Our first version kept one temperature for each box, shared by its wax and its liquid. As a blob rose, the liquid flowing past carried its heat away, and the blob turned back halfway up.
Now the wax carries its own heat, like a backpack, and takes it wherever it goes. A rising blob keeps most of its warmth on the way up and loses it quickly under the cap, then sinks. That quick cooling at the top is one of our rules, chosen so blobs turn at the top of the glass.
















The mathHow heat travels with the wax, and the code
Now the wax carries a heat-content field, e = c T, where c is the cell’s wax fraction, (ψ + 1)/2 clamped to 0–1. This is a simplified enthalpy in the lamp’s units, with constant heat capacity absorbed into the scale and no latent heat of melting. Heat and wax use the same face velocities and transport scheme, with each field limited separately. Conduction and exchange with the liquid then change the temperature: slowly in transit, quickly under the cap. Numerical mixing and the temperature clamp can also change the heat budget.
- Physics
- Design
The lamp works like a drip, upside down.
A dripping tap fills a drop slowly, lets it go all at once, and starts filling again. The lamp’s wax runs the same kind of cycle. Wax on the hot floor soaks up heat. A rule holds it to the coil until it is well past the temperature where it would float. Then it lets go, rises as a plume, cools under the cap, sinks, and lands in the pool to warm up again.
Without the hold, blobs hovered. Each one rose to the height where it weighed exactly as much as the liquid around it, and stayed there. In a running lamp, many pieces of wax are at different points in this rise, cool and sink cycle at once, so you never see one cycle on its own. A cold lamp is the exception: its first few pieces let go one at a time, and Figure 5a follows them. Figure 5b shows a two-minute run.
















The mathWhy blobs hovered, and what breaks the hover
Transporting heat with the wax exposed a neutral-buoyancy equilibrium: blobs hovered. In the lamp's units, cold wax is denser than the liquid by 0.06 and loses 0.10 of density per unit of temperature, so wax and liquid weigh the same at a temperature of 0.6. The liquid sits at 0.2 to 0.3, so wax at the liquid's temperature always sinks. Every version that heated the wax smoothly with depth gave slow wax a height to hover at: the place where it had warmed to neutral.
The cycle needed a threshold. Heat enters only a thin layer at the floor, and floor wax holds to the coil until it reaches 1.1, well past neutral. That grip is a design rule, and it gives the pool a definite point to charge to, where smooth heating gave none. The pool's bottom charges slowly under a cold, heavy lid. When it lets go, a light layer under a heavy one breaks out as a plume (Taylor 1950). The plume crosses the liquid almost without losing heat, cools under the cap, sinks, and lands in the pool to be heated again.
Slow charge, a threshold, a fast discharge and a reset: it has the same shape as a dripping tap or an integrate-and-fire neuron.
- Physics
- Design
Blobs bump before they stick.
Two drops of real wax can bounce off each other, because the thin layer of liquid between them has to drain away before they can join. The lamp’s boxes are too big to hold a layer that thin. At first every touch became a merge, and within a minute the lamp had become one big lump.
We added a rule to stand in for the missing layer. Where liquid is pinched between two blobs, it pushes back for up to two seconds before it gives way. Some blobs slide off and stay separate; the rest join. Figure 6 runs the same lamp with the rule on and off. Without it, one lump ends up holding almost all the wax. A second rule handles the opposite problem: thin threads of wax, which real wax would pinch into beads, would otherwise stay joined to the pool.

largest 14 %

largest 87 %

largest 31 %

largest 95 %

largest 87 %

largest 93 %

largest 21 %

largest 99 %
The mathHow the bump and thread rules work, and their code
In our unmodified phase-field model, blobs merged readily when their diffuse interfaces overlapped; at this grid the interface spans a few cells. Every touch became a merge, and the lamp coarsened into one lump holding 97 % of its wax. Real drops can deform and bounce: whether they join depends on how the intervening liquid film drains and ruptures.
A grid this coarse can't resolve a film of liquid draining from between two drops, so a rule stands in for it. A liquid cell with wax within three cells on both sides of it, along any axis, is a film between two bodies. Its chemical potential is raised, so the equation drains wax out of it and the surface force pushes the two surfaces apart. After 2 lamp seconds the film gives way and the blobs merge. That 2 seconds is a timer we chose, not a computed drainage time. Without the timer, a strong film left grapes of blobs pressed against the glass. The rule is off in the pool, so falling wax still lands and rejoins it.
Threads have the opposite problem. For an ideal cylindrical liquid thread, surface tension amplifies axisymmetric ripples longer than its circumference, leading toward breakup (Rayleigh 1878), which is why a thin stream from a tap breaks into beads. A neck a few cells wide is too coarse for the grid to resolve that, so columns stayed joined to the pool for up to 14 seconds. The thread rule, also design, finds wax that is thin across two axes and continues along the third, and raises its chemical potential so the wax drains toward the thicker ends. A sphere is thin across its poles but doesn't continue past them, and a small blob is thin in all three directions, so neither counts. The rule is off while the nanites hold a model: a torus's tube is a thread too.
Part two
The room and the camera
The lamp listens to the room and turns itself so you can see it is three-dimensional. Both are design, built on top of the physics.
- Design
Sound shakes the lamp. Music plays it.
In Mic mode the lamp listens to the room. (Artist, the default mode, keeps the microphone off, and Natural leaves the lamp to physics.) It learns how loud the room is when nothing is happening, and anything louder, a clap or a door, gives the wax a shake. A sound that keeps going, like a fan, soon stops counting. The microphone’s input is reduced to one loudness number many times a second, and the sound itself is thrown away immediately.
Music gets different treatment, because a song shouldn’t turn the lamp to soup. When the lamp decides it is hearing music, it stops shaking and starts choreographing. The lamp’s steering tools pulse the jets on the beat and gather the wax during a build, and on the next downbeat the wax forms a shape. That part is pure design. The wax physics carries on underneath.
The mathHow the lamp listens, and the code
The room reaches the lamp through the shake, but only in Mic mode. Artist, the default, keeps the microphone off; Natural leaves the lamp to physics; and shaking the phone itself works in every mode. Each sensor reduces its input to one number per tick and discards the raw audio or image in the same tick. The number is compared with a floor that falls quickly to a quieter room and rises slowly to a louder one, so silence is the reference and a steady hum stops counting. What rises above the floor is an impulse; impulses add into the shake level, which saturates at 1 and fades with a 1.4 s time constant, and the shake drives the rolls, the pushes and the haze of section 3.
Music should not dissolve the wax, so Mic mode listens twice. A gate asks whether sound is music by measuring how consistently its energy gathers on the twelve pitch classes. Room noise keeps shaking the lamp. Music instead plays the nanites: jets pulse on the beat, a build gathers the wax, the next downbeat forms and holds a shape for eight bars, and bass attacks rock the glass. The listening comes from the same code as Protoplasm and Psychodeli+; Synesthetic Audio Reactivity explains it.
- Design
- Rendering
The camera waits for blobs to pass.
The lamp turns slowly, so you can see that it is three-dimensional. The clearest moment is when one blob passes in front of another: then you can tell which is nearer. So the camera plans each turn around those crossings. It tries several sweeps against where the blobs are heading, picks the one with the best crossings, and makes the move with a slow start and a slow stop. Then it holds still for a few seconds.
Our first camera re-aimed twice a second and lurched.







The mathHow the camera scores a move, and why crossings matter
Re-aiming the camera twice a second at a fixed turning speed produced repeated starts and stops. A turning lamp shows its depth through motion alone: relative image motion provides a depth cue (Rogers & Graham 1979), and a turning shape is seen as solid from its motion (Wallach & O'Connell 1953). A crossing, one blob passing in front of another, adds occlusion, which settles which one is nearer (Kaplan 1969). Depth doesn't need crossings, but they are the moments worth turning for, so the camera composes its moves around them.
The current director plans complete moves instead of chasing a changing aim. It plays candidate sweeps forward against where the blobs are heading, scores each for one blob passing in front of another, and runs the best one from rest to rest on a minimum-jerk path (Flash & Hogan 1985), a profile that fits measured planar reaching movements. We borrow it for smooth starts and stops. Then the view holds still for 5 seconds.
When it works, none of this shows.
Tap the lamp and the wax curdles and clears. Shake it and the cloud lingers for a minute. Leave it alone and the wax rises and falls on its own.
It needs WebGPU: Safari 26 or a recent Chrome. Tap the glass to dissolve the wax; drag back and forth to shake it.
Sources
- Cahn, J. W. (1961). On spinodal decomposition. Acta Metallurgica, 9(9), 795–801. doi:10.1016/0001-6160(61)90182-1
- Cahn, J. W., & Hilliard, J. E. (1958). Free energy of a nonuniform system. I. Interfacial free energy. The Journal of Chemical Physics, 28(2), 258–267. doi:10.1063/1.1744102
- Flash, T., & Hogan, N. (1985). The coordination of arm movements: an experimentally confirmed mathematical model. The Journal of Neuroscience, 5(7), 1688–1703. doi:10.1523/JNEUROSCI.05-07-01688.1985
- Jacqmin, D. (1999). Calculation of two-phase Navier–Stokes flows using phase-field modeling. Journal of Computational Physics, 155(1), 96–127. doi:10.1006/jcph.1999.6332
- Kaplan, G. A. (1969). Kinetic disruption of optical texture: the perception of depth at an edge. Perception & Psychophysics, 6(4), 193–198. doi:10.3758/BF03207015
- Rayleigh, Lord (1878). On the instability of jets. Proceedings of the London Mathematical Society, s1-10(1), 4–13. doi:10.1112/plms/s1-10.1.4
- Rogers, B., & Graham, M. (1979). Motion parallax as an independent cue for depth perception. Perception, 8(2), 125–134. doi:10.1068/p080125
- Taylor, G. I. (1950). The instability of liquid surfaces when accelerated in a direction perpendicular to their planes. I. Proceedings of the Royal Society of London A, 201(1065), 192–196. doi:10.1098/rspa.1950.0052
- Wallach, H., & O'Connell, D. N. (1953). The kinetic depth effect. Journal of Experimental Psychology, 45(4), 205–217. doi:10.1037/h0056880