<html> <head>
<!--- <base c:/Math/Pianos/www/></base> --->
<!--- <title>This note's for you</title> --->
<title>Pianos and Continued Fractions</title>
</head>

<body bgcolor="#FFFFFF"> 
<center>
<h1>Pianos and Continued Fractions</h1>
<p>
<h1>Edward G. Dunne</h1>
<h2>American Mathematical Society</h2>
<h2>Email: <a href="mailto:egd@ams.org">egd@ams.org</a></h2>
</center>

It is an old (and well-understood) problem in music that you can't
tune a piano perfectly. 
To understand why takes a tiny bit of mathematics and a smattering of
physics (acoustics, namely).
<p>

<hr>
There is a <a href="Temperament2x.PDF">PDF version</a> of this
article available, which is slightly modified from the original text.
<p>
You can also read a more polished version in the article: <br>
Edward Dunne and <a href="#MarkThanks">Mark McConnell</a>, Pianos
and Continued Fractions, 
<i>Mathematics Magazine</i>, vol.&nbsp;72, no.&nbsp;2 (1999), 104-115.
<hr>

<h3>The physics</h3>
Let me begin by explaining the way a scale is constructed.  
To avoid sharps and flats (and to make the diagrams easier to draw),
I'll use the key of C. 
So-called middle C represents a particular frequency.  There are    
various standards for fixing the starting frequency.  (I will let the
musical directors of orchestras on the two sides of the Atlantic hash
out the question of what is actually appropriate...)
Also, I will play the
old trick of defining my units so that my middle C has a frequency of
<b>1</b>.  
<p>

There are two pieces of <a href="#PythagoreanHammers">acoustics</a>
that matter now:
<ol>
<li>Going up one octave doubles the frequency.  Thus,
the C one octave up from middle C has a frequency of <b>2</b>. 
<li>Tripling the frequency moves to the perfect
fifth in the next octave.  In our case, this means that the <b>G</b>
in the next octave has a frequency of <b>3</b>.
</ol>   
<P>
<IMG align=middle SRC="FIFTH2.GIF">
<p>
<p>
By inverting the rule that says that the note one octave than another
must have double the frequency, we can fill-in the perfect fifth in
the first octave.  It should have half the frequency of the G in the
second octave. 
<P>
<IMG align=middle SRC="FIFTH3.GIF">
<p>
Following Pythagoras, we can now attempt to use these two rules to
construct `all the notes', i.e., a complete <a href="#ChromaticScaleDef">chromatic scale</a>.
<p>
The perfect fifth in the key of G is
D.  Thus we have, by tripling then halving, then halving again:
<P>
<IMG align=middle SRC="FIFTH4.GIF">
<p>
Repeat again: the perfect fifth in the key of D is A:
<P>
<IMG align=middle SRC="FIFTHLONG2.GIF">
<p>
We can shorten this by looking at the Table of Fifths, also known as the
Circle of Fifths:
<p>

<table border>
<tr>
 <th><b><a href="#TonicDef">Tonic</a></b></th> <th> </th> <th> </th>
      <th> </th> <th><b>Fifth</b></th> <th> </th> <th> </th>  
      <th><a href="#TonicDef"><b>Tonic</b></a></th>
</tr>
<tr align=center>
 <td><b>C</b></td> <td>D</td> <td>E</td> <td>F</td> <td><b>G</b></td> <td>A</td> <td>B</td> <td><b>C</b></td>
</tr>
<tr align=center>
 <td><b>G</b></td> <td>A</td> <td>B</td> <td>C</td> <td><b>D</b></td> <td>E</td> <td>F#</td> <td><b>G</b></td> 
</tr>
<tr align=center>
 <td><b>D</b></td> <td>E</td> <td>F#</td> <td>G</td> <td><b>A</b></td> <td>B</td> <td>C#</td> <td><b>D</b></td> 
</tr>
<tr align=center>
 <td><b>A</b></td> <td>B</td> <td>C#</td> <td>D</td> <td><b>E</b></td> <td>F#</td> <td>G#</td> <td><b>A</b></td> 
</tr>
<tr align=center>
 <td><b>E</b></td> <td>F#</td> <td>G#</td> <td>A</td> <td><b>B</b></td> <td>C#</td> <td>D#</td> <td><b>E</b></td> 
</tr>
<tr align=center>
 <td><b>B</b></td> <td>C#</td> <td>D#</td> <td>E</td> <td><b>F#</b></td> <td>G#</td> <td>A# = Bb</td> <td><b>B</b></td> 
</tr>
<tr align=center>
 <td><b>F#</b></td> <td>G#</td> <td>A# = Bb</td> <td>B</td> <td><b>C#</b></td> <td>D#</td> <td>E# = F</td> <td><b>F#</b></td> 
</tr>
<tr align=center>
 <td><b>C#</b></td> <td>D#</td> <td>E# = F</td> <td>F#</td> <td><b>G#</b></td> <td>A# = Bb</td> <td>B# = C</td> <td><b><b>C#</b></td> 
</tr>
<tr align=center>
 <td><b>G#</b></td> <td>A# = Bb</td> <td>B# = C</td> <td>C#</td> <td><b>D#</b></td> <td>E# = F</td> <td>G</td> <td><b>G#</b></td> 
</tr>
<tr align=center>
 <td><b>D#</b></td> <td>E# = F</td> <td>G</td> <td>G#</td> <td><b>A# = Bb</b></td> <td>B# = C</td> <td>D</td> <td><b>D#</b></td> 
</tr>
<tr align=center>
 <td><b>A# = Bb</b></td> <td>B# = C</td> <td>D</td> <td>D#</td> <td><b>E# = F</b></td> <td>G</td> <td>S</td> <td><b>A#</b></td> 
</tr>
<tr align=center>
 <td><b>E# = F</b></td> <td>G</td> <td>A</td> <td>A#</td> <td><b>B# = C</b></td> <td>D</td> <td>E</td> <td><b>E# = F</b></td> 
</tr>
<tr align=center>
 <td><b>C</b></td> <td>D</td> <td>E</td> <td>F</td> <td><b>G</b></td> <td>A</td> <td>B</td> <td><b>C</b></td> 
</tr>
</table>
<p>


If we use the rule of doubling/halving for octaves, 
we arrive at the following frequencies for the twelve notes
in our basic octave:
<p>

<table border>
<tr>
 <th>Frequency</th><th><a href="#TonicDef">Tonic</a></th> <th> </th> <th> </th> <th> </th> <th>Fifth</th> <th> </th> <th> </th> 
<!---        <th><a href="#TonicDef">Tonic</a></th> --->
            <th>Tonic</th>
</tr>
<tr align=center>
 <td>1</td> <td><b>C</b></td> <td>D</td> <td>E</td> <td>F</td> <td><b>G</b></td> <td>A</td> <td>B</td> <td><b>C</b></td>
</tr>
<tr align=center>
 <td>3 / 2</td> <td><b>G</b></td> <td>A</td> <td>B</td> <td>C</td> <td><b>D</b></td> <td>E</td> <td>F#</td> <td><b>G</b></td> 
</tr>
<tr align=center>
 <td>9 / 8</td> <td><b>D</b></td> <td>E</td> <td>F#</td> <td>G</td> <td><b>A</b></td> <td>B</td> <td>C#</td> <td><b>D</b></td> 
</tr>
<tr align=center>
 <td>27 / 16</td> <td><b>A</b></td> <td>B</td> <td>C#</td> <td>D</td> <td><b>E</b></td> <td>F#</td> <td>G#</td> <td><b>A</b></td> 
</tr>
<tr align=center>
 <td>81 / 64</td> <td><b>E</b></td> <td>F#</td> <td>G#</td> <td>A</td> <td><b>B</b></td> <td>C#</td> <td>D#</td> <td><b>E</b></td> 
</tr>
<tr align=center>
 <td>243 / 128</td> <td><b>B</b></td> <td>C#</td> <td>D#</td> <td>E</td> <td><b>F#</b></td> <td>G#</td> <td>A#</td> <td><b>B</b></td> 
</tr>
<tr align=center>
 <td>729 / 512</td> <td><b>F#</b></td> <td>G#</td> <td>A#</td> <td>B</td> <td><b>C#</b></td> <td>D#</td> <td>E# = F</td> <td><b>F#</b></td> 
</tr>
<tr align=center>
 <td>2187 / 1024</td> <td><b>C#</b></td> <td>D#</td> <td>E# = F</td> <td>F#</td> <td><b>G#</b></td> <td>A#</td> <td>B# = C</td> <td><b><b>C#</b></td> 
</tr>
<tr align=center>
 <td>6561 / 4096</td> <td><b>G#</b></td> <td>A#</td> <td>B# = C</td> <td>C#</td> <td><b>D#</b></td> <td>E# = F</td> <td>G</td> <td><b>G#</b></td> 
</tr>
<tr align=center>
 <td>19683 / 8192</td> <td><b>D#</b></td> <td>E# = F</td> <td>G</td> <td>G#</td> <td><b>A#</b></td> <td>B# = C</td> <td>D</td> <td><b>D#</b></td> 
</tr>
<tr align=center>
 <td>59049 / 32768</td> <td><b>A#</b></td> <td>B# = C</td> <td>D</td> <td>D#</td> <td><b>E# = F</b></td> <td>G</td> <td>S</td> <td><b>A#</b></td> 
</tr>
<tr align=center>
 <td>177147 / 131042</td> <td><b>E# = F</b></td> <td>G</td> <td>A</td> <td>A#</td> <td><b>B# = C</b></td> <td>D</td> <td>E</td> <td><b>E# = F</b></td> 
</tr>
<tr align=center>
 <td>531441 / 262144</td> <td><b>C</b></td> <td>D</td> <td>E</td> <td>F</td> <td><b>G</b></td> <td>A</td> <td>B</td> <td><b>C</b></td> 
</tr>
</table>
<p>

However, there are some rules of 
<a href="#PythagoreanHammers">acoustics</a> that might also be used:
<ul>
  <li>The frequency of the <i>perfect fifth</i> is 3/2 that of the 
<!---      <a href="#TonicDef">tonic</a>. --->
      tonic.
  <li>The frequency of the tonic at the end of the octave is twice that
      of the original 
<!---      <a href="#TonicDef">tonic</a>. <p> --->
      tonic. <p>
  <li>The frequency of the <i>perfect fourth</i> is 4/3 that of the 
<!--        <a href="#TonicDef">tonic</a>.  -->
      tonic.
  <li>The frequency of the <i>major third</i> is 5/4 that of the 
<!--        <a href="#TonicDef">tonic</a>.  -->
      tonic.
  <li>The frequency of the <i>minor third</i> is 6/5 that of the 
<!--        <a href="#TonicDef">tonic</a>.  -->
      tonic.
</ul>
<p>
Using these rules and combining them as efficiently as possible, one
arrives at the following list of frequencies for the notes in the
C major scale.  (That is, I'm leaving out five of the notes from the
chromatic scale.) 
<p>
<table border>
 <tr>
  <th>Note</th> <th><a href="#PythagoreanHammers">Acoustics</a></th> 
         <th>Up by fifths, down by octaves</th>
 </tr>
 <tr align=center>
  <td>C</td> <td>1</td> <td>1</td>
 </tr>
 <tr align=center>
  <td>D</td> <td>9/8</td> <td>9/8</td>
 </tr>
 <tr align=center>
  <td>E</td> <td>5/4</td> <td>81 / 64</td>
 </tr>
 <tr align=center>
  <td>F</td> <td>4/3</td> <td>177147 / 131042</td>
 </tr>
 <tr align=center>
  <td>G</td> <td>3/2</td> <td>3/2</td>
 </tr>
 <tr align=center>
  <td>A</td> <td>5/3</td> <td>27 / 16</td>
 </tr>
 <tr align=center>
  <td>B</td> <td>15/8</td> <td>243 / 128</td>
 </tr>
 <tr align=center>
  <td>C</td> <td>2</td> <td>531441 / 262144</td>
 </tr>
</table>
<p>

Notice that some of these fractions are not equal! In particular, the final
C in the scale ought to have frequency twice the basic C.  Instead, if we go 
waaaay  up by fifths, then back down again by octaves, we have this
strange fraction, whose decimal approximation is: 2.027286530.  If we took 
half of this to return to our starting point, we'd have:
<center>531441/524288 = 1.013643265.</center>
This discrepancy is known as the <a href="#PythagComma"><i>Pythagorean
(or ditonic) Comma</i></a>.  
<p>
So what is the problem?  To answer this, it is time to consider some
mathematics.
<p>
<h3>The mathematics</h3>
The essence of the comparison is that we went up twelve perfect fifths, which
is equivalent to changing the starting frequency from <b>1</b> to
<IMG align=middle SRC="FRACTION1.GIF">.
This should produce another copy of the note <b>C</b>, but
seven octaves up.  Thus, we should compare this frequency with
<IMG align=middle SRC="FRACTION2.GIF">.
<p>
The problem is that we are mixing a function
based on tripling (for the fifths) with a function based on doubling
(for octaves).   More abstractly, we are trying to solve an equation
of the type: 2^<i>x</i> = 3^<i>y</i>, where <i>x</i> and <i>y</i> are
rational numbers. (With minor finagling, we could restrict to just integers.)
<p>
Notice that for different notes in our 
<a href="#ChromaticScaleDef">chromatic scale</a>, we will be 
using different (and inequivalent) values of <i>x</i> and <i>y</i>.
The first issue to contend with regarding the difficulty of notes not
agreeing with themselves (that is to say, enharmonics that have
different frequencies) is to make a choice of where to concentrate the
errors.  There are ways of tuning an instrument so that some keys have
only slight problems, while other keys have rather bad discrepancies.
(See `<a href="#wolf">the wolf</a>' below.)
<p>
<h4>Equal Temperament</h4>
The method that western music has adopted
is to use the system of <b>equal 
<a href="#TemperamentDef">temperament</a></b> (also known as
<i>even temperament</i>) whereby the ratio of
the frequencies of any two adjacent `notes'
(i.e. <a href="#SemitoneDef">semitones</a>) is
constant, with the only interval that is acoustically correct
being the octave.   
It is not clear when this was originally developed.  Bach
certainly went a long way to popularize it, writing
two series of twenty-four preludes and fugues for keyboard
in each of the twelve major and twelve minor keys.  These
are known as the  <i>Well-tempered Clavier</i>.  If your 
harpsichord, clavichord or piano is not  even tempered, most of these
pieces will sound awful.  Some people claim that Bach actually
invented the system of even temperament.  However, guitars in Spain
were evenly tempered at least as early as 1482, long before Bach was
born.  Beethoven also wrote works that took advantage of equal
temperament, for instance, his Opus 39 (1803) <i>Two preludes through
the twelve major keys</i> for piano or organ. 
<p>
Even temperament spreads the error around in two ways.
<ol>
  <li>The errors in any particular key are more or less evenly spread about.
  <li>No keys are better off than any others.  With alternative means
      of tempering, such as just temperament or <a href="#MeanToneSystem">mean temperament</a>,
      roughly four (out of a possible twelve) major keys are clearly
      better than the others.  
</ol>
Since western music has settled on a
<a href="#ChromaticScaleDef">chromatic scale</a> consisting of twelve
<a href="#SemitoneDef">semitones</a>, we can compute the necessary ratio, <i>r</i>.  Since twelve
intervals will make an octave, we must have 
<p>
 <center>
  <img align="middle" src="NECESSARYRATIO.GIF">
 </center>
<p>
It is natural to use a logarithmic scale for measuring intervals in
our musical/acoustical setting.  The basic unit in our diatonic scale,
the semitone, in equal tempering is equal to
<a name=CentsDef><i>100&nbsp;cents</i></a>.
Thus, one semitone equals 100&nbsp;cents and an octave equals
1200&nbsp;cents.
<p>
<a name=PythagComma>
We can measure the <b>Pythagorean comma</b> in terms of cents.</a>
The discrepancy was:
<p>
<center> <table>
<tr align=center> <td>(3/2)^12</td> <td>~</td> <td>129.746...</td> </tr>
<tr align=center> <td>2^7</td>  <td>=</td> <td>128 </td>
</table></center>
<p>

Recall that <i>cents</i> are measured in a logarithmic scale with base
the twelfth root of two.  Therefore, our discrepancy, in hundreds of
cents is:
<P>
<IMG WIDTH=384 HEIGHT=56 ALIGN=BOTTOM SRC="IMG1.GIF"  > <P>
After a little algebra, we see that this is equal to
<P> <IMG WIDTH=419 HEIGHT=34 ALIGN=BOTTOM SRC="IMG2.GIF"  > <P>

This difference is so small that most people cannot hear it.  (There
are stories of violinists being particularly sensitive to such
differences, however.)
<p>

Following up on the algebra of the preceding problem, we see that an
interval corresponding to the ratio <i>I</i> equals
1200&nbsp;log[2](<i>I</i>)&nbsp;cents.  This will simplify the
formulas given below for the other commas
<p>

There are other commas: The <a href="#SyntonicComma"><i>syntonic (or
Didymic)</i> comma</a> is the difference between four perfect fifths and
two octaves plus a major third.  The syntonic comma occurs more easily
than the Pythagorean comma or the schisma, since one doesn't need to
go through particularly many chord progressions to move through
four perfect fifths.  

The <a href="#Schisma"><i>schisma</i></a> is the difference between
eight perfect fifths plus one major third and five octaves.  The <a
href="#Diaschisma"><i>diaschisma</i></a> is the difference between four
perfect fifths plus two major thirds and three octaves .  The
computations are given below. 


<p>
It should be clear at this point that most (indeed almost all) of the
acoustic intervals will be imperfect in an equally tempered scale.
<p>
Let me come back to some of the details of even temperament after
addressing another issue.  Namely, why should we have twelve half
steps in an octave anyway?
<p>
<h4>Continued Fractions</h4>
For convenience, denote the logarithm base 2 of <i>x</i> by log[2](<i>x</i>).
The heart of our problem with fifths and octaves is the
attempt to solve the equation 
2^<i>x</i> = 3^<i>y</i>, where <i>x</i> and <i>y</i> are
integers or rational numbers.  Notice, if we're using 
rational numbers it is an equivalent problem to solve the equation
2^<i>x</i> = 3.
<p>
If I take logarithms base 2 of both sides of the troublesome
equation, I am left with the equation
<p>
<center><i>x</i> log[2](2) = <i>y</i> log[2](3)</center>
<p>
Of course, since  log[2](2) = 1, the equation reduces to:
<p>
<center><i>x</i> = <i>y</i> log[2](3)</center>
<p>
We then try to solve this for integer or rational
values of <i>x</i> and <i>y</i>.  Unfortunately, log[2](3) is not a
rational number.  The best we can do is to try to approximate it by a
rational number.  A decimal approximation is: 1.584962500721156181.
<p>
A good (and well-known) way to approximate an irrational number by a rational
number is by continued fractions.  
<p>
A <b>continued fraction</b> is an expression of the form:
<p>
<center><img align="middle" src="STANDARDCONTINUEDFRACTION1.GIF"></center>
<p>
where
<img align=middle src="STDCONTFRACTINTEGERS.GIF"> are integers.  
Using this form
(with only <i>1</i>s in the numerators) means we will only be
considering <b>simple</b> continued fractions.
<p>
For notational convenience, write <i>[a_0, a_1, a_2, ...]</i> for the
infinite continued fraction above.  Of course, it is also possible to
consider finite continued fractions.  It is an exercise to see that
any rational number can be expressed as a finite continued fraction.
I refer you to Hardy and Wright's book for a discussion of the
uniqueness of such an expression.  If we cut off an infinite continued
fraction after <i>N</i> terms, we have the <i>N</i>th convergent.  For
the infinite continued fraction given above, this is
<p>
<center><img align="middle" src="STANDARDCONTINUEDFRACTION2.GIF"></center>
<p>
which is denoted <img align="middle" src="STDCONTFRACTNOTATION.GIF"> .
This is obviously a
rational number, which we write (in reduced form) as
<img align="middle" src="STDCONTFRACTCONVERGENT.GIF">
<p>
There is a convenient algorithm for computing the continued fraction
expansion of a given number <i>x</i>, called <b>the continued fraction
algorithm</b>.  For any positive number <i>A</i>, let [<i>A</i>]
denote the integer part of <i>A</i>.  To compute a continued fraction
expansion for <i>x</i>, take <i>a_0 = [x]</i>.  So
<p>
<center><i>x = a_0 + x_0</i></center>
<p>
and <i>0 &lt;= x_0 &lt; 1</i>.
<p>
Now write <p>
<center><i>1/x_0 = a_1 + x_1</i> &nbsp; with &nbsp;<i>a_1 = [1/x_0]</i></center>
and
<p>
<center><i>1/x_1 = a_2 + x_2</i> &nbsp; with &nbsp;<i>0 &lt;= x_2 &lt; 1</i></center>  
<p>
and so on.

<h4>Some examples</h4>
In what follows, the notation for a repeating continued fraction is
similar to that for 
a repeating decimal expression.  For the continued fraction
<img align=middle src="CONTFRACTNOTATION1.GIF"> , we write
<img align=middle src="CONTFRACTNOTATION2.GIF"> . 
<ul>
  <li><img align="middle" src="SQUAREROOT2.GIF">=[1,2,2,2,...]
      = <img align="middle" src="SQUAREROOT2CF.GIF">
      with convergents: <img align="middle" src="SQUAREROOT2CVGTS.GIF">
  <li><img align="middle" src="GOLDENMEAN1.GIF">=[1,1,1,1,1,...]
      = <img align="middle" src="GOLDENMEAN1CF.GIF">
      with convergents: <img align="middle" src="GOLDENMEAN1CVGTS.GIF"><br>
      Notice that the numerators and denominators of the convergents
      are successive Fibonacci numbers.  If you start simplifying the
      convergents of the 
      continued fraction [1,1,1,1,...] as a rational number, you will
      soon see why this is so.  Also, it is a well-known fact that the
      ratio of successive Fibonacci numbers is indeed the <b>golden
      mean</b> <img align="middle" src="GOLDENMEAN1.GIF">.
      That is to say, this particular continued fraction does indeed
      converge to the irrational number it is supposed to represent. 
  <li><i>e</i> = [2, 1, 2, 1, 1, 4, 1, 1, 6, 1, 1, 8, 1, 1, 10,...]
      with convergents: <img align="middle" src="ECVGTS.GIF">.<br>
      Remarkably, the obvious pattern in the continued fraction
      expansion for <i>e</i> actually persists.
  <li><img align="middle" src="PI.GIF">=[3,7,15,1,292,1,1,1,2,...]
      with convergents: <img align="middle" src="PICVGTS.GIF">.<br>
      Unlike the continued fraction expansion for <i>e</i>, the
      complete expansion for <img align="middle" src="PI.GIF"> 
      is unknown.  
</ul>
<p>
There are two pertinent theorems (see Hardy and Wright):
<p>
<b>Theorem 1</b>&nbsp;&nbsp; If <i>x</i> is an irrational number and <i>n
&gt;=1</i>, then
<p>
<center><img align="middle" src="THEOREM1.GIF">
</center>
<p>
Since the denominator of the <i>(n+1)</i>st convergent is strictly
larger than the denominator of the <i>n</i>th convergent (and they are
all integers), we see that the continued fraction expansion does
indeed converge to the irrational number it is meant to be
approximating.  
<p>
<b>Theorem 2</b>&nbsp;&nbsp; If <i>x</i> is an irrational number, <i>n&gt;=1</i>, 
<i>0 &lt; q &lt;= q_n, </i> and <img align="middle" src="THEOREM2A.GIF">
with <i>p, q</i> integers, then
<p>
<center><img align="middle" src="THEOREM2B.GIF">
</center>
<p>
That is to say, the <i>n</i>th convergent is the fraction among all
fractions whose denominator is no greater than <i>q_n</i> which
provides the best approximation to <i>x</i>.  It is common to use the
size of the denominator as a measure of the `complexity' of the
rational number.  Thus, we have that the <i>n</i>th convergent is
optimal for a given complexity.
<p>
What does this say for our musical problem?
<p>
Recall that the troublesome equation
2^<i>x</i> = 3^<i>y</i> is equivalent to the equation
2^<i>x</i> = 3, provided we use rationals, and not just integers.  The
obvious solution is <i>x</i>=log[2](3).  We want to approximate this
by a rational number.
<p>
The continued fraction expansion for log[2](3) is [1,1,1,2,2,3,1,5,2,23,2,2,1,...]
(see 
<A HREF="http://silk.research.att.com/~njas/cgi-bin/form/sequences/eisA.cgi?Anum=028507">sequence A028507</a> of the
<a href="http://silk.research.att.com/~njas/sequences/">On-Line Encyclopedia of Integer Sequences</a> for more terms).
The first few convergents are:
<p>
<center><table>
 <tr align=center>
  <td>1,</td> <td>2,</td> <td>3/2,</td> <td>8/5,</td> <td>19/12,</td>
  <td>65/41,</td> <td>84/53,</td> <td>485/306</td>
 </tr>
</table></center>
(
<A HREF="http://silk.research.att.com/~njas/cgi-bin/form/sequences/eisA.cgi?Anum=005663">A005663</a> /
<A HREF="http://silk.research.att.com/~njas/cgi-bin/form/sequences/eisA.cgi?Anum=005664">A005664</a>).
<p>
Thus, taking the fourth approximation (start counting at zero):
<p>
 <center>
  <img align="middle" src="APPROXEQUATION.GIF">
 </center>
<p>
That is to say, we obtain the perfect fifth, one octave up, by
nineteen semitones.  Moreover, the denominator, being twelve, forces
us to have twelve semitones per octave.  
Thus, western music has adopted, quite by accident I assume, the
fourth best approximation to a Pythagorean scale using equal
temperament.  
<p>
Obviously it is possible to have scales that come from dividing an
octave into other than twelve pieces. 
For instance, the typical Chinese scale has five
`<a href="#SemitoneDef">notes</a>' to the octave.  Remarkably, this
corresponds to the third convergent of the continued fraction expansion.
<p>
Going in the other direction, we could use the next more accurate
continued fraction approximation of log[2](3), which would lead to an
octave consisting of forty-one pieces.  Below is a comparison of what
happens to some standard intervals in these three systems.  
The fundamental interval for our standard twelve-tone chromatic scale
is the semi-tone.  There is no name for the basic intervals of our
other chromatic scales.  So we will refer to their basic intervals
merely as `basic intervals'.  
<p>
If we compute <I>exactly</I> in a twelve-tone scale, we find:
<UL>
<LI> The fifth is 
  <IMG WIDTH=190 HEIGHT=24 ALIGN=MIDDLE SRC="FIFTH_12TONES.GIF">  
  basic intervals (semitones).
<LI> The major third is 
  <IMG WIDTH=182 HEIGHT=24 ALIGN=MIDDLE SRC="MAJTHIRD_12TONES.GIF">  
  basic intervals (semitones).
<LI> The minor third is 
  <IMG WIDTH=181 HEIGHT=24 ALIGN=MIDDLE SRC="MINTHIRD_12TONES.GIF">  
  basic intervals (semitones).
</UL>
<P>
<P>
If we used a five-tone scale, we would have:
<UL>
  <LI> The fifth being  
  <IMG WIDTH=189 HEIGHT=24 ALIGN=MIDDLE SRC="FIFTH_5TONES.GIF">
      basic intervals.
  <LI> The major third being  
   <IMG WIDTH=189 HEIGHT=24 ALIGN=MIDDLE SRC="MAJTHIRD_5TONES.GIF">  
      basic intervals.
  <LI> The fourth being  
      <IMG WIDTH=189 HEIGHT=24 ALIGN=MIDDLE SRC="FOURTH_5TONES.GIF">
      basic intervals.
  <LI> The minor third being  
      <IMG WIDTH=189 HEIGHT=24 ALIGN=MIDDLE SRC="MINTHIRD_5TONES.GIF">  
      basic intervals.
</UL>
Thus, the major third and the perfect fourth would be
indistinguishable in an equal-tempered five-tone scale.<br>
The ?  for the major third and minor third indicate that the rounding to
the nearest integer is fairly inaccurate.
<P>
<P>
If we used forty-one semitones per octave, we would have:
<UL>
  <LI> The fifth being 
      <IMG WIDTH=233 HEIGHT=24 ALIGN=MIDDLE SRC="FIFTH_41TONES.GIF">  
      basic intervals.
  <LI> The major third being  <IMG WIDTH=232 HEIGHT=24 ALIGN=MIDDLE SRC="MAJTHIRD_41TONES.GIF">  
      basic intervals.
  <LI> The fourth being <IMG WIDTH=233 HEIGHT=24 ALIGN=MIDDLE SRC="FOURTH_41TONES.GIF">  
      basic intervals. 
  <LI> The minor third being  <IMG WIDTH=232 HEIGHT=24 ALIGN=MIDDLE SRC="MINTHIRD_41TONES.GIF">  
      basic intervals.
</UL>
This type of scale has a fairly good separation of the standard
acoustically distinct notes. I would guess that if we used such a scale,
our ears would be trained to hear the difference between adjacent
basic intervals.  However, this difference is only 12/41, which is 29 cents,
only slightly more than the Pythagorean comma.
<p>

Interestingly, around 40&nbsp;B.C., King Fang, in China, discovered
the sixth best approximation given above.  It is
unlikely, of course, that he actually used continued fractions to do
this, which makes it all the more remarkable.  In particular, Fang
noticed that fifty-three perfect fifths are very nearly equal to
thirty-one octaves.  This leads to what is sometimes called the
<i>Cycle of 53</i>.  It can be represented by a spiral of fifths,
replacing the more usual circle of fifths.  

<p>
 <center>
  <img align="middle" src="PARBREAK.GIF">
 </center>
<p>

<a name=PythagoreanHammers><h3>The Pythagorean Hammers and Acoustics</h3></a>
Western music has adopted certain intervals as basic to
acoustics.  It is not always the case that there the choices made are
more natural than their alternatives.  The legend about the source of
some of these intervals involves Pythagoras.  The story has him
listening to the sound of the hammers of four smiths, which he found
to be quite pleasant.  Upon investigation, the hammers weighed 12, 9,
8, and 6 pounds.  From these weights, Pythagoras derived the
intervals:
<UL>
 <li> The octave: &nbsp;&nbsp 12:6 = 2:1
 <li> The perfect fifth: &nbsp;&nbsp; 12:8 = 9:6 = 3:2
 <li> The perfect fourth: &nbsp;&nbsp; 12:9 = 8:6 = 4:3
 <li> The whole step: &nbsp;&nbsp; 9:8
</ul>
<p>

I don't know.  Maybe.  It's hard to say what really happened
twenty-six centuries ago.  But this certainly seems lucky.  Maybe he
was sitting in the same bath tub that Archimedes was sitting in four
hundred years later.
<p>

In the present, we can look to see what might be natural intervals to
construct.  Firstly, the octave is quite natural, as a doubling of
frequency.  As usual, we will also take its inverse, halving of
frequency, as equally natural.  The next integral
multiplication of frequency is tripling, which leads to the perfect
fifth when combined with halving.  Multiplying the frequency by four
is just going up two octaves, so we already have that in our system. 
<p>

The next natural operation is, then, to multiply the frequency by
five.  To remain in the original octave, we need to combine this with
two halvings, leading to the interval of the major third.
<p>

Now it is not simply a preference for integers that leads to these
intervals.  There is also the phenomenon of <i>overtones</i>.  A
vibrating string has a fundamental tone, whose frequency <i>f</i> can be
calculated from its length <i>L</i>, mass <i>m</i> and tension
<i>T</i> according to a basic formula of acoustics: 
<img align=middle src="FUNDAMENTALTONEFORMULA.GIF">
But the
string also vibrates in other modes with less intensity.  These other
modes are vibrations at integer multiples of the fundamental
frequency.  The increasing sequence of such frequencies is called the
<i>harmonic series</i> based on the given fundamental.  The
fundamental is called the <i>first harmonic</i>.  The frequency of the
octave (twice that of the fundamental) is called the <i>second
harmonic</i>.  The <i>third harmonic</i> is the perfect fifth one
octave up from the fundamental.  And so it goes. 
Thus, the argument for preferring
intervals based on doubling, tripling and multiplying by five is
actually based on acoustics, not just a fondness for the numbers 2, 3
and 5.
<p>

The phenomenon of overtones is an important factor in the quality of
the sound of any particular instrument.  
Now, in theory, it may appear that the harmonic series for a particular
fundamental frequency continues through all the integers.  However,
this would surely produce unbearable dissonance.  What actually
happens is that the intensity of the higher harmonics decreases quite
rapidly.  Indeed, on some instruments it is difficult to discern
beyond the third harmonic.  (My guitar, for instance.)
Violins and oboes 
have strong higher harmonics, leading to a `bright' tone.
Flutes and recorders have weak higher harmonics.
Apparently the clarinet has strong odd-numbered harmonics, which is
why has a `hollow' tone.  Before valves were added to brass
instruments, it was only notes corresponding to harmonics that could
be played on these instruments.  
<p>

After the intervals based on multiplying by two, three and five, our
choices become more arbitrary.   
<ul>
 <li>The perfect fourth.  Should we go down a perfect fifth then up
     an octave, resulting in an interval of (3/2)(2)=4/3?  Or should
     we do something else?
 <li>The whole tone.  Why is it better to go up two perfect fifths and
     down an octave: (3/2)(3/2)(1/2)=9/8 rather than, say, up two
     fifths and down three major thirds: (3/2)(3/2)*(4/5)(4/5)(4/5) =
     144/125? (There is a difference of about 41
     <a href="#CentsDef">cents</a> here.)
 <li>The minor third.  Should we use (4/5)(3/2) = 6/5, i.e. down
     a major third and up a perfect fifth, 
     or (2/3)(2/3)(2/3)(2)(2) = 32/27, i.e. down three fifths and up
     two octaves?
 <li>The major third.  One could even argue that
     (3/2)(3/2)(3/2)(3/2)(1/2)(1/2) = 81/64 is preferable to 5/4 as
     the former is obtained by going up four perfect fifths then down
     two octaves, thus using only the doubling and tripling rules.
</ul>

<p>
 <center>
  <img align="middle" src="PARBREAK.GIF">
 </center>
<p>

For the sake of curiosity, we could investigate what we obtain using
the <i>major third</i> as the basis for our computations.  The
acoustic major third is 5/4.  Thus, the critical quantity is
log[2](5/4) = log[2](5) - log[2](4).
<p>
Since log[2](4) is an integer, the crux of the approximation is that
of log[2](5).  The continued fraction expansion is [2, 3, 9, 2, 2, 4, 6, 2, 1, 1, 3, 1, 18]
The convergents are: 7/3, 65/28, 137/59, 339/146, 1493/643, ...
<p>
Since three is certainly too few for an octave, we would have been
stuck with octaves of twenty-eight notes!
<p>
 <center>
  <img align="middle" src="PARBREAK.GIF">
 </center>
<p>

<h4>Some other commas</h4>

<dl>
  <dt><a name=SyntonicComma><b>Syntonic Comma</b></a>
  <dd>The <I>syntonic (or Didymic)</I> comma is the
difference between four perfect fifths and two octaves plus a major
third.
<P>
Four perfect fifths correspond to
<IMG WIDTH=39 HEIGHT=53 ALIGN=MIDDLE SRC="FOURPERFECTFIFTHS.GIF">. 
In the key of C, this is
<IMG WIDTH=57 HEIGHT=12 ALIGN=BOTTOM SRC="CTOE.GIF">.
<P>
Two octaves plus a major third correspond to 
 <IMG WIDTH=49 HEIGHT=48 ALIGN=MIDDLE SRC="TWOOCTAVESANDMAJTHIRD.GIF"> .
<P>
Using the logarithmic scale,
<P> 
<IMG WIDTH=451 HEIGHT=49 ALIGN=BOTTOM SRC="SYNTONICCENTS.GIF"> 
<P>
  <dt><a name=Schisma><b>Schisma</b></a>
  <dd>The <I>schisma</I> is the difference between eight perfect
fifths plus one major third and five octaves.
<P>
Eight perfect fifths plus one major third correspond to 
 <IMG WIDTH=76 HEIGHT=53 ALIGN=MIDDLE SRC="EIGHTPERFECTFIFTHSANDMAJTHIRD.GIF">. 
<P>
Five octaves correspond to  <IMG WIDTH=50 HEIGHT=13 ALIGN=BOTTOM SRC="FIVEOCTAVES.GIF">.
<P>
Using the logarithmic scale:
<P> <IMG WIDTH=456 HEIGHT=49 ALIGN=BOTTOM SRC="SCHISMACENTS.GIF">
<P>
  <dt><a name=Diaschisma><b>Diaschisma</b></a>
  <dd>The <I>diaschisma</I> is the difference between four perfect fifths
plus two major thirds and three octaves .  The computation is
<P>
<IMG WIDTH=430 HEIGHT=49 ALIGN=BOTTOM SRC="DIASCHISMACENTS.GIF">
<p>
</dl>
 <center>
  <img align="middle" src="PARBREAK.GIF">
 </center>
<p>
<a name=MeanToneSystem><h4>Mean-tone system</h4></a>
One alternative to equal <a href="#TemperamentDef">temperament</a> is 
the <i>mean-tone system</i>, which seems to have begun around 1500.  In
mean temperament, the fifth is 697 cents, as opposed to 700 cents in
equal temperament or 701.955 cents for the acoustically correct
interval.  The mean-tone system for tuning a piano is satisfactory in
keys that have only one or two sharps or flats.  But there are problems.
For instance, G#=772 cents and Ab=814.  They ought to be the same!  This
discrepancy is called <a name=wolf><b>the wolf</b></a>.  While the
Pythagorean comma, at 23.5 cents, is not discernible by most listeners,
the wolf, at 52 cents is quite noticeable.
<p>
Before equal temperament was widely accepted, keyboards had to
accommodate these problems.  One solution was only to play simple
pieces in the keys your instrument could handle.  A second solution,
which was certainly necessary for large and important organs, was to
have divided keyboards.  Thus, the single key normally used today for
G# and Ab would be split into two keys.  Often, the back of one key
would be slightly raised to improve the organist's ability to play by
touch.  The most extraordinary keyboard I was able to find a reference
to was Bosanquet's `Generalized Keyboard Harmonium' built in 1876,
which had 53 keys per octave!
<a name="MarkThanks"></a><h4>Acknowledgment</h4></a>
My thanks to Mark McConnell for his help with the ideas in this web page.
<p>
<h4>References</h4>
<ul>
 <li>Eric Blom (ed.) <i>Grove's Dictionary of Music and Musicians</i>,
     Fifth Edition, St Martin's Press, Inc., 1955.
 <li>G.H. Hardy and E.M. Wright, <i>An Introduction to the Theory of
     Numbers</i>, Fourth Edition, Oxford University Press, 1975.<br>
     See, in particular, Chapters X and XI concerning continued
     fractions. 
 <li>Don Michael Randel, <i>Harvard Concise Dictionary of Music</i>,
     Harvard University Press, 1978.<br>
     See the sections titled `Comma' and `Temperament'.  
 <li>Percy Scholes, <i>The Oxford Companion to Music</i>, Ninth
     Edition,Oxford University Press, 1955. <br>
     See the section titled
     `Temperament'.
</ul>
<h4>Definitions</h4>
<dl>
  <dt><a name=ChromaticScaleDef>Chromatic Scale</a>
  <dd>The chromatic scale contains all the possible pitches in an
      octave, as opposed  to a diatonic scale, which contains
      combinations of whole tones and semitones.  When using octaves
      divided into other than twelve intervals, the chromatic scale
      contains all the microtones in the subdivision.  
  <dt><a name=SemitoneDef>Semitone</a>
  <dd>A <i>semitone</i> is the basic interval of the standard octave
      of western music.  That is to say, it is an interval of 2^(1/12).
      For the scales of five, twelve and forty-one
      notes that are also considered here, the semitone is not quite
      as useful.  Instead, we speak of the `basic interval'.  For the
      scale obtained by dividing the octave into five pieces, the
      basic interval is 2^(1/5).  Generally, intervals that are not
      obtained from semitones are called <i>microtones</i>.  
  <dt><a name=TonicDef>Tonic</a>
  <dd>The tonic is the first note in a key or scale.  It is also the
      note after which the scale is named, hence, the keynote.
  <dt><a name=MajorThirdDef>Major Third</a>
  <dd>For the purposes of this discussion, we take a <i>major third</i>
      to be defined as the interval corresponding to a change in
      frequency by a factor of 5/4.  In the key of C, this is the
      interval C-E (but only approximately in equal temperament!).
  <dt><a name=MinorThirdDef>Minor Third</a>
  <dd>For the purposes of this discussion, we take a <i>minor third</i>
      to be defined as the interval corresponding to a change in
      frequency by a factor of 6/5.   In the key of C, this is the
      interval (approximated by!) C-Eb.
  <dt><a name=TemperamentDef>Temperament</a>
  <dd>For our purposes, <i>temperament</i> refers to any system of
      defining the frequencies of the notes in a scale, be it chromatic,
      diatonic or some other sort of scale.
</dl>


<hr>
<p>
<!-- hhmts start -->  
<!--  Last modified: Wed Jul 10 11:47:11 CDT 1996 -->
<!-- hhmts end -->

<address>Edward Dunne <a href="mailto:egd@ams.org">(egd@ams.org)</a><br>
<a href="http://www.ams.org">American Mathematical Society </a>
</address>
<p>
<hr>
  
</body> </html>
<!--  LocalWords:  td td td td td td td
 -->