Music and Math

What’s the first thing you see when you look at a piece of sheet music? A fraction.

Music has a deep-rooted connection to how I perceive the world. When I was in first grade, I wanted nothing more than to play the electric guitar, yet I felt that I had to be more like my sister, so I picked up the violin. I almost jokingly said one day that I was going to learn the “electric violin,” only to see later on TV that such a thing actually exists. From then through seventh grade, I played the violin (but never got around to the electric part). What’s also fascinated me is the connection between music and math. After all, what’s the first thing you see when you look at a piece of sheet music? A fraction.

In December I stumbled upon a Finnish research paper that studies how the brain processes rhythm, tonality, and timbre. It was published in the journal NeuroImage. With a functional MRI, the research team found that listening to music employs both the auditory areas of the brain and large scale networks. There are also links in these networks to areas associated with movement, which would make sense, I suppose. All in all, many parts of the brain activate with music, many of which I would not have guessed, including the emotional, motor, and creative parts, all at once.

Timbral processing was located in the cerebellum which leads me to think that the “color” of music—the vibe if you will—is what makes us move. My next question is: How did all of this evolve? How is there a selective advantage to having these abilities? Also, an interesting element to explore would be the areas active while processing math and comparing the two neuroimages.

Still, though, you might be wondering, How strong really is this connection between music and math? To answer that, allow me to take you back to Ancient Greece. At that time, there was a man called Pythagoras that made important discoveries to philosophy, mathematics, and music. Already you might remember the name from middle school or high school. All together now: a2+b2=c2a^2 + b^2 = c^2. It’s the same person.

Now that we have that out of the way, we can discuss the important discoveries he made by “playing” with a stretched string one day. To explain what I mean, imagine a stretched string tied to its extremities. When we touch this string, it vibrates. Pythagoras realized that different sounds can be made with various weights and vibrations. So a vibrating string can be controlled by its length. Strings that are halved are an octave higher than the original. A shorter string meant a higher pitch. Also, he found that certain frequencies sound best with multiple frequencies of that note, just in different octaves, like how 220Hz sounds “best” with notes of 440Hz, and 660Hz.

The closest tie between music and math is patterns. Because what is music? It is vibration, sound, waves, and neural signals. In music, we see repeating choruses or bars. And in mathematics, patterns are all over the place. Music uses similar strategies, and in the course of time, the notes would receive the names we know today. For instance, the tritone (Devil’s) interval, for example, is obtained in the relation 32/45, a complex, ambiguous, unresolved, and inaccurate relation, which makes logical part of the brain to consider this sound unstable and tense. In fact, this sinister chord was not allowed to be played in churches during the Renaissance since the main purpose of music at the time was to express the majesty of God, rather than the opposite.

But let’s take a step back for a moment. Why, exactly, does something even sound good to hear in the first place? The closest tie between music, math, and our biology is patterns. Music often has repeating choruses, bars, and so on. In math, patterns can explain and predict the unknown. In nature, it’s common to see symmetry as a sign of health in genetically fit organisms. Music employs similar strategies.

One of the independent discoverers of calculus, Gottfried Wilhelm Leibniz, once said, “Music is a secret arithmetical exercise and the person who indulges in it does not realize that he is manipulating numbers.” So let us manipulate some numbers. And here’s where music becomes more of an art than a science. In the Western world, we use the chromatic scale, which divides the octave into 12 notes. That was a completely arbitrary decision and might be one of the reasons why people from different cultures have varying opinions on different types of music, despite the notion of the octave itself being universal. Nevertheless, in this example, we will use the chromatic scale to show how to calculate the frequencies of various notes in an octave.

First, a lesson on frequencies. Frequency is a repetition; imagine, for example, a bicycle wheel spinning. If a wheel of our example completes 10 turns per second, its frequency would be 10 Hertz (10 Hz). Sound is a wave, and it oscillates with a given frequency. On Simplifying Theory, it says that “the sound wave completes one oscillation in one second, its frequency will be 1 Hz. If it completes 10 oscillations in one second, its frequency will be 10 Hz. For each frequency, we will have a different sound (a different note). A note, for example, corresponds to a frequency of 440 Hz.” These waves created by instruments vibrate the air, which in turn vibrates your eardrum.  So, if you start with Frequency of B (246.9 Hz), multiplying the frequency by the twelfth root of 2 (1.0595) we will have 246.9 x 1.0595 = 261.6 Hz (C). Then the frequency of C 261.6 Hz x 1.0595 = 277.2 Hz (C#). Then after C#: 277.2 x 1.0595 = 293.6 Hz (D). For another example, take a look at this graph of the notes in “Allegretto,” a Beethoven piece that we played in the band in freshman year of high school:

What happens if we try other combinations of notes? Well, the next most “consonant-sounding” pair comes from notes that are a perfect fifth apart; for instance, C3 and G3 on the piano keyboard. The next graph shows the resulting waveform if we add two pure sine waves where one is a perfect fifth above the other.

It’s not as nice as a perfect sine wave, but it still looks pleasant and predictable. In terms of the frequency, the faster one makes 1.5 cycles every time the slower one makes one cycle. This corresponds to a 3:2 ratio. It’s not as pure as the 2:1 ratio formed by notes an octave apart, but it’s close. The graph wiggles a bit more inside each cycle, but overall the pattern remains very steady, very periodic. If you would like to learn more about this, I would suggest the following video on the circle of fifths:

However, not all note combinations are consonant. Some are strongly dissonant, with a harsh annoying quality. The next graph shows what happens when we play two adjacent keys on the piano together, for instance, the white C3 and the black C3-sharp next to it. This time, the pattern looks very different.

The wiggle within each cycle has disappeared. But a new phenomenon has emerged instead: the overall loudness of the sound falls almost to zero, then gets loud again. This is called beating, and the effect is both audible and disconcerting. Even though both notes are being played at a steady volume, the combination sounds as if the sound is rapidly turning off and on again, or buzzing. To understand why this happens, look closely at the next graph, which shows the two pure tones separately, in black and blue.

We see that sometimes the two curves overlap very closely, and sometimes, they are actually opposites. When the curves overlap closely, their sum (the red curve) is roughly twice as big as either of them. However, when the curves are “out of sync” with each other (or, technically, out of phase), they (approximately) cancel, so when we add them together, the red curve is (approximately) zero. On a basic level this is how noise-canceling headphones work. But the lesson to take away is that, based on cultural norms, musical notes will sound very pleasing if two notes are played together that make a simple ratio, such as 1:1 (unison) or 1:2.

We can also use math to find the most consonant sounds if we recall a trigonometric identity, with two frequencies being added to satisfy this equation:

sina+sinb=2sin(a+b2)cos(ab2) \sin a + \sin b = 2\sin\left(\frac{a+b}{2}\right) \cos \left(\frac{a-b}{2}\right)

This means the sum of two sine waves looks like a single sine wave at the average frequency a+b2\frac{a+b}{2}, except that the overall volume is modulated, or varies from loud to soft and back again, via the multiplication by the cosine wave with frequency ab2\frac{a-b}{2}. We don’t actually hear the difference between multiplying by +1 or -1, so the perceived beat frequency actually is just the difference aba-b. The human ear is good at hearing sounds with between 20 and 20,000 Hz (cycles per second). Actually, we hear sounds best somewhere in the middle, around the 1,000 to 4,000 zone, and we often lose some of our hearing ability as we age. At any rate, 15 times per second is too slow to hear as a pure tone. Instead, our ears hear it as “roughness” on top of an overall “average” pitch of around 270. Apparently, it is this “roughness” that we perceive as dissonance.

However, this is really just the beginning of the story. Perception is a biological process, not a mathematical one, so not surprisingly, the real story is more complicated. But even to just get a glimpse into this fascinating world of music and math is worth the time. Its applications go far:

  • Making business and stimulating the economy
  • Cognified music
  • Music therapy
  • Forming culture
  • Communication
  • Expression of feelings and emotions
  • Entertainment
  • Exchanging knowledge and experience
  • Inspiration, motivation, and “call to action”
  • Sound design

It makes me wonder, who decided all of these rules? Are the patterns of music something obvious, fundamentally embedded in logic? Is it unexplainable? Regardless, there is also so much to be gained by just understanding the ins and outs of things, but there is also so much value in appreciating the beauty of math, music, and biology because, despite the differences of every person on this earth, there is something about art that transcends dissimilarity and bridges the gap, and that I find to be astoundingly beautiful.