# Is there an “easy” formula for calculating the species and quality of the musical interval between two notes?

Let's number the scale steps of the major scale $$1,2,\ldots 7$$, i.e., label them from the tonic upward mod $$7$$ and then add $$1$$. With that numbering scheme, let the lowest note of a given diatonic interval be $$x$$ and the highest note $$y$$.

Is there an "easy" or at least "manageable" formula/algorithm for the function $$I(x,y)$$, where $$I$$ takes values $$1,2,\ldots,7$$ according as the interval between $$x$$ and $$y$$ is a unison, second, third, etc.?

For example, $$I(6,4)=6$$.

As a further question, could we then modify the formula for $$I(x,y)$$ into one for $$J(x,y)$$, where $$J(x,y)=(I(x,y),Q)$$, with $$Q$$ the quality (major, minor, perfect, augmented, diminished) of the interval according to some convenient numerical labeling?

• The formula for $I$ depends on what operators you allow. The binary $\bmod$ operator would be useful (written % in many programming languages). For the "quality" component, however, it seems to me that a lookup table would be far simpler than a formula. – David K Apr 16 '20 at 2:51

## 2 Answers

For the intervals part, I think that by definition the number-name of the interval is simply the distance, the difference $$\;y-x\;$$, between scale steps $$\;x\;$$ and $$\;y\;$$.

Only with two complications: Intervals are numbered starting from $$1$$, not $$0$$; and sometimes one doesn't want to distinguish between a sixth, a 13th, or an inverted third.

That leads to the $$\;+1\;$$ and the $$\;\text{ mod }7\;$$ in the formula from the earlier answer $$I(x,y) \;=\; (y-x)\text{ mod }7 + 1$$

Now for the quality, I have found the following.

First, we calculate the number of fifths in the interval, which is $$\;F(y) - F(x)\;$$, where $$F(x) = 2m - \left\lfloor (m+4)/7 \right\rfloor\times7 - \left\lfloor m/7 \right\rfloor\times7 \text{, where } m = x-1$$ is the number of fifths (modulo octaves) from the tonic to $$\;x\;$$. (Note that $$\;\left\lfloor \dots/7 \right\rfloor\times7\;$$ rounds down to the nearest multiple of $$7$$.)

Then the quality is $$Q(x,y) = h(k) - h(-k) \text{,} \\ \text{where } k = F(y) - F(x) \\ \text{ and } h(k) = \max(0, \left\lfloor (k+8)/7 \right\rfloor)$$ where the quality is encoded as

Q(x,y) quality name
... ...
$$-3$$ doubly diminished
$$-2$$ diminished
$$-1$$ minor
$$0$$ perfect
$$1$$ major
$$2$$ augmented
$$3$$ doubly augmented
... ...

There is more behind this, but I cannot expand on that now. For now, suffice it to say that $$\;h(k)\;$$ indicates how 'major' the $$\;k\;$$-fifths interval is; and a perfect interval is, in some sense, one that is both major and minor.

• Thank you, this is exactly the sort of thing I was looking for! – Kim Fierens Jun 2 at 15:40
• @KimFierens You're welcome! As an additional remark, things become simpler if you take intervals as the basic concept, and build scale steps on top; then you only need to use $\;I(1,y)\;$ and $\;Q(1,y)\;$, making the formulas simpler. And unlike scale steps, intervals can be added together, although not via the standard arithmetic-- it helps to write an interval $\;y\;$ as (nrOfFifths, nrOfOctaves), with nrOfFifths = $\;F(y)\;$ describing the interval quality per this answer; and as (nrOfMajorSeconds, nrOfSharps), where nrOfMajorSeconds describes the interval 'degree'; and add elementwise. – MarnixKlooster ReinstateMonica Jun 2 at 18:42

Although you don't say explicitly what $$\ I(x,y)\$$ means when $$\ x>y\$$(i.e. the index of the lower note is greater than the index of the higher note) , I assume from your example that it is the degree of the interval from the note represented by $$\ x\$$ to the one an octave higher than that represented by $$\ y\$$. In that case, if $$I(x,y)\stackrel{\text{def}}{=} y-x\hspace{-0.5em} \pmod{7}+1$$ then the interval between $$\ x\$$ and $$\ y\$$ will be a unison if $$\ I(x,y)=1\$$, and an $$\ n$$-th if $$\ I(x,y)=n\$$ with $$\ n=2,3,\dots,7\$$.

For the qualities, I doubt if there's any simpler way to represent them than in a table something like the following: $$\begin{matrix} \,_{\large x}\backslash^{\large y}&1&2&3&4&5&6&7\\ 1&u&2&3&p4&p5&6&7\\ 2&m7&u&2&m3&p4&p5&6\\ 3&m6&m7&u&m2&m3&p4&p5\\ 4&p5&6&7&u&2&3&a4\\ 5&p4&p5&6&m7&u&2&3\\ 6&m3&p4&p5&m6&m7&u&2\\ 7&m2&m3&p4&d5&m6&m7&u \end{matrix}$$ in which the numbers unaccompanied by a letter represent major intervals. While you could no doubt concoct some sort of numerical formula to represent the same information that's contained in this table, I doubt if it could be made any more succinct.