the mathematics of music - stem2 · we shall explore some of the mathematics of music here. ... the...
TRANSCRIPT
The Mathematics of Music
James D Emery
Latest Edit: 7/25/2015
Contents
1 Introduction 2
2 Sound Waves 3
3 Logarithms 3
3.1 The Exponential Function and the Natural Logarithm . . . . . 43.2 The Logarithm to the Base b . . . . . . . . . . . . . . . . . . 8
4 Equal Temperament 9
5 Notation 10
6 Scales 11
7 Intervals 11
8 Trigonometry 11
9 Fourier Series 12
10 Sound 12
11 Harmonics 12
12 Pitch 12
13 Chords 12
1
14 Attack and Duration 12
15 Rhythm and Time 13
16 Vibrating Strings 13
17 Pipes: Vibrating Air Columns 13
18 Musical Instruments 13
19 The Piano Keyboard 13
20 Bessel Functions 13
21 Piezoelectricity 14
22 The Oscilloscope 14
23 The Spectrum Analyzer 14
24 Digital Signal Processing 14
25 The Fast Fourier Transform 15
26 Jokes 16
27 Bibliography 17
28 Appendix A: Piano Keys and Frequencies 18
29 Appendix B: Program freqint.ftn: Musical Notes and Fre-
quencies 21
30 Appendix C: Musical Terms 24
1 Introduction
Mathematics and Music have much similarity because they are both inher-ently very beautiful, and further the graphical notation for Music, and Mathe-matics, are both aesthetically pleasing. Writing musical notation and writing
2
Mathematical notation is often found by many to be quite artistically sen-sual in itself, independent of explicit meaning. It is said that mathematiciansoften have great interest and appreciation of Music. This may be true, butI am not absolutely sure of this.
We shall explore some of the mathematics of Music here. The bibliogra-phy contains several references for the Mathematics and Physics of Music,should the reader choose to explore the subject further.
2 Sound Waves
Sound waves are longitudinal waves, with the pressure oscillating in the prop-agation direction.
3 Logarithms
Music involves logarithms in a couple of different ways. The relationshipbetween notes is logarithmic, and human hearing has a logarithmic response.So let us review logarithms.
The logarithm of a product is the sum of the logarithms
log(ab) = log(a) + log(b).
The logarithm of a/b is the difference of the logarithms.
log(a/b) = log(a) − log(b).
In music we are interested in the ratio of frequencies. The octave doublesa base frequency. Thus if A = 440 cycles per second, that is 440 Hertz(abbreviated as Hz), then the octave is 880 Hz. The ratio is
880/440 = 2.
Taking the logarithm we have
log(880/440) = log(880) − log(440).
We have converted a ratio to a difference.
3
Let us take the logarithm to the base 2, written as log2. By definition ify = log2(x) then in words the logarithm of x to the base 2, is the power that2 must be raised to produce x. That is
x = 2y.
For example, if x = 512 then y = log2(x) = 9, because
29 = 512.
Suppose we have a frequency f and an octave frequency 2f , then
log2(2f/f) = log2(2) = 1,
because 21 = 2. So the difference between the octave frequency and the basefrequency is 1, when expressed using log2. A change in frequency is calledan interval. But for a smaller change in frequency we will get a number lessthan 1. So we shall multiply by 100 to get larger numbers. Thus we definethe interval difference between two frequencies f1 and f2 in cents using thedefinition
100 log2(f2/f1).
It follows that the interval between a frequency and its octave is 100 cents.In the next section we show that
log2(x) =ln(x)
ln(2)=
ln(x)
.69314718,
where ln(x) is the natural logarithm of x.
3.1 The Exponential Function and the Natural Loga-
rithm
We define the exponential function as the power series
exp(x) = 1 + x +x2
2!+
x3
3!+ ....
Differentiating the series term by term we have
d(exp(x)
dx= 0 + 1 + x +
x2
2!+
x3
3!+ ... = exp(x).
4
So a fundamental property of the exponential function is that it equals itsown derivative. This is a very natural property, and the reason that theinverse function ln(x) is called the natural logarithm.
The exponential function has the property
exp(a + b) = exp(a) exp(b).
This follows by finding the product of power series.
exp(a) exp(b) = (1 + a +a2
2!+ ..)(1 + b +
b2
2!+ ..) =
=∞∑
k=0
ck,
where
ck =a0bk
k!+
a1bk−1
1!(k − 1)!+
a2bk−2
2!(k − 2)!+ .. +
akb0
k!
=1
k!(c(k, 0)a0bk + c(k, 1)a1bk−1 + .. + c(k, k)akb0),
=(a + b)k
k!.
We have used here the binomial theorem, and the binomial coefficients
c(k, j) =k!
j!(k − j)!.
We have shown that
exp(a + b) = exp(a) exp(b).
We define a number e by
e = exp(1).
One can prove that e is an irrational and transcendental number.We have
em = exp(1)m =m∏
i=1
exp(1) = exp(m).
Alsoexp(1/n)n = exp(1) = e.
5
Thuse1/n = exp(1/n).
Thus for any rational number r
er = exp(r).
If x is irrational, then ex is not yet defined. However, if ex is to be a continuousfunction we must define, for all real x
ex = exp(x).
From the power series definition of exp(x), we see that it is a monotoneincreasing function, so it has an inverse. Define the natural logarithm as theinverse of the exponential function
ln(x) = exp−1(x).
Since exp(0) = 1, we have ln(1) = 0, and since exp(1) = e, we have ln(e) = 1.If ln(x1) = y1 and ln(x2) = y2, then x1 = ey1 and x2 = ey2 Then
x1x2 = ey1+y2,
henceln(x1x2) = y1 + y2 = ln(x1) + ln(x2).
Similarly, if r is a rational number, then
ln(xr) = r ln(x).
Thenxr = exp(r ln(x)).
If a is an irrational number, we define
xa = exp(a ln(x)).
Notice that iff(x) = ax = exp(x ln(a)),
thenf ′(x) = exp(x ln(a)) ln(a) = f(x) ln(a).
6
Hence for any real number a,
ln(xa) = a ln(x).
Letting y = ln(x), We have
d(ln(x))
dx= 1/
d(exp(y))
dy= 1/ exp(ln(x)) = 1/x.
Now given a real number a, we define the power function
ax = exp(ln(ax)) = exp(x ln(a)).
The logarithm to base a is the inverse of the power function. We write
loga(x) = y,
wheny = ax.
Example We shall show that
limn→∞
(1 + 1/n)n = e.
By taking the logarithm we have
limn→∞
ln((1 + 1/n)n)) = limn→∞
ln(1 + 1/n)
1/n
Let x = 1/n . We shall use the mean value theorem. The numerator andthe denominator each go to zero, so we may replace the numerator and thedenominator by their derivatives (L’Hospital’s Rule).
limx→0
ln(1 + x)
x
= limx→0
1/(1 + x))
1= 1.
Solim
n→∞
ln((1 + 1/n)n) = 1.
Thereforelim
n→∞
(1 + 1/n)n = e.
7
3.2 The Logarithm to the Base b
Given a positive real number b, we define the logarithm y = logb x of x tothe base b, by
x = by.
So we have
ln(x) = y ln(b) = logbx ln(b).
Therefore the logarithm to the base b may be defined in terms of the naturallogarithm as
logb x =ln(x)
ln(b).
So logb(x) has the same properties as ln(x), such as
logb(x1x2) = logb(x1) + logb(x2)
andlogb(x
a) = a logb(x).
Common logarithms use base b = 10. We have approximately
ln(10) = 2.30258509.
So we have approximately
log10(x) =ln(x)
2.30258509,
and less approximately,
log10(x) =ln(x)
2.30.
Similarly
log2 x =ln(x)
ln(2)≈
ln(x)
.69314718.
Now consider the relation between logb x and logc x, for two different basesb and c. Notice that logb x ln(b) and logb x ln(b) are equal, because they areboth equal to ln(x). Therefore
logb(x) =logc(x) ln(c)
ln(b).
8
=logc(x)
ln(b)/ ln(c)
=logc(x)
logc(b).
4 Equal Temperament
The octave is divided into 12 notes and intervals, with successive frequencyratios all equal, say to a number α. The notes in the octave are the twelvenotes with frequencies f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, and f11. Now f12 =2f0. And for each k,fk+1/fk = α. Thus
f12/f0 = (f1/f0)(f2/f1)...(f12/f11) = α12
2f0/f0 = 2 = α12,
soα = 21/12.
So the frequencies are related to a fundamental frequency such as A4 withfrequency 440 Hz, by a formula
f(n) = αn−49× 440 = 2(n−49)/12
× 440,
where n is the key number on the piano. A is the 49th key on the piano. Wecan solve this for n, given the frequency f .
n = 12 log2(f/440) + 49
Thus middle C with frequency 261.63 gives
n = 12 ln(261.63/440)/ln(2) + 49 = 40,
and middle C is the 40th key.The frequency ratio 3/2 is supposed to be especially pleasing. Because
the frequency of a vibrating string is inversely proportional to its length, astring that has been shortened to 2/3 of its length, will have frequency equalto 3/2 of the frequency of the original string length. In the C major scalewith notes C,D,E,F,G,A,B of the equal tempered scale we have the ratio ofthe frequency of the fifth note G to the first note C is
332/261.63 = 1.498,
9
which is very close to 3/2. This is seven semitones. Indeed we have
α7 = 1.498307076876682 ≈ 3/2.
This is called a perfect fifth in the C major scale, C up to G, being five keys.On a stringed instrument reducing a string length by 1/3 producs a fifth,because the reciprocal of 3/2 is 2/3.
Similarly,α5 = 1.334839854170034 ≈ 4/3
gives a perfect fourth, C to F is four keys in the C major scale, which isproduced by shortening a string by 1/4.
Powers of α = 21/12
α1 = 1.059463094359295
α2 = 1.122462048309373
α3 = 1.259921049894873
α4 = 1.259921049894873
α5 = 1.334839854170034
α6 = 1.414213562373095
α7 = 1.498307076876682
α8 = 1.587401051968200
α9 = 1.681792830507429
5 Notation
See a beginning music theory book, such as the book by Henry in the bibliog-raphy, for information on the staff (grid of five lines), the treble clef, the bassclef, and the notation representing notes, such as whole notes, half notes,quarter notes etc.
I may construct a computer program to display the staff and the clefs. Imight draw the clefs with a program producing a Postscript graphic usingeither Bezier or B-spline curves.
10
6 Scales
Each octave is divided into 12 semitones. A scale such as the C major scaleconsists of a subset of these frequencies. The C major scale consists of thewhite keys on the piano, with C the tonic (first key) The major scale has thepattern WWHWWWH, the W standing for a whole step and the H standingfor a half step (semitone).
The A minor scale consists of the white keys on the piano starting withA as the tonic. The minor scale has the pattern WHWWHWW.
If we start anywhere on the piano, that is at any piano key X, we canstill form the pattern WWHWWWH, and produce a major scale. However,in the general case, the keys needed will not necessarily be just the whitekeys, some of the piano keys may be the black keys. So in this case we wouldbe playing in the key of X major, for some key we call X. Similarly, if wehave the pattern WHWWHWW, and again we would use both white andblack keys. We would be playing in the key of X minor. Equal temperamenttuning allows this to be done, since the frequency ratio between successivekeys will always be equal. This will not happen in the JUST temperamentsystem of tuning.
7 Intervals
An interval is a distance between frequencies, or a ratio of frequencies.
8 Trigonometry
The fundamental functions in trigonometry are the sine function and thecosine function. Fourier series is an infinite series of sine and cosine terms ofthe form
an cos(nω)
andbn sin(nω),
where ω is the angular fundamental frequency, and nω is the nth harmonicfrequency.
11
9 Fourier Series
If a musical instrument plays a note in fundamental frequency ω, then thequality of the sound or timbre, is characteristic of the particular instrument.That is a flute sounds differently than a piano. This depends on the quantityof each harmonic. A tone consisting say of just the first harmonic is a verypure tone, perhaps coming from an electronic keyboard. And of course itdoes not sound very great, because the absence of the higher harmonics,allows it to have little character or quality.
See the bibliography and the documents fourier.pdf and fouran.pdf.
10 Sound
See a beginning university Physics book.
11 Harmonics
Harmonics concerns the intervals between notes, such as the octave, thefourth, the fifth and so on. Harmonic analysis concerns Fourier Series, andtransforms and related material such as Haar Measure.
12 Pitch
Pitch is frequency.
13 Chords
Chords are sets of three or more keys played together to obtain harmonicsounds.
14 Attack and Duration
As a note is played on a musical instrument it has a time duration and astarting form known as the attack.
12
15 Rhythm and Time
dot diddy dot diddy dot diddy .......
16 Vibrating Strings
See books on vibration theory and partial differential equations, and mydocuments Vibration, Damped Harmonic Vibration, and Harmonic
Mechanical Vibration
17 Pipes: Vibrating Air Columns
See an elementary Physics book, or for an advanced treatment a book onmathematical acoustics.
18 Musical Instruments
19 The Piano Keyboard
The standard piano has 88 keys, this includes seven complete octaves, theseare called the 1st, 2nd, 3rd, 4th, 5th, 6th, and 7th, octaves. The startingnotes of these octaves are C1, C2, C3, C4, C5, C6, C7. Middle C is C4, withfrequency 261.63 Hz. There is a partial octave at the beginning of the key-board, consisting of the 3 keys A0, A0#, and B0, and there is a partial octaveat the end of the keyboard consisting of the single key C8. Thus there are3 + 7 × 12 + 1 = 88 keys. Key A4 = 440Hz is the 49th key of the piano.
I might create a computer program to display any portion of the pianokeyboard and display chords by the colored keys struck down.
20 Bessel Functions
The vibration of a flat plate, or of a drum involves Bessel functions. Besselfunctions arise from Bessel’s differential equation. They also arise in theX-ray diffraction pattern from crystalized DNA, and played a roll in thediscovery of the structure of DNA.
13
21 Piezoelectricity
Piezoelectricity arises from pressure applied to certain crystals, and inverselymoves when electricity is applied to piezoelectric material. It can both gen-erate and sense sound waves and ultrasound waves. Thus it has much appli-cation and affect in music.
22 The Oscilloscope
The oscilloscope displays wave shapes on a cathode ray tube, a tube like thepicture tube on a television set. An oscilloscope usually employs electrostaticdeflection of the electron beam, using charged plates, so that the voltagesand resulting electric field deflect the beam, and make the image ray trace,produce a curve on the screen.
A television traditionally used magnetic deflection of the beam controlledby coils of wire mounted on the tube.
23 The Spectrum Analyzer
A spectrum analyzer computes the amplitudes of the various harmonics mak-ing up a sampled signal. So for example can determine the character of agiven musical instrument. Once these harmonic amplitudes are known theycan be regenerated electronically with oscillators, to produce synthesizedsounds reproducing more or less the sound of an instrument, or even a hu-man voice.
24 Digital Signal Processing
Looking at the image of a sound produced by an instrument, we see that thesewave shapes are quite complicated and require determining many harmonics.There is much computation needed for this. The signals are sampled atdiscrete intervals, and so are processed by computers. If the sampling issufficiently dense, essentially all of the practical content of the wave shape canbe captured. Although the fourier series has in general an infinite number ofterms, and an infinite number of harmonics, we can only hear a small number
14
of them with our imperfect ears, so only a finite number of the harmonicsneed to be determined.
25 The Fast Fourier Transform
The Fast Fourier Transform is an algorithm the does a very fast calculation ofthe finite Fourier Transform, which makes the calculation practical for manyapplications for very large data sets. Otherwise the calculation would notbe useful for most common applications, such as, for example, Digital SignalProcessing, the determination of molecular structure from X-Ray crystallog-raphy, and the computation of 3d models using CAT scans (Computer AidedTomography), and doing a harmonic analysis of signals such as in analyzingthe timbre of musical instruments.
15
26 Jokes
[1] What do you call twenty violinists playing the Blues? A senseless act ofviolins.
[2] The phone is Baroque, please call Bach later! I wonder when I should callagain? He is probably not himself right now, but I think he will be Bach ina minuet to fix it.
[3] What do you get when you drop a piano down a mine shaft? A flat miner.
[4] What do you call someone who hangs around with musicians? A drummer.
[5] What is the difference between a fiddle and a violin? The fiddle has”strangs.”
[6] Did you hear about the bass player who was so depressed about his poortiming he threw himself behind a train?
[7] Why was Prince Esterazy often unable to find his court musician? Hewas Haydn.
16
27 Bibliography
[1] Culver Charles A., Musical Acoustics, MacGraw-Hill, 1956.
[2] Emery James D., Fourier Analysis, fouran.tex, stem2.org/je/fouran.pdf
[3] Emery James D., Joseph Fourier, stem2.org/je/fourier.pdf
[4] Emery James D., Quick Calculus, stem2.org/je/calcq.pdf
[5] Fischer J. Cree, Piano Tuning, Dover 1975, (Reprint of 1907 Edition).
[6] Halliday David, Resnick Robert, Physics, John Wiley and Sons, 1966.
[7] Helmholtz Hermann Ludwig Ferdinand von, On the Sensation of Tone,Dover, 1954, (republication of the Ellis translation of 1885, of Die Lehre vondem Tonemphfindungen.) New Introduction by Henry Margenau.
[8] Henry Earl, Fundamentals of Music, Prentice Hall, 1988.
[9] Jeans James Sir, Science and Music, Dover, 1968, (Original Publicationby Cambridge University Press, 1937).
[10] Lindsay R. Bruce (editor), Physical Acoustics: Benchmark Papers
in Acoustics, Dowden, Hutchingson and Ross, Inc., 1974.
[11] Machlis Joseph, The Enjoyment of Music, W. W. Norton, 1967.
[12] Machlis Joseph, Forney Kristine, The Enjoyment of Music, 8th Edi-tion, 1999, W. W. Norton.
[13] Mason Warren P., (editor), Physical Acoustics: Principles and
Methods, Volume 1-Part A, 1964, Academic Press.
[14] Morgan Joseph, The Physical Basis of Musical Sounds, Robert E.Krieger Publishing Company, 1980.
17
[15] Olson Harry F., Music, Physics, and Engineering, 2nd Edition,Dover, 1967.
[16] Siegmeister Elie, Harmony and Melody, Two Volumes, 1966, Wadsworth.
[17] Suits B. H., Notes: Physics of Music, Frequencies for equal-
tempered scale, www.phy.mtu.edu/suits/notefreqs.html, Michigan Tech-nological University.
[18] Winckel Fritz, (Translated from the German by Thomas Binkley), Mu-
sic, Sound, and Sensation: A Modern Exposition , Dover, 1967
[19] Wikipedia, Piano Key Frequencies,https://en.wikipedia.org/wiki/Piano key frequencies
[20] Wood Alexander, (Revision Bowsher J. M.), The Physics of Music,Sixth Edition, University Paperbacks, Methuen and Company, London, 1961.
28 Appendix A: Piano Keys and Frequencies
The 88 piano keys and their frequencies:
88 piano keys:
1 A0 27.500000000000
2 A#0 29.135235094881
3 B0 30.867706328508
4 C1 32.703195662575
5 C#1 34.647828872109
6 D1 36.708095989676
7 D#1 38.890872965260
8 E1 41.203444614109
9 F1 43.653528929125
10 F#1 46.249302838954
11 G1 48.999429497719
12 G#1 51.913087197493
13 A1 55.000000000000
14 A#1 58.270470189761
15 B1 61.735412657015
16 C2 65.406391325149
17 C#2 69.295657744218
18 D2 73.416191979352
19 D#2 77.781745930520
20 E2 82.406889228217
21 F2 87.307057858251
18
22 F#2 92.498605677908
23 G2 97.998858995437
24 G#2 103.82617439499
25 A2 110.00000000000
26 A#2 116.54094037952
27 B2 123.47082531403
28 C3 130.81278265030
29 C#3 138.59131548844
30 D3 146.83238395870
31 D#3 155.56349186104
32 E3 164.81377845643
33 F3 174.61411571650
34 F#3 184.99721135582
35 G3 195.99771799087
36 G#3 207.65234878997
37 A3 220.00000000000
38 A#3 233.08188075904
39 B3 246.94165062806
40 C4 261.62556530060
41 C#4 277.18263097687
42 D4 293.66476791741
43 D#4 311.12698372208
44 E4 329.62755691287
45 F4 349.22823143300
46 F#4 369.99442271163
47 G4 391.99543598175
48 G#4 415.30469757995
49 A4 440.00000000000
50 A#4 466.16376151809
51 B4 493.88330125612
52 C5 523.25113060120
53 C#5 554.36526195374
54 D5 587.32953583482
55 D#5 622.25396744416
56 E5 659.25511382574
57 F5 698.45646286601
58 F#5 739.98884542327
59 G5 783.99087196350
60 G#5 830.60939515989
61 A5 880.00000000000
62 A#5 932.32752303618
63 B5 987.76660251225
64 C6 1046.5022612024
65 C#6 1108.7305239075
66 D6 1174.6590716696
67 D#6 1244.5079348883
68 E6 1318.5102276515
69 F6 1396.9129257320
70 F#6 1479.9776908465
71 G6 1567.9817439270
72 G#6 1661.2187903198
73 A6 1760.0000000000
74 A#6 1864.6550460724
75 B6 1975.5332050245
76 C7 2093.0045224048
77 C#7 2217.4610478150
78 D7 2349.3181433393
19
79 D#7 2489.0158697766
80 E7 2637.0204553030
81 F7 2793.8258514640
82 F#7 2959.9553816931
83 G7 3135.9634878540
84 G#7 3322.4375806396
85 A7 3520.0000000000
86 A#7 3729.3100921447
87 B7 3951.0664100490
88 C8 4186.0090448096
20
29 Appendix B: Program freqint.ftn: Musi-
cal Notes and Frequencies
c freqint.ftn 7/15/15, musical notes and frequencies
implicit real*8(a-h,o-z)
dimension f(500)
character*4 key(100)
n=100
ndom=2
key(1)=’C0’
key(2)=’C#0’
key(3)=’D0’
key(4)=’D#0’
key(5)=’E0’
key(6)=’F0’
key(7)=’F#0’
key(8)=’G0’
key(9)=’G#0’
key(10)=’A0’
key(11)=’A#0’
key(12)=’B0’
key(13)=’C1’
key(14)=’C#1’
key(15)=’D1’
key(16)=’D#1’
key(17)=’E1’
key(18)=’F1’
key(19)=’F#1’
key(20)=’G1’
key(21)=’G#1’
key(22)=’A1’
key(23)=’A#1’
key(24)=’B1’
key(25)=’C2’
key(26)=’C#2’
key(27)=’D2’
key(28)=’D#2’
key(29)=’E2’
key(30)=’F2’
key(31)=’F#2’
key(32)=’G2’
key(33)=’G#2’
key(34)=’A2’
key(35)=’A#2’
key(36)=’B2’
key(37)=’C3’
key(38)=’C#3’
key(39)=’D3’
key(40)=’D#3’
key(41)=’E3’
key(42)=’F3’
21
key(43)=’F#3’
key(44)=’G3’
key(45)=’G#3’
key(46)=’A3’
key(47)=’A#3’
key(48)=’B3’
key(49)=’C4’
key(50)=’C#4’
key(51)=’D4’
key(52)=’D#4’
key(53)=’E4’
key(54)=’F4’
key(55)=’F#4’
key(56)=’G4’
key(57)=’G#4’
key(58)=’A4’
key(59)=’A#4’
key(60)=’B4’
key(61)=’C5’
key(62)=’C#5’
key(63)=’D5’
key(64)=’D#5’
key(65)=’E5’
key(66)=’F5’
key(67)=’F#5’
key(68)=’G5’
key(69)=’G#5’
key(70)=’A5’
key(71)=’A#5’
key(72)=’B5’
key(73)=’C6’
key(74)=’C#6’
key(75)=’D6’
key(76)=’D#6’
key(77)=’E6’
key(78)=’F6’
key(79)=’F#6’
key(80)=’G6’
key(81)=’G#6’
key(82)=’A6’
key(83)=’A#6’
key(84)=’B6’
key(85)=’C7’
key(86)=’C#7’
key(87)=’D7’
key(88)=’D#7’
key(89)=’E7’
key(90)=’F7’
key(91)=’F#7’
key(92)=’G7’
key(93)=’G#7’
key(94)=’A7’
22
key(95)=’A#7’
key(96)=’B7’
key(97)=’C8’
c do i=1,60
c lc=lenstr(key(i))
c write(*,’(1x,a)’)key(i)(1:lc)//’0’
c write(*,’(1x,a)’)key(i)
c enddo
c do i=1,13
c write(*,’(1x,i5,1x, 3(1x,g15.8))’)i,f(i),f(i+1)/f(i),f(i+1)-f(i)
c end do
f(58)=440.
a=2.d0**(1./12.d0)
write(*,*)’ a = ’,a
write(*,*)’ a^12 = ’,a**12
write(*,*)’ fifth, alpha^7 = ’, a**7
write(*,*)’ ln=’,log(exp(5.d0))
write(*,*)12*log(261.63/440)/log(2.d0)+49
write(*,*)’ powers of alpha’
do i=1,9
write(*,*) i, a**i
end do
write(*,*)
c do k=1,88
write(*,*)’ 88 piano keys: ’
do k=10,97
f(k)=f(58)*a**(k-58)
j=k-9
write(*,’(1x,i4,1x,a,1x,g21.14)’)j,key(k),f(k)
end do
one=1.
zero=0.
pi=4.*atan(one)
nfile1=1
c open(nfile1,file=’q.txt’,status=’unknown’)
nfile2=2
open(nfile2,file=’q.eg’,status=’unknown’)
end
c
c+ lenstr nonblank length of string
function lenstr(s)
c length of the substring of s obtained by deleting all
c trailing blanks from s. thus the length of a string
c containing only blanks will be 0.
character s*(*)
lenstr=0
n=len(s)
do 10 i=n,1,-1
if(s(i:i) .ne. ’ ’)then
lenstr=i
return
endif
10 continue
return
23