The integers are a unique factorization domain, so we can’t tune pianos. That is the saddest thing I know about the integers.

I talked to a Girl Scout troop about math earlier this month, and one of our topics was the intersection of math and music. I chose to focus on the way we perceive ratios of sound wave frequencies as intervals. We interpret frequencies that have the ratio 2:1 as octaves. (Larger frequencies sound higher.) We interpret frequencies that have the ratio 3:2 as perfect fifths. And sadly, I had to break it to the girls that these two facts mean that no piano is in tune. In other words, you *can* tuna fish, but you can't tune a piano.

When we tune an instrument, we would like for all our octaves and fifths to be perfect. One way to tune an instrument would be to start with a pitch and start working out the fifths above and below it it. We start with some frequency that we call C. Then 3/2 times that frequency is G, 9/4 times that frequency is D (an octave and a step above our original C), and so on. If you learned about the “circle of fifths” at some point in your musical life, then you know that if we keep going up by fifths, we’ll eventually land back on something we'd like to call C. It takes a total of 12 steps, and so if we keep all our fifths perfect, the frequency of the C we get at the end is 3^{12}/2^{12}, or 531441/4096, times the frequency of the C we had at the beginning. You might notice that 531441/4096 is not an integer, much less a power of 2, so our ears would not perceive the C at the end as being in tune with the C at the beginning. (531441/4096 is about 130, which is 2 more than a power of 2, so we would hear the C at the top as being sharp.) And it's not a problem with the assumption that it takes 12 fifths to get from C to shining C. We can never get perfect octaves from a stack of fifths because no power of 3/2 will ever give us a power of 2.

Imperfect octaves are pretty unacceptable to any listener, and as a string player, I'm pretty into perfect fifths. So it's disappointing enough that I can't have them simultaneously. But the story gets even more complicated when we add thirds. Even if we could resolve the pesky fifths/octave problem, we would be stuck with some pretty strange sounding chords. When we hear frequencies in the ratio 5:4, we hear a perfectly tuned major third (the interval between C and E). But if we go around the circle of 5ths making uncompromising perfect fifths, we get 3^{4}/2^{4}=81/16. If we divide by 2 a few times to move the E back down to the same octave as the C, we end up with an 81:64 ratio, which is a bit bigger than 5:4 (or 80:64), meaning that the major third from C to E sounds too wide. So fifths are also incompatible with major thirds! Once again, we can never get a perfectly tuned major third from a stack of fifths, or a perfect fifth from a stack of major thirds, because no power of 5/4 equals a power of 3/2.

Blame unique factorization. One property of the integers that we take for granted is that we can factor any integer other than -1, 0, or 1 into its prime factors, and that the factorization will be unique. (We call this the fundamental theorem of arithmetic.) Hence, we can call the integers a unique factorization domain. (If you're a real stickler, you might be worried about negative integers. The factorization is unique up to signs of numbers, and that's good enough to be a unique factorization domain. If that still bothers you, just ignore the integers smaller than 2.) As a thought experiment, I decided to see if we could fix the problem by expanding from the integers to another set of numbers like the integers in that they can also be multiplied or added together.

One such set of numbers is called the Gaussian integers, and it consists of complex numbers of the form *a+bi*, where *a* and *b* are both integers and *i ^{2}=-1*. In the Gaussian integers, 2 is no longer a prime number because it can be factored into (1+

*i*)(1-

*i*), which happen to be primes. Neither is 5, which can be written (1+2

*i*)(1-2

*i*). But 3 is still a prime in the Gaussian integers (this isn't obvious, but it's true). Thus 2 and 3 still share no prime factors over the Gaussian integers, so we can't resolve our octaves/fifths problem there. (Not that I even know what it would mean to divide a frequency by a Gaussian integer. Like I said, this is a thought experiment.) Likewise, 5 and 2 share no Gaussian prime factors, nor do 5 and 3. So even if it made sense to divide a frequency by a complex number, it wouldn't help.

An even stranger set of numbers is the set of complex numbers of the form *a+√5bi, *or Z[√-5]. It might seem like this is no different from the Gaussian integers, but it is. It's not a unique factorization domain. For example, the number 6 can be factored into either 23 or (1+√5i)(1-√5i).* It's not obvious, but 2 and 3 can't be factored further; they are irreducible, as are (1+√5*i*) and (1-√5*i*). So 6 has two distinct factorizations. Will this help us? Well, we could end up with some powers of 6 in our frequency ratios if we combine fifths and octaves. But let's say we could divide that power of 6 by 1+√5*i* and 1-√5*i*. Where would we be? We'd have reduced our power of 6 by 1, but we're no closer to getting a 3 to change into a 2. Bummer! But at least we got to play with some quadratic integers, right?

You may have noticed that piano music doesn't always sound out of tune, so there must be some resolution to the prime number predicament. Compromise, my friend. Currently, most instruments use equal temperament, which makes all the fifths slightly narrower than perfect so the octaves will be in tune. Each half step has the same frequency ratio as any other half step, and that ratio is 2^{1/12}:1. We've lost the pure rational ratios that made Pythagorean intervals sound so sweet, but we've gained a lot. The difference between a Pythagorean fifth and an equal temperament fifth is not enough to bother any but the fussiest listeners, but it is detectable to some. Before equal temperament became the law of the land, at least for keyboard instruments and other instruments where the player can’t make minute adjustments to pitch, there were several other temperament compromises in use.

One solution is to tune an instrument so that the octaves, fifths, and/or thirds are perfect or very close for the important chords from some keys (generally “easy” keys like C, G, and D) but terrible for some other keys. Those systems (often meantone temperaments) ended up with "wolf fifths" that were much narrower than perfect fifths. An instrument with a wolf fifth couldn't really play in certain keys. Then along came well temperament, which was not one system but any of many irregular temperaments that made the keys sound different but didn't leave any key howling at the moon, so to speak. The "well-tempered" in Bach's *Well-Tempered Clavier *doesn't refer to the instrument's beautiful tone (or the instrumentalist's equanimity) but to the fact that the set of pieces was composed for a clavier with a temperament that allowed the instrument to play in every key. (The *Well-Tempered Clavier* is a set of 24 preludes and fugues, one in each major and minor key. Scholars don't know what exactly the clavier's temperament was, but it is unlikely that it was equal temperament, as some musicians assume.)

The fact that 3/2, 2, and 5/4 are incommensurable makes me genuinely sad, but later this week I hope to share a fun experiment the Girl Scouts and I did with pitch perception. It doesn't rely on having perfectly tuned fifths, thirds, and octaves simultaneously, so it shouldn't cause the same existential angst that temperament does.

*This sentence and other sentences in this paragraph were edited after publication to correct missing square root signs.