In 2003, Eric Bjorklund was working on the Spallation Neutron Source (SNS) at Oak Ridge National Laboratory. His problem was practical and precise: how do you distribute k high-voltage power supply pulses as evenly as possible across n time intervals in an accelerator's timing system? He wrote an algorithm to solve it and published it in two internal technical notes.
He had no idea he had also written a machine for generating the tresillo, the bossa nova, the clave, and the bell patterns of Ghanaian Ewe music.
The Pattern That Appears Everywhere
Consider the tresillo, the foundational rhythm of Cuban son and countless other Caribbean and Latin forms. Three beats across eight steps: [x . . x . . x .]. That 3+3+2 feel shows up in Elvis Presley's "Hound Dog," in the atoke bell of West African Sohu dance, in the habanera, in reggaeton. Across cultures that had no contact with each other, musicians landed on the same rhythmic pattern.
The Euclidean algorithm explains why.
In 2005, computer scientist and music theorist Godfried Toussaint published "The Euclidean Algorithm Generates Traditional Musical Rhythms" in the proceedings of the Bridges conference in Banff. He had found Bjorklund's work and recognized that the algorithm generating maximally even pulse distributions in accelerator timing systems produced the same binary sequences as the rhythms he had been cataloguing from ethnomusicology literature. The match was not approximate, it was exact.
How E(k, n) Works
The notation E(k, n) means: distribute k onsets across n steps as evenly as possible. The algorithm is recursive, and it's the same process as Euclid's method for finding the greatest common divisor, repeated subtraction until nothing remains.
Starting with k groups of [x] and (n-k) groups of [.], the algorithm repeatedly distributes the shorter sequences among the longer ones, carrying the remainder forward. Concretely, for E(3, 8):
Step 0: [x][x][x] + [.][.][.][.][.] → 3 ones, 5 zeros
Step 1: [x.][x.][x.] + [.][.] → move zeros into ones
Step 2: [x..][x..][x.] + remainder → carry [x.] forward
Step 3: [x..x..x.] → done
Result: x . . x . . x ., the tresillo. The algorithm terminates when either the remainder is empty or has length 1. That termination condition mirrors how Euclid's GCD algorithm terminates.
Because the math is identical, Toussaint named these Euclidean rhythms.
The Rhythms That Fall Out
The table of Euclidean rhythms reads like a syllabus in world percussion:
| Pattern | Steps | Groove name | Origin |
|---|---|---|---|
| E(3, 8) | [x . . x . . x .] | Tresillo | Cuba, West Africa |
| E(5, 8) | [x . x x . x x .] | Cinquillo | Cuba |
| E(7, 12) | [x . x x . x . x x . x .] | Gahu bell | Ewe people, Ghana |
| E(5, 16) | [x . . . x . . x . . x . . x . .] | Bossa nova | Brazil |
| E(4, 9) | [x . x . x . x . .] | Bendir | North Africa |
E(5,8) and E(3,8) share the same pulse total: 3+5=8. Cuban music frequently layers them both, with the right phase offset the cinquillo fills in the gaps of the tresillo, covering all eight positions. The interlocking works not by convention but by the arithmetic that built both patterns.
Maximal Evenness and Why It Grooves
The property that makes these rhythms work musically is what music theorists call maximal evenness: given k onsets in n steps, spread them so the distances between consecutive onsets differ by at most one. For E(3,8), the distances are 3, 3, 2, as uniform as three things can be in eight slots when 8 is not divisible by 3.
The concept was formalized by music theorists John Clough and Jack Douthett for scales before Toussaint applied it to rhythm. The diatonic scale is a maximally even set: 7 notes in 12 semitones. So is the pentatonic scale: 5 notes in 12 semitones. The mathematics that makes the major scale feel stable and navigable is the same mathematics that makes the tresillo feel like it wants to move forward.
Rhythms that aren't maximally even tend to cluster beats together or create large empty gaps, neither of which generates groove. A robotic 4-on-the-floor pattern (E(4,8) = x . x . x . x .) is maximally even but maximally boring, equally spaced in a cycle that divides cleanly. The interesting Euclidean rhythms come from irreducible ratios like 3-in-8 or 5-in-16, where the algorithm must make trade-offs at every step.
The Bresenham Parallel
There is a second algorithm that produces identical results to the Euclidean method: Bresenham's line algorithm, developed in 1962 for rasterizing lines on pixel grids. When you draw a line at an irrational angle across a bitmap, Bresenham's algorithm decides whether each pixel steps diagonally or horizontally to approximate the line as cleanly as possible. The result, read as a binary sequence of steps, is a Euclidean rhythm.
This is not a coincidence. Both algorithms solve the same abstract problem: distribute k events across n slots such that no two adjacent spacings differ by more than 1. Bresenham's implementation is often preferred in software sequencers because it runs without recursion, a single loop with an accumulator:
def euclidean(k, n):
pattern = []
bucket = n - k # bias so position 0 fires an onset
for _ in range(n):
bucket += k
if bucket >= n:
pattern.append(1)
bucket -= n
else:
pattern.append(0)
return pattern
euclidean(3, 8) returns [1, 0, 0, 1, 0, 0, 1, 0], the tresillo, derived from rounding a line of slope 3/8 across eight pixels.
In Hardware Today
Euclidean sequencers have moved from academic papers into commercial hardware. Elektron added Euclidean sequencing to the Analog Rytm in a 2023 OS update, then brought it to the Analog Four and Analog Keys in OS 1.55 (2026). Each generator has three parameters: steps (n), pulses (k), and rotation (phase offset). Two independent generators can run simultaneously, producing interlocking polyrhythms from a single menu.
In Eurorack, dedicated modules like the Ornament & Crime (open-source) and numerous DIY designs implement Euclidean generation in hardware. Connecting two Euclidean outputs with different step counts, one at E(3,8), one at E(5,12), for instance, produces combined patterns that repeat only after LCM(8,12) = 24 steps. The complexity feels organic because it is: the algorithm generates variation the same way the rhythms of West African and Cuban music generate variation, by packing the maximum number of rhythmic relationships into the minimum number of steps.
The Unexpected Insight
What makes the Bjorklund-to-Toussaint story stick is that neither man set out to study rhythm. Bjorklund was solving an accelerator engineering problem. Toussaint was looking for a mathematical explanation for a pattern he had already noticed in ethnomusicology data. The algorithm connecting them was two thousand years old.
The tresillo is not a culturally specific invention. It is a solution, the mathematically optimal answer to the question: how do you place three things in eight slots so they feel as balanced as possible? Different cultures, independently, found the same answer. The Euclidean algorithm is why.