Module 4 · Weeks 8–9 · UG→Graduate
Rhythm, Combinatorics & Geometry
The Bjorklund algorithm distributes pulses as evenly as possible around a cycle, recovering rhythms from Cuban tresillo to West African bembe. These “Euclidean rhythms” are necklaces in the combinatorial sense—equivalence classes under cyclic rotation.
Euclidean Rhythm Generator
Necklace (circular):
Linear pattern:
10010010
World rhythm examples:
Polyrhythm layers (simultaneous):
Layer 2
10110110
Layer 3
101101011010
Mathematical Framework
The Bjorklund algorithm is isomorphic to the Euclidean algorithm. To distribute \( k \) pulses among \( n \) steps, we compute\( \gcd(k, n-k) \) via repeated subtraction, grouping remainder sequences at each stage. The output is a maximally even distribution:
\( s_i = \left\lfloor \frac{i \cdot k}{n} \right\rfloor - \left\lfloor \frac{(i-1) \cdot k}{n} \right\rfloor, \quad i = 1, \ldots, n \)
A sequence is maximally even iff the gap between consecutive onsets differs by at most 1.
Necklace equivalence: two binary strings are the same necklace if one is a cyclic rotation of the other. The number of distinct binary necklaces of length \( n \) with \( k \) ones is counted by Burnside's lemma:
\( N(n,k) = \frac{1}{n} \sum_{d \mid \gcd(n,k)} \varphi(d) \binom{n/d}{k/d} \)
where \( \varphi \) is Euler's totient function. The cyclic group \( \mathbb{Z}_n \) acts on binary strings by rotation; the orbits are necklaces.
Geometric interpretation: each binary necklace of length \( n \)with \( k \) ones is a vertex of the cyclic polytope inscribed in the circle. Euclidean rhythms correspond to regular or nearly regular polygons, maximizing the minimum arc between consecutive onsets.
Python Simulation: Euclidean Rhythms & Maximally Even Sets
The Bjorklund algorithm in action: necklace visualisations of classic Euclidean rhythms, step-by-step algorithm trace for E(5,8), evenness analysis across all k values, and Burnside necklace counts.
Click Run to execute the Python code
Code will be executed with Python 3 on the server