Here’s the first in what will hopefully be a series of related posts about one particular (limited) aspect of the interaction between music and mathematics. In my mind, I’ll be explaining things to a hypothetical musically uneducated mathematician, who should nevertheless end up with an understanding as good as any bona-fide musician’s – in the tradition of certain physics books of which I am a fan.

I begin by revising, in unnecessary rigorous detail, what you already knew about musical pitches and intervals.

Musical intervals are the signed distance between musical notes, as written on a traditional (Western) five-lined musical stave. For completeness, I will first summarise traditional pitch and interval notation.

## Pitch syntax

Pitches are a pair, consisting of a *letter* and an *accidental*: , , where

leading to constructions such as C♮, F♯, B♭ etc. These pitches correspond in a slightly irregular way to the horizontal lines (and gaps between them) on the stave, but I will not go into the details here. All pairs correspond to valid pitches. The set of pitches is actually extended upwards beyond that written above with super-prime symbols ( ), and downwards with sub-primes ( ).

The *accidentals* are pronounced as follows: ♮ is a *natural*, ♭ is a *flat*, ♯ is a *sharp*.

Pitches form an affine space, with intervals as the difference type (subtraction of two pitches). I will not define this subtraction until we have a clearer idea of the algebra of intervals.

## Interval syntax

Intervals are also a pair, consisting of a *quality* and a *number*: , , where

leading to interval names such as P5, M3, m6 etc. Note that the set which belongs to is **not** ℤ – the are simply an arbitrary label (nominal numbers), and their arithmetic is tied up with the overall algebra of musical intervals in a complex way that does not correspond to the conventional notion of integers. Intervals form an associative abelian algebra (generally written as addition), together with the four additional operations of *augmentation*, *diminution*, *inversion* and *negation*.

The interval *qualities* listed above are pronounced, respectively, *perfect*, *major*, *minor*, *augmented*, *diminished*, *doubly augmented* etc. The interval *numbers* are pronounced as ordinal numbers, with the special case that is an *octave*, and a *unison*.

Note also that not all combinations are permitted; in particular, there are certain rules that allow one to construct valid intervals. Start with one of the eleven valid base intervals:

The total set of valid intervals is actually periodic: take , and in the positive direction has period 7 and the entire inverted set (the result of the map ) is also in , i.e.

and then also

## Operations on intervals

I will freely interchange two forms of notation for the same interval: and for convenience. I will use for interval vector addition and addition of intervals to pitches, and for interval vector subtraction and subtraction of pitches. I will use a dot for scalar multiplication of interval vectors by integers.

Before I get to the complete decision procedure for intervallic addition below, a limited form of interval addition can be defined on ,

which can be extended in the obvious way to (of course, each case is defined only for that actually exist in ).

Then, you can *augment* intervals:

and *diminish* them:

Note that , for all .

We can now define addition on intervals. Let and . Then,

finding and according to the following procedure: augment or diminish until you have a new interval , along the way calculating an augmentation index , where you increment once for each augmentation, and decrement once for each diminution. Repeat for . Then perform the following interval addition, which is possible because addition is already defined on :

Then, perform the appropriate number ( ) of augmentations on , to give :

Incidentally, it is always true that .

## Free abelian groups

Quick revision of free abelian groups. A free abelian group of rank satisfies the following: there exists at least one set , with , such that every element of can be written as a linear combination of the elements of , with integer coefficients, i.e. .

Free abelian groups can be thought of as vector spaces over the integers (ℤ as the field of scalars, as the group of vectors).

A rank- free abelian group is isomorphic to the group of -tuples of integers, with the group operation pairwise addition:

or in other words, any rank- free abelian group is isomorphic to the direct sum of copies of ℤ:

There may be many different choices of basis set , much like a vector space with no preferred basis.

## Intervals as a free abelian group

As you can probably tell, our previous method of interval addition is a horrible mess. Luckily we can prove that intervals form a rank-2 free abelian group (said proof consists of a pile of tedious case analysis). Hence we can find a two-element basis; after which interval addition proceeds easily, being reduced to element-wise addition of pairs of integers.

We need to find any pair of linearly independent intervals to use as a basis – to decompose any arbitrary interval into a linear combination of the two basis intervals. Once we have one basis, we can use them to easily generate all the other bases. However, it’s not immediately obvious how to find our first pair of linearly independent intervals. Luckily, I have such a pair up my sleeve already: (A1, d2). They must be linearly independent, because

We will now take the opportunity to simplify our augmentation and diminution operations,

Decomposing arbitrary intervals into a basis requires some more tedious case analysis, so here are just a few examples:

If we define the map to be the map that gives the decomposition into the (A1, d2) basis, then the above could be written as

The basis (A1, d2) is convenient insofar as A1 matches up with what we think of as *semitones*, and d2 simply counts an interval’s *number*.

Now that we can add and subtract intervals easily, I can concisely define the two remaining special operations on intervals, *inversion* and *negation*:

## Pitch space

Of course, merely being able to add and subtract intervals is pretty useless on its own. What we really want to do is use intervals to hop around the space of pitches. The rules for pitch arithmetic are only barely less irregular than for intervals.

Note: adding an interval to a pitch is called *transposition*, and it is technically a separate operation from interval addition (it has a different type signature), but we shall use the symbol for it anyway.

In our notation from the first section, adding an octave (P8) adds a prime symbol to a letter name

with the obvious extension to multiple octave subtraction, and multiple primes and sub-primes.

Adding and subtracting A1 corresponds to adding and subtracting sharps and flats:

with the obvious extension to double sharps (♯♯) and double flats (♭♭) and arbitrary numbers of accidentals.

All that remains is to give the intervals between the natural (♮) pitches:

The equivalent of choosing a basis for our intervals is finding a coordinate system for our pitches. To do this we must convert the pitch affine space into a vector space (Wikipedia suggests the name Pointed space) by choosing an origin. At this point, any choice of origin is arbitrary and meaningless, but it becomes important when we get to tuning systems, which will be the subject of the next post in this series.

For example, let us define a map with origin

Then, to find the coordinates of an arbitrary pitch , we compute

Of course, it is easiest to simply define .

We now no longer need to worry about how to represent pitches, and will focus on intervals for the purposes of basis changes.

## Change of interval basis

Given that we now have one valid basis, the problem of further changes of basis reduces to linear algebra in two dimensions.

Let be our interval in the (A1,d2) representation, and let and be a different pair of linearly independent basis intervals. Then

which is simply a system of two linear equations, to be solved by determinants in the usual way:

Clearly the solution will not always be in the integers, so we may sometimes choose to extend our scalar field to the rationals (particularly when we come to tuning systems). Here are the examples from the previous-but-one section, but demonstrating the (P5,P8) basis:

and again with the (M2,m2) basis:

Finally, here is a diagram showing pitch space, with arrows representing 3 choices of interval basis.

Figure 1: Lattice

The ideas in this post are implemented concretely in two software projects: the Haskell Music Suite (also available on Hackage), and in AbstractMusic (the latter being my own personal research project).

Pingback: From notated music to audible sounds | Scientific Notation