Music has only two near-natural intervals: the octave (frequency ×2) and the perfect fifth (×3/2). The trouble is that they are incompatible — walk upward by fifths and you never return to where you started: $(3/2)^m = 2^n$ would require $3^m = 2^{n+m}$, which unique factorization vetoes outright.
So a scale must be a compromise, and compromises have optima: cut the octave into $q$ equal parts, and ask which $q$ lands the perfect fifth closest to a grid point. The musical question has just become a number-theoretic one — approximating an irrational by a rational with a small denominator.
Let $x=\log_2(3/2)=0.5849625\ldots$, the fraction of an octave occupied by a perfect fifth. We seek $p/q$ minimizing $|x-p/q|$, where $q$ is the number of equal divisions and $p$ the number of steps in a fifth. The continued fraction and its convergents:
The best-approximation theorem guarantees that convergents satisfy $|x-p/q| < 1/q^2$, and that no fraction with denominator at most $q$ comes closer. Here $3/5$ is the pentatonic scale and $7/12$ is twelve-tone equal temperament (a fifth spans 7 semitones). Taking 1200 cents to the octave, the pure fifth is 701.96: equal temperament gives 700 (off by −1.96), while 53 divisions give 701.89 (off by −0.07, far below the roughly 5-cent threshold of human discrimination).
The pentatonic and the twelve-tone scale are not cultural accidents; they are two adjacent terms of the same continued fraction. The Chinese sān-fēn-sǔn-yì cycle, the Pythagorean chain of fifths, the Arabic 17-tone system, the 22 śrutis of India — civilizations working in isolation all landed near this sequence of convergents. Number-theoretic convergence pushed different cultures onto the same grid points.
More telling still is 53: mathematically near-perfect (Nicholas Mercator and the Chinese 60-lü tradition both brushed against it), yet adopted by no mainstream instrument. Between the optimal solution and the playable one stands a wall of engineering — what twelve-tone equal temperament won on was never accuracy, but the number of fingers and the width of a key.
The same continued-fraction machine runs elsewhere: orbital resonance (Io, Europa and Ganymede locked at 1:2:4), gear-tooth design, the Metonic cycle behind calendar intercalation, divider ratios in phase-locked loops. KAM theory supplies the mirror image: the frequency ratio hardest to approximate by rationals (the golden ratio) marks the orbit least likely to be torn apart by resonance — the gaps in Saturn's rings and the tuning of a piano pose the same question.
Arrange the $n$ pulses of a bar in a circle and blacken the struck positions — a rhythm is simply a subset of that ring. Entering the same drum pattern on a different beat is just "another door into the same rhythm": mathematically, the rotation action of the cyclic group $\mathbb{Z}_n$, with one rhythm = one orbit (a necklace). "How many 8-pulse rhythms are there?" thereby becomes a counting problem.
A second intuition: good drum patterns tend to spread $k$ onsets as evenly as possible across $n$ slots. When $k$ does not divide $n$, "as evenly as possible" needs an algorithm — and that algorithm turns out to be Euclid's.
A rhythm is a subset $A\subseteq\mathbb{Z}_n$ under the rotation $A\mapsto A+1$. By Burnside's lemma, the number of rhythm necklaces of length $n$ is:
Here $\varphi$ is Euler's totient and $2^{n/d}$ counts the patterns fixed by a rotation of period $d$. For $n=8$ the answer is 36 — 256 binary patterns collapse into 36 genuinely distinct rhythms. The Euclidean rhythm $E(k,n)$ comes from Bjorklund's algorithm: run the Euclidean algorithm on $(k,\,n-k)$ and you obtain a maximally even set in $\mathbb{Z}_n$. $E(3,8)=\texttt{x..x..x.}$ is the Cuban tresillo; $E(5,16)$ is the bossa nova clave.
The most startling identity is $E(7,12)$: spread 7 points maximally evenly over 12 slots and you get the major scale. One and the same "maximal evenness" algorithm yields the world's drum patterns along the time axis and the Western diatonic scale along the frequency axis — pitch and rhythm turn out to be two slices of a single combinatorial object.
And a cold piece of corroborating evidence: Bjorklund's algorithm was written to schedule timing pulses for the spallation neutron source at Los Alamos. It has nothing to do with music, yet it computes the same traditional rhythms — Toussaint checked dozens of world rhythms and found almost all of them are Euclidean.
"Spread $k$ events as evenly as possible over $n$ slots" is daily bread in distributed systems: timer division, CPU quota scheduling, token issuance in rate limiters, virtual-node placement in consistent hashing — and Bresenham's line-drawing algorithm is literally the same procedure. The group-theoretic half supplies a rhythm fingerprint: compare orbits rather than sequences and identification of looped samples becomes start-point invariant for free.
To decide "which note is this?" you must listen for a while — pitch is read off by counting cycles, and the shorter the window the fewer cycles there are, so the pitch blurs. Conversely, to know exactly "when was it struck?" you need an extremely short window, and then there is almost no frequency information left.
This is not a shortcoming of equipment but a property of waves: a tone that is both short and pure does not exist mathematically. The Fourier transform (Day 40) tells you which frequencies are present, not when they occur; ask both questions at once and there is a non-negotiable bill to pay.
$\Delta t$ is the standard deviation of the signal's energy along time, $\Delta f$ its standard deviation along frequency; equality holds only for a Gaussian window — which is exactly why Gabor atoms carry a Gaussian envelope. The engineering version is easier to remember: a window of $T$ seconds buys roughly $1/T$ Hz of frequency resolution.
The constant-Q transform spends the budget differently: it holds the relative resolution fixed, $Q=f_k/\Delta f_k$, with bins spaced logarithmically as $f_k=f_0\,2^{k/b}$. Resolving a semitone demands $\Delta f/f = 2^{1/12}-1\approx 5.9\%$, i.e. $Q\approx 17$: long windows low, short windows high.
Fourier hands you a uniform frequency grid, but music lives on a logarithmic one: near 30 Hz a semitone is only 1.8 Hz wide, while at 3000 Hz it is nearly 180 Hz. A uniform STFT therefore cannot separate the bass and squanders resolution in the treble. Constant Q gives each band a window proportional to its wavelength, which amounts to redistributing the uncertainty budget along music's own geometry.
This is more than an engineering trick: logarithmic frequency is not a notational convention — the cochlea's place-to-frequency map is already roughly logarithmic, and wavelet analysis independently produces the same family of scale-self-similar atoms. Physiology, mathematics and music theory converge on one coordinate system. It even hard-codes a rule of composition: low notes need longer to be identified, so a bass is natively unsuited to very fast runs.
The phase vocoder decouples time-stretching from pitch-shifting, the foundation of every tuning and stretching plug-in; CQT and mel spectrograms are the front end of nearly all music AI (transcription, chord recognition, the input to audio generative models). In quantum mechanics the very same inequality is called Heisenberg's principle — position–momentum and time–frequency are one and the same pair of Fourier conjugates.
The most naive way to make a machine compose: tabulate what usually follows the previous few notes, then sample. Hiller and Isaacson's Illiac Suite of 1957 — the first computer-composed score — worked exactly this way. The outcome is emblematic: locally plausible, globally formless. Thirty seconds sound like music; three minutes reveal that nothing was being said.
The failure can be stated precisely: a Markov chain's memory decays exponentially with distance, while musical structure is a power law — a second section echoing the first means correlations survive hundreds of notes. No increase in the order $k$ closes that gap.
This is the autoregressive factorization: every note is conditioned on the entire history, $x_{
This translates "music has form" into a measurable statistical signature. A power law means no characteristic scale, and no characteristic scale means self-similarity (the fractals of Day 17): the hierarchy of theme, development and recapitulation leaves the same statistical fingerprint as a critical phenomenon.
The repairs are equally mathematical, and there are only two. Write the hierarchy into the model explicitly (Schenkerian analysis, the tree grammars of GTTM), or let the model see hundreds of steps away directly — attention in a Transformer is precisely "an edge between any two positions", and relative position encoding turns "how many beats since this last appeared" into a learnable quantity. That Music Transformer first produced piano pieces with genuine recapitulation amounts to tearing down the wall of exponential decay.
Music generation models (over MIDI events or audio tokens) and accompaniment and continuation tools are the direct payoff. The same long-range-dependence analysis is carried over to evaluating language models (why low perplexity still drifts off topic over long documents), detecting long-range correlation in DNA, and diagnosing cross-file dependence in code completion. Xenakis's other road is still open too: model the distribution rather than the notes — today's diffusion models are its distant relatives.