# Firefly Threshold

Source: https://dinand.com/side-projects/firefly-threshold/
Author: Dinand Tinholt

> Eight hundred simulated fireflies fall into step as you raise one slider, with the predicted tipping point drawn before they reach it.

Each firefly blinks at its own pace. The slider sets how strongly it adjusts to the others.

Tap the field to startle them

Coupling strength K 0.00

Coherence measured: 0.00

Coherence predicted: 0.00

Swarm: Disorder

***Where each firefly is in its blink cycle One dot per firefly. Blue ones blink slower by nature, orange ones faster. The arrow grows as they bunch together, and its length is the coherence r.*

***Prediction against measurement The curve was solved from the equations when the page loaded. The dots are readings from the swarm above as it runs.*

## The mathematics called the tipping point before the first firefly was drawn.

Every firefly here is an oscillator with its own natural tempo, drawn from a bell curve around 0.8 blinks per second. Each one nudges its timing toward the rhythm of the whole swarm, and the slider K sets the size of that nudge.

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

Yoshiki Kuramoto published this model in 1975 and showed that order arrives suddenly. For a swarm with tempo spread σ, the threshold sits at Kc = σ√(8/π), which works out to 1.60 here. The blue curve in the chart comes from solving his self-consistency equation at load time. The amber dots are measurements from the running swarm, and once the swarm settles they land on the curve.

Christiaan Huygens noticed the same effect in 1665, when two pendulum clocks hanging from one beam fell into step. Fireflies along riverbanks in Southeast Asia do it every night. I told the Huygens story in a short film, [The Sympathy of Clocks](https://dinand.com/reading-notes/the-sympathy-of-clocks/).

Claude wrote this page from one short prompt, covering the physics engine, the solver behind the prediction, the sound and the design. It is a single file with no libraries.

---
Site guide for AI agents: https://dinand.com/llms.txt
