Artful Computing

Play a musical note on a piano. Play the same note on a violin, or a guitar. They will have the same pitch - but sound quite different to the ear. Few people will confuse tune played on the guitar with one played on the piano. 

 In both cases the string is fundamentally vibrating at the same frequency, but the sound also contains multiple overtones. These are oscillations at two, three, four, five times the fundamental frequency and so on. It is the different proportions in which these overtones occur that contribute part of the unique quality of each type of musical instrument. (Some of that quality also comes from the way the note builds up and dies away, and other subtle contributions - I am knowingly simplifying for the sake of getting the main point across.) These overtones are also known as harmonics. The pressure variations associated with a pure musical tone (a single harmonic) is a wave that can be described very well by a sine or cosine function (they really do keep turning up all over the place). The ancient Greeks knew about harmonics and the relationship of notes to the lengths of vibrating string. They were also trying to explain the motions of heavenly bodies using circular motions. At first, they would have liked to have believed that all the planets had to move in perfect circles about the Earth. This, however, was disconcertingly inconsistent with what they actually saw when they looked closely at the planet. (Mars, for example, makes rather complex motions on the sky, sometimes appearing to go backwards.)

Ptolemy's solution was to use epicycles, super-positions of circular motions, based on multiples of the fundamental rotational frequency of the planet. He still had circular motions of a sort, but could fit the actual motions of the planets as closely as required by adding more and more higher frequency cycles. He had to use trial and error to get things to work. (Try to produce a predefined curve with our epicycle program - it is not easy.) You can, however, get pretty much any closed curve you like with the right choices - even, perhaps, square orbits! I happen know the maths that allows me to calculate the correct harmonic contributions - no trial and error required - so let's demonstrate that. Try running this program (i.e. download and paste into Processing) which animates a set of epicycles that get fairly close to a square orbit. The final result is shown on the right. (This required 11 epicycles. More would add sharpness to the corners of the square.)

We now jump to France, and a mathematician called Joseph Fourier. He devised a mathematical method, that given the initial shape into which a vibrating string was plucked, would calculate the amplitude of each harmonic. Any wave, according to Fourier, of any shape, could be represented by the sum of sines and cosines with frequencies of variation that were multiples of a fundamental frequency. It was a broad claim and he had not quite proved it, but it turned out that he was pretty much right, though it took most the rest of the 19th century for mathematicians to fully understand why, and in particular how you could produce curves with sharp corners by adding up smooth waves. (His contemporaries found this very difficult to swallow at first and of course did not have computers to do the type of demonstration you can see below.) His calculation is now knows as a Fourier Series.

A Saw-tooth wave generated by adding sine waves of increasing frequency together.

Electric organs and pianos are a consequence of Fourier's mathematics, because they build their sounds by generating each of the harmonics in the right proportions and adding them together before feeding a loudspeaker. The diagram above shows a "saw-tooth" wave form which turns into a sound that has some similarities with a trumpet note, and all the individual wave that contributed - all 200 harmonics in all. (You can animate the addition of these series by downloading this program and playing it in Processing.) All the electric organ needs to do to switch to an oboe sound (or indeed an organ sound) is change the proportions of the individual waves. (As it happens, the above saw-tooth needed only sine wave. In general you also need some cosine waves as well.) This is called a Fourier series. We now explain why Ptolemy's epicycles can match the motions of planets following elliptical orbits and even why you could build a representation from superimposed epicycles even if the planets had to move on square orbits!

In fact, Fourier's mathematics also helped me when I did my radio astronomy PhD. Our radio telescopes did not directly make images of the sky. No eyepiece! (which often confused visitors to the telescopes). Instead, we could measure Fourier components of the radio brightness distribution on the sky. We could then build an image in a computer using a Fourier series. (You will not be tested on this until you do maths at university. It is complicated. It was sufficiently clever that Sir Martin Ryle, who lead the Radio Astronomy Research Group at the Cavendish while I was there, got the Nobel Prize for bringing to a high degree of practical usability a technique that subsequently opened the way to many major discoveries. It is still extremely important in astronomy.)

Fourier's ideas had an enormous impact on the development of mathematics in the 19th century. They are also of huge importance in may practical applications (including all sorts of electronics and signal processing). HiFi systems need to be able to handle high frequencies even though most musical notes have relatively low frequencies because the characteristic sound of instruments often comes from the sharp edges in their wave forms, and as the saw-tooth shows, we need high harmonics to reproduce these accurately. These ideas also explains why knowing a bit about sines and cosines and all that helps us to make Processing images of arbitrary complexity, and it also explains why my first explorations in generative art are based around sines and cosines.

Breadcrumbs