2. Complex Vibrations

Adding Sine Waves of differing amplitudes, phases and frequencies

In the last virtual lab exercise, we looked at simple sine waves and investigated how the position v. time graph was affected by differing values for amplitude, frequency and phase.  We also heard the sounds of single sine waves using the "Play" function.

The vibrating objects that produce sound waves typically vibrate in a manner that is more complex than the SHM model predicts,  because most vibrations are a combination of the vibrations of many different Simple Harmonic Motions all mixed up together.  Think of steadily moving your right arm up and down once every second while at the same time wiggling your right index finger up and down steadily five times each second.  The resulting motion of your right index finger is a complex oscillation involving the two frequencies, 1 Hz and 5 Hz.

The waveform that results from the superposition of vibrations of various frequencies may itself be a periodic waveform, or not, depending on the numerical relationship between all the constituent frequencies in the mixture.

In this virtual lab exercise, we will look at the position vs. time relationships of complex vibrations that involve several frequencies at once, and listen to the soundwaves that result from these steady vibrations.

Instructions:  This Notebook is a tutorial in using various parts of Mathematica.  You should work through the examples in this notebook and then download the accompanying Mathematica notebook that contains a set of Homework exercises that you should complete and submit as homework.  You don't need to submit this notebook, but you do need to submit the accompanying one.

A: Complex Tones:  Introduction to Superposition

In the last exercise, we looked at the vibrations of a Simple Harmonic oscillator, for which the position vs. time is characterized by a simple sine wave,  y = ASin[2πft + ϕ],  and we learned how this motion is affected by changing the amplitude, frequency and phase in the expression  for y.   More complicated vibrations include more that just one frequency, and the position vs. time  relationship may be written as y = (Subscript[A, 1])Sin[2π(Subscript[f, 1])t + (Subscript[ϕ, 1])] + (Subscript[A, 2])Sin[2π(Subscript[f, 2])t + (Subscript[ϕ, 2])] + (Subscript[A, 3])Sin[2π(Subscript[f, 3])t + (Subscript[ϕ, 3])] + (Subscript[A, 4])Sin[2π(Subscript[f, 4])t + (Subscript[ϕ, 4])] + ...... , in compact notation, y=(∑_(n = 1)^N)(Subscript[A, n])Sin[2π(Subscript[f, n])t + (Subscript[ϕ, n])].  There can be many frequency components to the motion. Each frequency component, (Subscript[f, n]), has  its own amplitude, (Subscript[A, n]), and phase, (Subscript[ϕ, n]) .   The nature of the resulting waveform depends on the relationship between each of these frequencies, and on the amplitude and phase of each frequency component.

1. Adding Two Waves Together:  Periodic Waveforms

Sounds get more interesting when more than one note is played at the same time.  Here I'll define two frequencies, C4 and F4. (These two frequencies are notes in equally-tempered musical scale,  C4 is middle-C and F4 is the F in the  octave above middle-C..)

C4  =  261.1

The following Play[] function plays a simple sine wave at frequency C4 for one second of time.

Play[Sin[2  π C4 t], {t, 0, 1}]

F4  =  349.2

... and this Play[] function plays a simple sine wave at frequency F4 for one second.

Play[Sin[2  π F4 t], {t, 0, 1}]

Now listen to the sound of these two waveforms added together.  Does this sound seem to have a higher, or lower pitch than the single C4?

Play[Sin[2  π C4 t] + Sin[2  π F4 t], {t, 0, 1}]

Here is a plot of a few periods of the C4 single sine wave.  (Period = 1/C4 = 0.00383 sec)

C4Plot =  Plot[1 Sin[2  π C4 t], {t, 0,  .012}]

Here is a plot of a few periods of the F4 single sine wave.  (Period = 1/F4 = 0.00286 sec)

F4Plot = Plot[1 Sin[2  π F4 t], {t, 0,  .012}]

When the two sine waves are plotted side by side, you can see that they go in and out of phase with each other.  It takes 4 cycles of the F4 (equivalently 3 cycles of the C4) for the two sine waves to match up again.

Plot[{1 Sin[2 π C4 t], 1 Sin[2 π F4 t]}, {t, 0, 
        0.012}]

When the two sine waves added together, the result is a complex periodic waveform

Plot[
      1 Sin[2  π C4 t] + 1 Sin[2  π F4 t], {t, 
        0,  .043}]

The waveform of this sound is still periodic, but more complex than a simple sine wave.  It sounds different than a pure tone does also.  In fact the period of the combination tone, is longer that the period of either one of the pure tones that make it up.   There is actually no guarantee that two pure sine waves will combine to form a periodic complex wave, but in the cases where the ratio of the frequencies is a simple fraction, then the resulting complex tone is periodic as well.  Here,  C4/F4 = 3/4, so 3 cycles of the C4 happen in exactly the same time as 4 cycles of the F4 and then the whole thing repeats again.  The period of the combination tone is 3 periods of the C4 (or, equivalently,  4 periods of F4).  The frequency of the combination tone here is C4/3=F4/4 = 87 Hz.    This is the frequency of the note F2, two octaves below the F4.

2. Adding Two Waves Together:   Nonperiodic Waveforms

Let's repeat the exercise of A.1, except for different frequencies.  Here the ratio of the frequencies is not a ratio of small integers.  In fact the ratio of the two frequencies is (Sqrt[2]),  which is an irrational number. The resulting combined waveform is not periodic.

f1  =  220

f2 =  220 √2

Here is a plot of a few periods of the single sine wave of frequency f1.

Plot[1 Sin[2  π f1 t], {t, 0,  .02}]

...and here is a plot of a few periods of the single sine wave of frequency f2.

Plot[1 Sin[2  π f2 t], {t, 0,  .02}]

When the two sine waves are plotted side by side, the two waves go approximately in and out of phase with each other but never exactly match up again.

Plot[{1 Sin[2 π f1 t], 1 Sin[2 π f2 t]}, {t, 0, 
        0.05}]

When the two sine waves added together, the result is a complex waveform that is not periodic.

Plot[
      1 Sin[2  π f1 t] + 1 Sin[2  π f2 t], {t, 
        0,  .15}]

Here is what the combination of frequencies f1 and f2 sounds like.

Play[Sin[2  π f1 t] + Sin[2  π f2 t], {t, 0, 1}]

3.  Adding Many Waves together:  The Harmonic Series

In this section, we will show you how to use Mathematica Lists to create complex waveforms.  

Below is a plot of a complex waveform based on harmonic series with fundamental frequency of 440 Hz.  The syntax for creating this plot should now be familiar to you, from previous work.   All the components of the wave are added togther in the Plot[] command.

Plot [ 
      Sin[440 2 π t] + 0.25 Sin[880 2  π t] + 
        0.333 Sin[1320 2  π t] + 0.5 Sin[1760 2  π t] + 
        0.167 Sin[2200 2 π t], {t, 0, 3.1/440}]

Using Mathematica Lists, it is possible to create complex waveforms and sounds in a more compact way.  The next sections show how to do this.

The syntax of  Mathematica lists and how to use them

A Mathematica list is a set of objects separated by commas and surrounded by curly braces.  In the example below, two lists, list1 and list2, are defined.  (I am assuming that you haven't set any definitions for the letters a, b, c, d, e, or f in this notebook.)

list1 = {a, b, c}

list2 = {d, e, f}

You can find the values of any element in a list by writing the number of the element you want inside double square brackets.  

For example:

list1[[1]]

list1[[2]]

list1[[3]]

Any lists of equal length can be multiplied together. Our lists, list1 and list2, each have a length of 3, so they can be multiplied

list1 list2

The result is a new list containing the successive products of each of the two elements in each successive position of the two lists that were multiplied together

Now look what happens when you put a dot (period) between the two lists of equal length.

list1 . list2

This is a new kind of multiplication of lists. The "." tells Mathematica to multiply the two lists in the ordinary way, as seen in the first example of multiplication, but then to take all the elements of the resulting list and add them all together.

Using lists to build complex tones

Here is a list of 5 frequencies in a harmonic series (a set of multiples of the lowest frequency in the series) based on the fundamental frequency of 440 Hertz.

f = {440,  880, 1320,  1760,  2200}

See what happens when you evaluate the following expression in Mathematica.

Sin[2  π f t]

Evaluate the next cell to find out what each of these tones sound like separately.  This next expression uses the Mathematica function, Table, to write out successive objects in a list.  You can learn how to use Table by looking at your Menu (Help->Help Browser....) then look up Table.

Table[
      Play[Sin[2  π f[[n]] t], {t, 0,  .25}], {n, 1, 5}]

Here is a list of Amplitudes

A = {1. ,  .25,  .333333,   .5,  
        1. /6. }

If you evaluate .....

A Sin[2  π f t]

...you get a list of Sine waves.  With one little period, placed in the right spot, I can instruct Mathematica to add up all these sine waves together.   See the difference between the last command and the next one?

A  . Sin[2  π f t]

Let's see what  waveform of all these added together sine waves looks like when we plot it over several periods of the complex oscillation. This is essentially the same graph that we saw earler in this section.

Plot[A  . Sin[2  π f t], {t, 0,  .005}, 
      PlotRange -> {-3, 3}]

Note that the resulting waveform is also periodic (with frequency of 440 Hz, the lowest frequency in the series) and the structure of the wave is more complex than that of a simple sinusoid because of the higher harmonics that are added to the fundamental.

These higher harmonics affect the quality, or timbre of the resulting sound.  The harmonic structure of the sound is what gives different musical instruments their own characteristic sound.  A oboe sounds distinct from a clarinet, which is sounds different than a trumpet, which certainly doesn't sound like a violin because the waveform that is produced by each of these instruments has a harmonic content that is a unique characteristic of that particular instrument.

Oh, here's what the complex waveform you see above sounds like.  The pitch is the same as the lowest frequency of the harmonic series that makes up this sound, but most people will say that this tone sounds brighter than the plain old pure tone at 440 Hertz.

Play[A  . Sin[2  π f t], {t, 0, 2}]

Here's a pure tone at 440 Hertz for comparison.  Can you hear the difference?

Play[Sin[2  π 440 t], {t, 0, 2}]

Effects of phase

In the previous examples in this section, each frequency component had a phase, \(TraditionalForm\`ϕ\_n = 0. \ \ \ In\ \ this\ example, \ 
      we' ll\ \ examine\ how\ different\ phases\ of\ each\ of\ the\ frequency\ components\ affect\ the\ appearance\ of\ the\ waveform, \ 
      and\ also\ the\ timbre\ of\ the\ sound\ of\ this\ \(\(vibration\)\(.\)\)\)

Here's a list of 5 different phases

phase  =  2 π Table[Random[], {5}]

Here's the sound we heard before.  The phase of each frequency component is zero.

Play[A  . Sin[2  π f t], {t, 0, 2}]

Here's a modified sound.  The amplitude and frequency of each component is the same as before, but the phase of each frequency component is given by the corresponding element in the list, phase, defined above.

Play[A  . Sin[2  π f t  +  phase], {t, 0, 2}]

Do these two sounds sound different?