Transcript
Page 1: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 1

Physics 15c: Laboratory 2: Fourier SeriesDue Friday, february 23, 2007, before 12 Noon in front of SC 301

REV 0:1 ; February 15, 2007

“Lab” Hours: not quite the usual lab hours!

This lab can be done on any of the Science Center PC’s, and you can do it completely on your own, if you like. Wehave scheduled some “help lab” hours. These sessions will be held in room SC 226, the PC classroom. As youcome out of the elevators turn almost a U-turn to your left, and 226 is about 2/3 the way down the hall. Since someof you will do the labs on your own time, we haven’t tried to duplicate lab hours fully. At the time of these listed“help labs,” you will find Mark or Kevin on hand to help. During those hours, we have priority (we won’t use theentire room, so we’ll share it, of course).

Pleasenote:

We expect you to arrive with Fourier series equations done or at leastattempted. We do, of course, want you tocome to help labs for help!—but make your own attempt to solve the problems before you arrive. We’re verysympathetic to people who have tried, and find themselves baffled; we’re less sympathetic to a person who showsup and looks at the lab for the first time, asking, ’What do I do?’ We knowyouwouldn’t do that; but some peoplehave done that in past terms.

Help lab hours are as follows:

Pleasenotethat these areNOT your usual lab section times!

• Tuesday, Feb. 20, 3-4 p.m.;

• Wednesday, Feb. 21, 3-4 p.m.;

• Thursday, Feb. 22, 8-9 p.m.

Make sure you read this lab handout and do the calculations before you go to the lab.

1 Introduction

An important property of many types of waves islinearity. For example, two sounds of different frequencies can beplayed at the same time and the resultant sound is simply the addition of the amplitudes of the two original soundwaves. (Your ear does a fast frequency-analysis of the sounds it receives, using tunableresonant structures: theso-called cilia, little hairs in your inner ear.) The fact that the sound is as simple as the addition of the twoamplitudes is a mathematical property of the wave equation. The property holds true for many different wavephenomena (e.g. sound, light, quantum mechanics). (That this should be true may not be obvious at first glance. Infact, in some extreme limits linearity no longer holds true. Fortunately, many interesting phenomena exist in thelinear regime.)

In this lab you will learn about Fourier series. It turns out that any periodic wave can be obtained by adding up theproper series of sine and cosine waves. The proper series depends on the wave. The mechanism for determining

1Revisions: show changed path and procedure for invoking 15c files.

Page 2: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 2

that series is described below. You will add waves together on a computer to verify your determination of theproper series for describing square, triangle and saw-tooth waves. You will be able to listen to your results. Youwill also add some waves to produce various types of “musical” sounds.

2 Theory

A Fourier series is an infinite sum of harmonic functions (sines and cosines) with every term in the series having afrequency which is an integral multiple of some “principal” frequency and an amplitude that varies inversely withits frequency. The usefulness of such series is thatany periodic functionf with periodT can be written as aFourier series in the following way:

f(t) = a0 +∞∑

n=1

ancos nωt +∞∑

n=1

bnsin nωt1

where the coefficients are given by

a0 =1T

∫ T

0f(t) dt (1)

an =2T

∫ T

0f(t) cos nωt dt (2)

bn =2T

∫ T

0f(t) sin nωt dt (3)

andω = 2πT . The formulas for the coefficients can be easily obtained from the followingorthogonality

conditions2:

∫ T

0sin nωt cos mωt dt = 0 (4)

∫ T

0cos nωt cos mωt dt =

T

2δn,m (5)

∫ T

0sin nωt sin mωt dt =

T

2δn,m (6)

(Aside: The above formalism is expressed for a function of time with periodT and frequencyω = 2πT , but these

formulas are equally valid for function of position; one need just replaceT with the spatial period (or wavelength)λ andω with the spatial frequencyk = 2π

λ .)

2The notation, “δn,m,” used below, defines a variable that takes the value zero wheren 6= m and one wheren = m.

Page 3: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 3

2.1 Vectors

We are now going to discuss some formalism of three-dimensional vectors expressed in Cartesian coordinates, forthe purpose of making comparisons to Fourier series. In Cartesian space,any vector can be written as a linearcombination of the mutually perpendicular basis vectorsx, y, z in the following way:

~V = Vxx + Vyy + Vz z,

where the coefficients are given by

Vx = ~V · x, Vy = ~V · y, Vz = ~V · z.

The above expressions for the coefficients can be easily derived from the following perpendicularity (or, moregenerally,orthogonality) relations:

x · y = y · z = z · x = 0,

x · x = y · y = z · z = 1.

It is obvious what all the vector notation stands for: the unit vectors are “elements” that we are combining to makesome general vector~V , and the componentsVi are the “amount” of each “element” we need to add together tomake our final product, the vector~V . The orthogonality conditions simply express that the basis vectorsx, y, andzare linearly independent. Although this section about vectors is elementary and may appear unnecessary, we willsee presently ( and you may have figured it out by now) there are similarities between this vector formalism andthat of the Fourier series.

2.2 Comparison between Vectors and Fourier Series

The two previous sections were written suggestively, to make comparisons between the formalism for the Fourierseries and for vectors. The similarities between the two can provide us with some insight about Fourier series (forthose with knowledge of linear algebra, these similarities arise since we can create inner product sources for boththree-dimensional vectors and for periodic functions of a given period). It should be clear that the harmonicfunctions making up a periodic function are analogous to the unit vectors making up a vector, and the coefficientsan, bn in a Fourier series are analogous to the componentsVi of a vector:

cos, sin↔ x, y, z

an, bn ↔ Vx, Vy, Vz

So, the harmonic functions are the elements that go into making a certain periodic function (they will be the samefor all functions with the same period), and the coefficients are the amount of each harmonic we need to make theparticular function. This way of thinking about Fourier series isextremely powerful and will serve you well ifyou learn it now. So, if you have any doubts that you fully understand the idea, reread the previous section and talkabout it with others until you do understand.

Page 4: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 4

3 Experiment

3.1 Preliminaries

Before doing the experiment in lab, you will need to calculate the Fourier coefficients for several periodicfunctions: a square wave, a triangular wave, and a saw-tooth wave.

NOTEan example in which we have calculated the Fourier components for a given waveform appears as ahand-written appendix to these notes.3

These coefficients are just relative scaling factors. It is useful to characterize functions as “odd” or “even:” evenfunctions are those symmetric about time zero: unchanged by rotation about the f(t) axis; f(-t) = f(t). Odd functionsare inverse about the f(t) axis: f(-t) = -f(t). Even functions will be represented by cosines, odd functions by sines,and some functions are not purely even or odd and thus will need both sine and cosine. By the way, make sureyou’re consistent in your use of units as you evaluate the integrals: use seconds or milliseconds, but don’t wobblebetween the two. You will use these functions throughout the lab. The three waves whose Fourier series we’d likeyou to calculate are shown in the figure just below:

Figure 1: Three Waveforms for you to Synthesize

3.2 Fourier Synthesis on the Computer

In this part of the lab you will “construct” periodic functions (square wave, etc.) by adding harmonic waves of theright frequency and amplitude. You will do this by using a program running on a computer. You will be able tolisten to the resultant wave because the computer you will use is equipped with a chip called a “DAC,” a device that

3Thanks to Anita for doing this. It seemed to me unfair to assume that students could simply teach themselves to go through this process,if they happened not to have seen the technique before.

Page 5: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 5

converts the string of numbers or codes that represent the wave in thedigital domain into a succession of voltagesin theanalogdomain. These voltages can be sent out to speakers or headphones so that your (analog-) ears cansense the waveform that they represent.

The program that you will do this is MATLAB (running another program especially designed for this lab, aprogram named “thelab”). You can access the program through the PC’s networked at the Science Center.

3.3 Starting up Matlab

Go to one of the PC’s in the science center. Log in, using your fas login.

In principle, all you’ll need do is open the Matlab program, and then invoke the program written in Matlab’slanguage for this 15c exercise. A preliminary step is necessary, though, in order to let Matlab know where to findthat program, and the routines that it invokes.

Two steps:

• Preliminary: place the 15c programs in what looks to your computer like an additional drive:

– use the START menu, click on RUN, and enter CMD in the window that appears. This will open acommand window.

– at the cursor, type

net use R: \\Dsssoft10\Courses\Physics15c

(note that there is a space between the colon and the two backslashes)

– type EXIT, closing the command window.

• Start Matlab:

– use the START menu, click on PROGRAMS, then MATH&CHEMISTRY

– ...click on Matlab, then on the Matlab icon within that folder. This will open Matlab.

• Tell Matlab which folder to use:

– click the Current Directory button (if it’s not already selected—that is, brought to front, in the displaywindow);

– click on the button to the right of the smallcurrent directorywindow at top center. This action willopen a “Browse. . . ” window. Scroll down until you see “Physics 15c. . . (R),” the folder that you“mounted” a moment ago.”

– If you click on R, you should see the set of files—mostly “.m” files—that you’re about to invoke. (Ifyou don’t see the ”.m” files then go to the next step anyway and see if it works.)

• in the big window to the right (“Command Window”) type “thelab”

Page 6: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 6

Once the program starts...

You should soon see a couple of windows, one showing Fourier coefficients and frequencies (this we’ll call the“parameter window”), the other showing two plots: one, amplitude versus time, the other amplitude versusfrequency. At startup, you’ll find, a sine at 500Hz and cosine at 4500Hz are entered for you.

The parameter window lets you set the coefficients and frequencies of the sine and cosine waves, and lets you plotand hear the results. To reassure yourself that the program works, try pushing the LISTEN button—butbewarned!—audible amplitude isfixed, despite the seeming volume control! Therefore, to avoid tormenting yourclassmates, use theWindows’ volume controlto minimize your sound output. The volume-control icon, in thescreen’s lower right, looks like a speaker.

Take the amplitude of the 4500Hz cosine to zero, and push the PLOT button, then push LISTEN. You should see asinusoid plotted, and the sound should become less harsh—more flute-like.

As you may have guessed, PLOT sums the sines and cosines, and displays these in bothtime-domain(the upperdisplay) andfrequency-domain(the lower window); sine is red, cosine is blue. The Fourier coefficients, in thelower window again show sine in red, cosine in blue; the blue may be hard to make out, since it coincides with ablack vertical line defining the right edge of the window. You can fix that by setting the maximum frequencyslightly past the highest Fourier component. To do that click on the plot tools icon, a square, top right, and set the Xaxis range to, say 5000Hz rather than the automatic 4500Hz at which you find it.

Finding the Audible Range

The human ear is sensitive to sound only in the frequency range from 20-20,000 Hz. If you listen to loud musicthen your range probably does not go all of the way up to 20,000 Hz but may be as low as 15,000 Hz. Not onlyyour ear but also speakers show finitefrequency response. For example, the speaker in a lap-top computer may notproduce sound efficiently below 400 Hz. In fact, specialsubwooferspeakers are used to reach below 40 Hz. (Thiskind of speaker is found in movie theaters, fancy home stereos—and perhaps in your own gaming setup.)

Determine the range of frequencies audible using your computer. Produce a sine wave with a frequency of 2000 Hzand amplitude of 1. Set all of the other amplitudes to zero4 (To change parameters in the program click on thenumber you want to change and then type it in.)

Find the range of audible frequencies. Write down your procedure and describe anything you find particularlyinteresting.

3.4 Building the Square, Triangle and Sawtooth

For each wave you want to produce (square, triangle, sawtooth), you will enter your coefficients and frequencies inthe appropriate columns. (Note that you can enter fractional amplitudes: “1/7’ ’, for example.) Andnote that youmust enter frequencies in Hertz (cycles per second), not omega (radians per second). Start by entering thecoefficients of the square wave. Note important features of the resultant wave in your notebook. Make a sketch ofthe wave in your notebook. If you have access to a printer then please print your waveform instead of making a

4Here’s a trick that may be useful to you: to set the top frequency displayed, you can st up a dummy frequency component, one withamplitude zero. This is useful to prevent the highest actual component’s bad habit of disappearing into the vertical line that bounds the displaybox on the right. For example, if the highest frequency component you are putting in is at 8kHz, you might put a dummy at 10kHz, so as toleave a gap between the line for the 8kHz component and the right-hand bounding wall.

Page 7: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 7

sketch and note important features on the printout. You will need to tape this printout into your lab book.5 Lookespecially at the pointy peaks and the edges of the square wave. Are they sharp? Explain. Listen to the waves.Describe the sound. Now remove some of the higher frequencies. Describe how the wave changes. Describe howthe sound changes. Feel free to play around by changing coefficients and frequencies. Describe anything you findparticularly interesting. Repeat this procedure for both the triangle and sawtooth wave.

3.5 A Useful Function

Now try the following:

• set all of the amplitudes to zero, and start with just one cosine wave (in the 0 slot) at 400 Hz and amplitude 1.Plot it.

• Now add a wave (in the 1 slot) at 800 Hz and amplitude 1. Plot it.

• Now add a wave (in the 2 slot) at 1200 Hz and amplitude 1. Plot it.

Keep on going. What do you end up with? Please print out a graph or sketch it in your notebook. What do youthink would happen as we added higher and higher frequencies? Speculate on the limit of infinite upper frequency.

This function is relevant and useful to many areas in physics especially quantum mechanics.

For a good reference go tohttp://mathworld.wolfram.com/DeltaFunction.html

3.6 Beats and Nice Sounds

Now it is time for some real fun. First we will listen to some “beats” Set all of the coefficients for both sine andcosine to zero. Then add 2 waves (either sine or cosine) with equal amplitude and with frequencies differing by 10Hz. Listen. Describe what you here. Plot the wave. Make sure you use the appropriate timescale. The frequenciesthat you need to use to hear the beats may be different than the frequencies that you need to use to see the beats onthe computer screen.6 If you cannot see or cannot hear your beats then try using a different pair of frequencies.Sketch the beating waveform in your notebook or (preferably-) print it out and tape it into your lab book. Howmight beats relate to tuning musical instruments? The concept of beats will come up again next time, incidentally,in Lab 3’s coupled harmonic oscillator.

You may have noticed that most of the sounds we have heard don’t sound very musical (of course this depends onwhat kind of music you listen to). Musical instruments have richovertones. That is, when a single note is struckwaves at the fundamental, other higher frequencies are produced. In the figure on the next page, you will findspectra showing the harmonic content of several instruments. (These figures are Fourier-transform power spectra:similar to (but not exactly the same as) a plot of the squares of the Fourier coefficients.) You will learn aboutFourier transforms later in the course. Note that the vertical scale is logarithmic (in dB’s or decibels).Based onthese plots, invent your own pleasant-sounding musical tone. Write down the coefficients in your notebookand describe what it sounds like.

15c labfourier feb07.tex; February 15, 2007music spectra, and example of Fourier calculations follow

5The computer room is equipped with a printer so most students should be able to print out their waveforms.6The program display is limited in the time scale that it displays and the incorrect choice of frequency can make the beats difficult to hear

or see using the program.

Page 8: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 8

Figure 1: More Spectra of musical instruments: END LAB NOTES

Page 9: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 9

Figure 2: Example demonstrating calculation of Fourier coeffs., p. 1

Page 10: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 10

Figure 3: Example demonstrating calculation of Fourier coeffs., p. 2

Page 11: Physics 15c: Laboratory 2: Fourier Seriesscphys/courses/15c/15c_2.pdf · Figure 1: Three Waveforms for you to Synthesize 3.2 Fourier Synthesis on the Computer In this part of the

Phys 15c: Lab 2, Spring 2007 11

Figure 4: Example demonstrating calculation of Fourier coeffs., p. 3: END LAB NOTES


Top Related