No. 084 · Synchronization

10,000 fireflies learn to blink together

10,000 fireflies, each with its own clock. Once they start nudging toward the crowd, the sync score r climbs from 0.007 to 0.9 in under 5 seconds.

dθ/dt = ω + K · r · sin(ψ − θ)

Picture 10,000 fireflies, each with its own internal clock that goes round and round. A firefly flashes every time its clock passes the top. Every clock runs at its own natural speed: 0.8 flashes a second on average, give or take about 0.12 (a bell curve, drawn at random from a fixed seed), and the clocks start at random points. Each one is drawn in the colour of its speed, and its flash glows and fades.

Ignoring each other

For the first 4 seconds the fireflies don't interact, so they all twinkle at random. The video measures how much in step they are with one number, r: the length of the average of all 10,000 clock hands. If they all pointed the same way r would be 1; at the start it's 0.007.

Nudging toward the crowd

Then each firefly starts nudging its clock toward the crowd's average phase, harder the more in step the crowd already is. That's the Kuramoto model. The coupling is K = 3, about 2.5 times the critical value K_c ≈ 1.2: below K_c the fireflies would stay mostly scattered, above it a group locks together and pulls in the rest.

Here it's fast. The graph of r climbs steeply and passes 0.9 at 8.8 seconds, less than 5 seconds after the coupling switched on, and settles at 0.96. By the end every one of the 10,000 has locked to the common beat, and the last frame is the whole field flashing at once. Real fireflies in parts of Southeast Asia, and the pacemaker cells of the heart, sync up in much the same way.

The equation

dθ/dt = ω + K · r · sin(ψ − θ)

θ is a firefly's clock, ω its own speed, and r and ψ are the length and direction of the average of every clock hand. The sine term speeds a firefly up when it's behind the crowd and slows it down when it's ahead.

Part of Synchronization: Things with their own rhythm that nudge each other, until they move or blink as one.

Use this picture

SVGJPG

Free to reuse, also commercially, under CC BY 4.0. Credit “What Math Means” with a link to whatmathmeans.dev/v/10000-fireflies-learn-to-blink-together.