Music in Even Parts

Summer of Math Exposition 2025

M. Tirado

Contents

Note: This interactive article has sound playing capabilities. Please make sure your device and browser are able to play audio.

Introduction

Music is based on a careful balance of novelty and repetition. A stream of random notes is a uninteresting as the same note being played over and over again. Bars or measures define a time interval where a fixed number of beats can be placed, allowing us to create rhythms and melodies.

The question is, where and how to place these notes in such a way that is appealing to the human ear? Is there a way to have repetition and nuance at the same time, so that music feels familiar and novel at the same time?

In this bar composed of sixteen beats, we can play a note every one, two, four, eight or sixteen beats. These are the divisors of sixteen, and playing a note with a different interval would produce a syncopated pattern.

Note: Syncopation can be defined as a disturbance in the natural flow of a rhythm, and is responsible for that feeling of novelty or surprise when listening to a beat.

We are also allowed to play different notes, each following a different rhythm, allowing us to experiment with different patterns.

In the previous examples, rhythms are constructed by dividing the bar or measure in evenly spread intervals, giving us a number of beats, however, is it possible to create rhythms with an arbitrary number of notes?

Nuclear Physics?

Related to his research with spallation neutron source (SNS) accelerators, E. Bjorklund devised an algorithm to evenly spread out \(k\) pulses over \(n\) discrete time intervals.

We will refer to this algorithm as the function \(E(k, n)\), where \(E\) stands for “evenly spread”. Its output won’t be a number, but a visual representation of the pulses and time intervals.

\(E(1,1)\) produces: \(\bullet\). One pulse evenly spread over one time interval.

When \(k\) perfectly divides \(n\), the solution is trivial:

\[E(2,4) = \bullet\circ\bullet\circ\]

\[E(4,16) = \bullet \circ \circ \circ \bullet \circ \circ \circ \bullet \circ \circ \circ \bullet \circ \circ \circ\]

A trickier problem emerges when \(k\) does not evenly divide \(n\), i.e. there’s a remainder when dividing \(\frac{n}{k}\). Bjorklund’s algorithm goes like this:

Of course, sometimes it’s impossible to evenly spread these pulses, but the algorithm does its best job to accomplish this.

Euclid’s Algorithm

Euclid’s Algorithm computes the greates common divisor between two numbers. Bjorklund’s algorithm for evenly spreading out events over discrete time intervals can be considered to be “euclidean” as the process of pairing up sub-sequences is very similar to the process of repeated subtraction to compute the greatest common divisor.

The process of computing \(\text{GCD}(a, b)\) is the following

  1. Subtract the smaller of \(a\) and \(b\) from the larger until it becomes smaller than the smaller. This value, also called the remainder, will become the new smaller number.
  2. Repeat until the remainder becomes zero. The smallest remainder before it becomes zero is the greatest common divisor.

Using the example above, to calculate the GCD of 7 and 16 start with:

In each of the steps, the smallest number corresponds to the number of pairs we can make in Bjorklund’s algorithm.

World’s Rhythms

In 2004, Godfried Toussaint came to the realization that these patterns can be used to construct many rhythms found in world music, from the tresillo pattern to Colombian cumbias to West African music.

With the following calculator you can generate arbitrary euclidean rhythms.

Rotations

Although Bjorklund’s algorithm generates pulses that are evenly spread, a pattern can be “rotated” in the sense that the starting point is at a different index, allowing us mix different rotations of the same pattern to get more interesting rhythms.

We add a third argument to the \(E\) function, specifying the number of pulses, the number of time intervals, and the rotation amount. For example:

Using a circular pattern is a very good way to represent the cyclic nature of euclidean rhythms.

Music Generation

We are not limited to using a single rhythm or percussion sounds. Multiple of these euclidean rhythms can be combined, each one playing a different note, to generate interesting musical patterns and melodies.

Here, four euclidean rhythms can be controlled to play the root, the third, fifth and seventh degrees of the major scale.

Repetition

If you have played with the calculators above, you might have noticed that some patterns contain patterns that repeat, for example:

\[E(2, 8) = \bullet \circ \circ \circ \bullet \circ \circ \circ = \bullet \circ \circ \circ + \bullet \circ \circ \circ\]

In this case, the pattern \((\bullet \circ \circ \circ)\) repeats two times, which corresponds to the GCD of two and eight. The pattern \(E(2, 8)\) is just \(E(1, 4) \times 2\)

A musical pattern with no repetitions would need a GCD of 1, that is, when two numbers are coprime, and the larger these numbers are, the longer the pattern will be and still have no repetitions.

For example, we can pick a relatively large number, say 60, and pick four other numbers that are relatively prime to it: 13, 23, 31, 43. With these numbers we can generate a long, unique pattern.

Into the frequency domain

So far we viewed the patterns that the euclidean algorithm creates in the time domain, i.e. beats evenly spread over time.

Another place where euclidean rhythms emerge is in the frequency domain. That’s to say, in the pitches of the musical notes themselves.

The equal temperament chromatic scale is the basis of pretty much all modern western music. To create it, we take an octave (a frequency ratio of 2) and we divide it in 12 parts. Note that frequency increases not by adding a fix number, but by multiplying by a ratio.

For example, if we take a root frequency of \(\text{440 Hz}\) (A4), we need to multiply it 12 times by a special ratio to get its octave, \(\text{880 Hz}\).

\[F_{\text{root}} \cdot (\text{ ratio })^{12} = F_{\text{octave}}\]

\[(\text{ ratio })^{12} = \frac{F_{\text{octave}}}{F_{\text{root}}} = 2\]

\[\text{ratio} = \sqrt[12]{2} \approx 1.0595\]

The twelfth root of 2 is the ratio between two notes in the chromatic scale, also called a semitone.

Note: A semitone is the interval between any two notes in the piano (black or white!), or between two frets in a guitar.

The musical scales

Of course, we don’t always use all twelve notes when composing a song. The diatonic scale, for example, uses seven notes, while the pentatonic scale has five.

The problem now lies in choosing seven notes out of twelve, such that they are spread out as evenly as possible. Sounds familiar? That’s right! In the diatonic scale, musical pitches are evenly spread out and follow an Euclidean pattern:

\[E(7, 12) = \bullet \circ \bullet \bullet \circ \bullet \circ \bullet \bullet \circ \bullet \circ\]

The minor scale emerges by using the euclidean algorithm, instead of the beats being spread over time, pitches are spread over the chromatic scale.

Not only that, but the rotations of this pattern create the modes of the diatonic scale:

Notice that rotations are selected so that the first is not a blank space, indicating the start of the scale. Given these constraint, only seven modes are possible.

The same can be done by picking five evenly spread notes from the octave, to get the pentatonic scale.

We can generalize this by generating scales with any number of notes from the chromatic scale:

I don’t know about you, but I think that the two scales that sound better are the ones with five and seven notes. Could there be a reason for this?

Chords

Chords can also be generated just like scales are created by picking some notes from the chromatic scale.

By using the diatonic scale and picking three of its seven notes, we can obtain all the possible triads:

The same can be done to generate all the possible seventh chords, by evenly spreading four notes in the scale.

Conclusion

It’s very interesting to see how by just evenly spreading out \(n\) items over \(k\) spaces, we can create patterns that are pleasing to the human ear in both the frequency and time domains.

Euclidean rhythms can be used to create rhythmical patterns found in world music, but also scales and chords. They can be used to generate algorithmic music, and I have no doubts that there are other applications in other sciences and arts.

Support

Did you enjoy this interactive article? Explaining topics that require interactivity and appealing visuals is no small effort. You can help create more of them by becoming a supporter.