In a letter to a German princess on “the twelve tones of the harpsichord” penned by Leonhard Euler on the 3rd of May 1760 (coincidentally exactly 213 years before my birth day (coincidentally 213 is the smallest number that is part of a consecutive triple, each a product of a pair of distinct prime numbers; 213=3×71, 214=2×107, 215=5×43)), the tension between equal temperament and harmony is highlighted as a central issue in music. Euler wrote “It is evident, therefore, that in fact all semitones are not equal, whatever efforts may be made by musicians to render them such; because true harmony resists the execution of a design contrary to its nature”.

Music is relative. With the exception of a handful of individuals who possess perfect pitch (as an aside, the genetics are interesting), we perceive music relatively. This is very similar to an RNA-Seq experiment. Transcript abundances are measured only relatively to each other (by comparing read counts), although of course a very relatively abundant transcript can also be inferred to be absolutely abundant, as one has prior knowledge about the abundances of housekeeping and other yardstick genes. So it is with music. We know when we are listening to high vs. low pitch, but within a register we hear combinations of notes as concordant or discordant, as melodic or not, based on the relative frequencies of the pitches.

Harmony is the use of simultaneous sounds in music, and is closely associated with the notion of consonance. Specifically, the perfect fifth is the consonant sound of two frequencies at a ratio of 3/2 (the question of why this ratio sounds “good” is an interesting one, and I recommend Helmholtz‘s “On the sensations of tone” as an excellent starting point for exploration). Harmony leads to a “rational” requirement of musical scales: for example, the ability to produce a perfect fifth requires that among notes corresponding to sounds at pre-specified frequencies, there are a pair at a frequency ratio of 3/2.  Other consonant harmonies correspond to other rational numbers with small denominators (e.g. 4/3). Equal temperament is a relative requirement: in a musical scale composed of N notes, it is desirable that any pair of consecutive notes are at the same frequency ratio, say r. This allows for a music to begin on any note.

The tension Euler described between harmony and equal temperament is the mathematical observation that if $r^N = 2$ and $r^{k}=\frac{3}{2}$, then k should be chosen so that $\frac{k}{N} = log_2 \frac{3}{2}$. This is because the first equation leads to $Nlog_2 r = log_2 2 = 1$ so that $log_2 r = \frac{1}{N}$, and the second equation then leads to $k log_2 r = k \cdot \left( \frac{1}{N} \right) = log_2 \frac{3}{2}$. However $log_2 \frac{3}{2}$ is irrational. This is because if it were rational then $log_2 3$ would be rational, and that would mean that $log_2 3 = \frac{a}{b}$ for some positive integers $a,b$, which in turn would be mean that $2^a = 3^b$, which is impossible because powers of two are always even, and powers of three always odd. Ergo a problem.

The mathematics above shows that harmony is fundamental incompatible with equal temperament, but so what? If a very good rational approximation can be found for $log_2 \frac{3}{2}$ then music might not be perfect, but perfect should not be the enemy of the good. For example, in a 12 note scale,  we find that the seventh note (e.g. G if we are in C major) produces a frequency ratio with the first of $2^{\frac{7}{12}} = 1.4983...$, which is awfully close to 1.5. Does the difference in the third decimal really matter when one is listening to Rammstein?

Is 12 special? What about an 11 note scale? The following math provides the answer:

A (simple) continued fraction representation for an irrational number is an infinite expression of the form

$x=a_0+\frac{1}{a_1+\frac{1}{a_2+\frac{1}{a_3+\cdots}}}$

The convergents of are the rational numbers obtained by truncating the continued fraction expression at successively increasing finite points, i.e. the sequence $\frac{a_0}{1}, \frac{a_0a_1+1}{a_1},\frac{a_2(a_1a_0+1)}{a_2a_1+1},\ldots$

Theorem: Let $r_i=\frac{n_i}{d_i}$ be the convergents of a number x. Then the rational number $r_i$ is the best rational approximation to x with denominator $\leq d_i$.

The theorem is saying that if one approximates an irrational number with its continued fractions, then the denominators of those fractions are optimal in the sense that they provide rational approximations that improve on all lower denominators (an elementary proof is written up here). For example, the continued fraction approximation of $log_2 \frac{3}{2}$ is given by the sequence $[0,1,1,2,2,3,1,5,2,23,2,2,1,\ldots ]$ which translates to the expansion

$log_2 \frac{3}{2} = 0+\frac{1}{1+\frac{1}{1+\frac{1}{2+\frac{1}{2+ \cdots}}}}$

and leads to to the rational approximations $0,1,\frac{1}{2},\frac{3}{5},\frac{7}{12},\frac{24}{41},\frac{21}{53},\ldots$

The fourth denominator is 5, and its interpretation in light of the theorem is that no rational number with 1,2,3 or in the denominator can provide an approximation as good as 3/5 to $log_2 \frac{3}{2}$. Similarly, with 12 being the next denominator, the theorem implies that no rational number with a denominator between and 11 can provide an approximation to $log_2 \frac{3}{2}$ as good as 7/12. In fact, to improve on the accuracy of the perfect fifth a 29 note scale is required, a number which is much less practical than 12.There are of course other “rational” considerations in choosing a scale. Not only the perfect 5th must be approximated well, but also thirds and fourths. It turns out 12 provides a reasonably good approximation for all of these. In other words, the 12 note scale is not just a historical accident, it is a mathematical inevitability.

The question is did Princess Friederike Charlotte of Brandenburg-Schwedt realize that underlying the principle Euler was writing to her about was the key to understanding not only the theory of music, but also a fundamental design in nature?

The number of petals in flowers

An obvious question not addressed by the theorem stated above is how good are the rational approximations of irrational numbers? Obviously a rational number can always be chosen to be arbitrarily close to any irrational number (e.g. by truncating the decimal expansion arbitrarily far along). But the question is interesting when considered, in light of the theorem above, in terms of the accuracy of approximation as a function of its denominator. Hurwitz‘s theorem provides the answer:

Theorem [Hurwitz, 1891]: For every irrational number x, there are infinitely many rational approximations n/d such that

$\left| x - \frac{n}{d} \right| < \frac{1}{\sqrt{5}d^2}$.

Moreover, the constant $\frac{1}{\sqrt{5}}$ is best possible.

In other words, the approximation can be as good as the inverse of the square of the denominator (this should be contrasted with using the decimal expansion to approximate, which provides accuracy only proportional to the inverse of the denominator). The fact that $\frac{1}{\sqrt{5}}$ is the best possible constant means that there is some irrational number such that if one sets the constant to be smaller, then there are only finitely many rational approximations achieving the improved accuracy. One cannot get more accurate than $\frac{1}{\sqrt{5}d^2}$ infinitely often, and it turns out that the irrational number that is the extremal example is the golden ratio $\varphi = \frac{1+\sqrt{5}}{2}$. In a sense made precise by the theorem above, the golden ratio is the hardest irrational number to approximate by rationals.

Who would care about irrational numbers that are hard to approximate by rational numbers? Mothers of newborn twins?! However as whimsical as Ehud Friedgut‘s Murphy’s law sounds, evolution appears to have appropriated the principle of offsetting cycles to optimize branching patterns in plants and trees.

Tree branches around a trunk, or of flower petals around a stem, demand sunlight and ideally do not line up with each other. Suppose that they are equally spaced, separated by a fixed angle $\theta$. If $\theta$ is rational, then the branches or petals will line up perfectly creating a pattern, viewed from above, of lines emanating from the trunk or main stem. An irrational angle ensures that branches never line up perfectly, however if the irrational number is well approximated by a rational number then the overlap will be extensive. That is, the branches will almost line up. The solution? Choose an irrational angle that is as hard as possible to approximate by rationals. The golden ratio! The angle turns out to be 137.5 degrees.

With the golden ratio, the branching pattern when viewed from above looks like a series of spirals. Depending on the time between the appearance of branches (or seeds at the center of a flower), the number of spirals varies. The numbers though will always correspond to one of the convergents of the (continued fraction expansion of the) golden ratio. These are

$\frac{2}{3}, \frac{3}{5}, \frac{5}{8}, \frac{8}{13}, \frac{13}{21}, \ldots$.

Note that the denominators are the Fibonacci numbers. Since flower petals typically form at the tips of the spirals, one frequently finds a Fibonacci number of petals on flowers. Fibonacci numbers are all over plants. Nature is irrational.

Georgia O’Keeffe: Music Pink and Blue No. 2 (1918). Next time you are pondering what her flowers truly represent, think also of the tension between the rational and the irrational in music, and in nature.