[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference rusure::math

Title:Mathematics at DEC
Moderator:RUSURE::EDP
Created:Mon Feb 03 1986
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2083
Total number of notes:14613

2026.0. "musical problem" by FLOYD::YODER (MFY) Mon Feb 05 1996 13:54

Find the smallest equal temperament scale which well approximates both a perfect
fifth and a perfect (major) third.  (This requires a little judgment; but the
intent is that "well approximates" means that the pitch ratios are close enough
that the difference isn't audible to most people.)

An equal temperament scale is one based on equal divisions of a perfect octave,
i.e., pitch ratios which are the Nth root of 2 for some N.  The standard equal
temperament scale has N=12, twelve tones per octave.

A perfect fifth is a pitch ratio of 3/2.  A perfect major third is a ratio of
5/4.  (A perfect fourth is the ratio 4/3 and is the difference between an octave
and a perfect fifth: musical intervals are generally treated logarithmically.  A
perfect minor third is the ratio 6/5, the difference between a perfect fifth and
a perfect major third.  Thus if fifths and major thirds are well approximated,
so are fourths and minor thirds.)
T.RTitleUserPersonal
Name
DateLines
2026.1restatement of problemFLOYD::YODERMFYWed Feb 07 1996 16:2514
The following shows how to make the problem solvable with the aid of a computer
program; perhaps someone can suggest ways to reduce the computation such a
program must do.

Let lg(x) denote the logarithm base 2; this is convenient because an octave is a
ratio of 2.  Then the problem is to find N such that the set of numbers {i/N (i
an integer)} well approximate both lg(3/2) and lg(5/4).

The common modern unit for measuring small pitch ratios is the "cent", which is
the 1200th root of 2 (there are 100 cents to the semitone, 12 semitones to the
octave).  Thus, on a logarithmic (base 2) scale, 1 cent = 1/1200.  If anyone
wishes to approach this using a computer, I suggest expressing the results in
cents (this is to make experimentation with actual tones easier, since
electronic tuners will yield results expressed that way).
2026.2AUSSIE::GARSONachtentachtig kacheltjesWed Feb 07 1996 19:486
    re .1
    
    Can it be assumed that N=12 (i.e. normal scale) well approximates those
    intervals? If so, there is very little computation needed to show that
    no smaller number does any better. I assumed that error in pitch could
    be reasonably measured by absolute difference in the log of the pitch.
2026.3FORTY2::PALKAThu Feb 08 1996 08:237
    How well do most people hear ?
    
    I believe many musicians (especially the players of those instruments
    where the player can affect the pitch) would say that the conventional
    12 tone scale does not approximate these ratios very well.
    
    Andrew
2026.4reply to .2FLOYD::YODERMFYThu Feb 08 1996 13:2310
> Can it be assumed that N=12 (i.e. normal scale) well approximates those
    intervals?

It is commonly considered by musicians that the standard scale well approximates
fifths but not thirds.  So the short answer is "no."  (This may also help in
making my rather vague requirements more precise, since it will give you both an
error that is small enough and one that isn't.)

Yes, the absolute value of the logarithm is an excellent measure of the error;
you may take it for granted that it is the "right" one for this problem.
2026.5Re: .3FLOYD::YODERMFYThu Feb 08 1996 14:0226
>   How well do most people hear ?
    
>   I believe many musicians (especially the players of those instruments
>   where the player can affect the pitch) would say that the conventional
>   12 tone scale does not approximate these ratios very well.

My statement of the problem was oversimplified for the sake of easily getting to
a purely mathematical problem.  The really interesting issue is not so much
whether the true and approximate tones are distinguishable, but whether the
approximate one makes a pleasing consonance with the tonic, and whether jumps of
the approximate interval "sound right."  (The ta-TAAA which starts the Star Wars
theme, for example, is an interval of a fifth.)

On instruments where the player can affect the pitch, I am pretty sure it is a
consensus among both musicians and physicists that good players intuitively take
advantage of this variation to *make* the played intervals sound right; they
aren't sticking to an equal temperament scale (or any other scale with fixed
tones) in any case.  The issue of temperaments primarily matters for keyboard
instruments and the like where pitch is fixed at manufacturing time.  Of course,
even with instruments with variable pitch, it is arguable that those intended to
be played in ensemble should be designed to have their normative tones close to
some standard.

I judged that it was a lie that was helpful to understanding (as Knuth put it in
his TeX book) to pose the question as having the tones sound alike.  The above
is hopefully the whole truth of the matter.
2026.6HANNAH::OSMANsee HANNAH::IGLOO$:[OSMAN]ERIC.VT240Thu Feb 08 1996 16:5426
Well, let's see.  If we start from middle C and count up a major third to E(i.e.
singing "dong ding", where "ding dong" is the familiar doorbell ("just a
miiiiiiiinute...") sound), we have

	C D D# E
        0 1  2 3

So in the 12-note scale, E is 2**(3/12) or 2**(1/4) or the fourth root of 2
times the frequency of C (I think C happens to be 256 hertz).

But I forget how to calculate the *non* tempered value of the major third.
How do we get 5/4 ?  I must be forgetting something basic here.


Similarly, to get from C to G (the first two notes of Star Wars theme maybe,
unless it starts at the lower G with some sort of up note), we have

	C D D# E F F# G
	0 1 2  3 4 5  6

So G is 2**(6/12) or 2**(1/2) or the square root of 2 times middle C.

But how do we get that the non-tempered value should really be 3/2 ?  

/Eric
2026.7WIBBIN::NOYCEEV5 issues 4 instructions per meterThu Feb 08 1996 17:4010
Eric, you've forgotten C#.  The standard 12-tone scale approximates
the (major) third as 2**(4/12) and the fifth as 2**(7/12).
2**(3/12) is a minor third.

The interval at 2**(6/12) (half of an octave) is called the tri-tone.
It's the sound European emergency vehicles use instead of sirens.

The reason you want 3/2 or 5/4 is so that the tones resonate together.
You get three or five cycles of the harmonic in the same time as two or
four cycles of the fundamental.
2026.8possibly useful Pascal programFLOYD::YODERMFYThu Feb 08 1996 18:0851
{
  A Pascal program to calculate the errors in cents for various values of N
  for the pure fifth, pure major third, and pure minor third.

  To reduce output, substitute some condition for "true" below.
}
program scale(input, output);
const
  nfield = 4;
  rfield = 8;
  rdigits = 2;
  cents = 1200; { per octave }
  min_n = 2;
  max_n = 100;
type
  fraction = packed array[1..3] of char;
var
  lg_fifth, lg_major, lg_minor: real;
  efifth, emajor, eminor, sum, max_err: real;
  n: integer;

  function error(x: real; n: integer): real;
  begin
    error := cents*abs(round(n*x) - n*x)/n;
  end;

begin
  lg_fifth := ln(3/2)/ln(2);
  lg_major := ln(5/4)/ln(2);
  lg_minor := ln(6/5)/ln(2);
  writeln('n': nfield,
	  'efifth': rfield, 'emajor': rfield, 'eminor': rfield,
	  'sum': rfield, 'max': rfield);
  for n := min_n to max_n do
    begin
      efifth := error(lg_fifth, n);
      emajor := error(lg_major, n);
      eminor := error(lg_minor, n);
      sum := efifth + emajor + eminor;
      max_err := efifth;
      if emajor > max_err then max_err := emajor;
      if eminor > max_err then max_err := eminor;
      if (n = 12) or (true) then
        writeln(n: nfield,
		efifth: rfield: rdigits,
		emajor: rfield: rdigits,
		eminor: rfield: rdigits,
		sum: rfield: rdigits,
		max_err: rfield: rdigits);
    end;
end.
2026.9first prize as "hoze player" at conservatoryGVAADG::DUBEZero is not not not zero, or is it?Thu Feb 08 1996 19:0035
re .6

>> How do we get 5/4 ?  I must be forgetting something basic here.
>> But how do we get that the non-tempered value should really be 3/2 ?  

I got once this demonstration with a hoze, opened on one side, closed on the
other side. My teacher (organ teacher) took such hoze and started rotating this
"instrument" faster and faster.

Suppose at low speed, the hoze sounds a "C" (DO) as the basic harmonic;
accelerate the rotation to play the second harmonic, which is 
precisely the "C" at the octave (let's call it 'second octave', to simplify).

Accelerate again to get the third harmonic, and you clearly hear a "G" (SOL) in
the second octave. Hence the frequency ratio between "natural G" and  
"natural C" is 3/2.

Fourth harmonic brings to the "C" in the 'third octave'.

Faster again if you can: you reach the fifth harmonic: clearly the "E" (MI) in
the third octave. So we can deduce that the frequency ratio between 
"natural E" and "natural C" is 5/4.

And so on: 6_th harmonic is "G", then "B flat" (Si bemol), then "C"
and 9_th harmonic is "D", which gives the interval between D and C = 9/8.

Got it? In the natural scale (Darlin scale) the tones have distinct intervals:
ex : C<->D = 9/8, whilst D<->E = 10/9. So if the tuning of the organ (or piano)
is based on natural scale, then some tunes sound well (C major for ex.) but
some other tunes are simply horrible (F# sharp!).

In summary, in the natural scale of Darlin, the notes are deduced from the
frequency of the harmonics, starting from the basic tone.

##### Remy #####
2026.10the standard scaleFLOYD::YODERMFYThu Feb 08 1996 19:018
>(I think C happens to be 256 hertz).

Almost.  The standard scale has A=440 hertz exactly.  A long time ago I read a
mathematics book in which one section (concerning music) claimed that C was 256
cycles per second (the term "hertz" wasn't in use yet).  This was an error, but
it seems to be popular among physicists (presumably because it makes the various
"C" tones powers of 2).  I believe, however, that the A=440 standard is from the
1800s (I could look it up).
2026.11AUSSIE::GARSONachtentachtig kacheltjesFri Feb 09 1996 00:055
    re .4
    
    n=53 is the smallest n such that the error in both intervals is less
    than the error that the n=12 scale has in the "fifth" - according to my
    q&d program.
2026.12how about 22 or 31-tone scales?AD::GRUNDMANNBillFri Feb 09 1996 11:4168
    consider an octave from 440 Hz to 880 Hz
    
    a major third is 5/4 of 440 Hz, or 550 Hz
    a perfect fifth is 3/2 of 440 Hz, or 660 Hz
    
    where do these ideal pitches fall in the octave?
    
    call the usual 12-tone scale names 0 through 12, for C-D-E-F-G-A-B-C
    Each step can be subdivided by 100. These are called cents.
    
    assume 441 Hz would be recognizably off-pitch by the listener
    (the beat frequency would be 1 Hz)
    call this the threshold pitch
    
    consider an octave of pitches to fall between 1.0 Hz and 2.0 Hz
    
    a major third is now 1.250 Hz
    a perfect fifth is now 1.500 Hz
    the threshold pitch is now 1.00227 Hz
    
    
    the basic equation for scale step to pitch is:
             f = pow(2,s/12)
    
    solve for s:
             log2(f) = s/12
    
             s = 12 * log2(f)
    
    major third     is 3.86314
    perfect fifth   is 7.01955
    threshold pitch is 0.0393016
    
    You can see that the 12-tone scale is pretty far off on the major third
    (86.3 cents)
    The threshold pitch is about 3.9 cents, call it 4.
    
    
    Now all we want to do is divide this range from 0-12 into some other
    evenly spaced steps.
    
    It might be easier if we normalize the scale steps from 0.0 to 1.0
    
    major third is   0.321928
    perfect fifth is 0.584963
    
    Now problem is reduced to dividing the unit interval into equal sized
    steps,
    two of which are really close to these values.
    Really close is within the threshold of 4 cents, or 0.00327513 within
    the unit interval
    
    Try 31.
    step  fraction  value     error       in cents
    10    10/31     0.322581  0.00065255  0.78306
    18    18/31     0.580645  0.00431734  5.18081   a little more than 4
    cents, but probably OK.
    
    I had heard of 31-tone scales before. I think 22 is supposed to be
    pretty good too.
    
    for 22,
    step  fraction  value     error       in cents
     7     7/22     0.318182  0.00374628  4.49553
    13    13/22     0.590909  0.00594659  7.13591
    
    this is not bad either...
    
2026.13replies to .11 and .12FLOYD::YODERMFYFri Feb 09 1996 13:3326
Re: .11

Yes, 53 is the answer I got.  I took the error for a fifth in the 12-tone scale
(1.95 cents), arbitrarily decided to make 2 cents the max allowable error, and
went from there.  Part of my interest here was to see whether others would use
different approaches (admittedly not a purely mathematical concern).

Re: .12

The error in a major third in the 12-tone scale, according to the program posted
in .8, is about 13.7 cents.  Since I know that some other results the program
produces are correct (like the error for a fifth), I think it's at least close. 
Could you check your results?

Roughly speaking, you get n=31 if you allow a max threshold of 6 cents.  The
errors for a fifth, major third, and minor third are 5.18, 0.78, and 5.96.

For n=22, the errors are 7.14, 4.50, and 11.63.  (For any N we care about, the
error in the minor third will be either the sum or the difference of the other
two errors; unfortunately in this case it is the sum.)  So I would be inclined
to avoid it because of the error in the minor third, though I admit that wasn't
given as part of the problem.

n=34 has a max error under 4 cents, n=46 a max error under 5 cents, and n=50 a
max error under 6 cents.  Since n=34 is superior to these other two, it is also
a plausible answer.
2026.14HANNAH::OSMANsee HANNAH::IGLOO$:[OSMAN]ERIC.VT240Fri Feb 09 1996 13:5426
Sorry about omitting C#.  I'm disappointed that this error detracted
from what I was trying to emphasize.

I seem to still be missing some basics back there.

Someone said, regarding the garden hose:

	harmonic	note
	--------	-----
	1		C
	2		next C
	3		G
	4		next C
	5		E
	6		G
	7		Bb
	8		next C
	9		D

Where do these come from ??  Like why aren't they all just "C" for example ?
What's the physics and math really orchestrating this (sorry!) ?

In other words, what's the definition of a harmonic.

/Eric
2026.15definition of harmonicFLOYD::YODERMFYFri Feb 09 1996 15:2843
A "harmonic" of a frequency f is any frequency n*f for n a positive integer. 
The "first harmonic" is with n=2, the "second harmonic" is with n=3, etc., which
is a tad unfortunate, but it can be lived with.

Remember that the sequence of Cs are an octave apart, which is a factor of 2; so
if f is the first one, the next Cs are at 2f, 4f, 8f, etc.  (Skipping 3, 5, 6,
7, et al.)

Tones that are an octave apart sound very much alike (a fact of acoustic
psychology known to the ancients), and so are in the same "tone class."  The
tone class C contains all the various C tones, for example.

Thus 3f = 2*(3/2)f is in the same tone class as a tone which is a perfect fifth
up from C, i.e., it is approximately G in an even temperament scale.  It is
exactly G in a Pythagorean scale, but that's another matter...

Similarly, 5f=4*(5/4)f is in the same tone class as a tone a perfect major third
up from C, approximately E.  6f=2(3f) is another G.  9f=8(9/8)f is a case we
haven't considered yet; 9/8 is an exact tone in the Pythagorean scale,
approxmiately 2 even-tempered semitones.  (In other words, you're justified in
being confused, this involves stuff not discussed previously in this note.)

7f is more problematic, but two fifths up from 7f is 7(3/2)(3/2)=63/4, only
63/64 different from exactly 4 octaves.  And B flat is just two fifths down from
C in the circle of fifths.

Scales like the Pythagorean and Darlin scales, which use only rational numbers
for pitch ratios, are easy to construct, but they have the disadvantage that
intervals of a fifth (or any other sort) vary in size depending on where they
start.  (Clearly, only an even temperament scale can avoid this.)  This means
that a piece of music transposed up an interval (other than a multiple of an
octave) can "sound different."  It is also possible to have phenomena like "wolf
fifths" which sound terrible even though all other fifths are consonant
intervals; this generally means you avoid using those particular intervals,
except perhaps for humorous effects.

Just so that there is no confusion: a "perfect fifth" is a pitch ratio of 3/2. 
"A fifth" is, in any normal 12-tone scale, an interval from some tone to the 7th
tone after it; the size of a fifth is only a constant if the scale happens to be
even temperament.  In an even temperament scale, all fifths differ from a
perfect fifth by a bit less than 2 cents.  In a Pythagorean scale, 11 of the
fifths are perfect fifths, and the 12th "wolf fifth" has a large error, between
23 and 24 cents.  The Darlin scale is a more complex situation in this regard.
2026.16HANNAH::OSMANsee HANNAH::IGLOO$:[OSMAN]ERIC.VT240Fri Feb 09 1996 18:176
o.k. I get most of what you were saying.  If C is first harmonic, second
is C*2 which is next C, third is C*3 which is C*3/2*2 so is octave above
C*3/2 so is octave above G above original C.

/Eric