Skip to main content
Physics LibreTexts

8.2.3: Fourier Series Simulation

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    This simulation shows the sum of up to eight harmonics (five on mobile devices) of a sine wave. Initially the speed is set to zero to make the visualization simpler. A harmonic of a sine wave is a sine wave that has a frequency which is a whole number multiple of the frequency of the original wave. The first harmonic (set with the slider \(A1\)) is called the fundamental. So if the fundamental is \(f_{1} = 200\text{ Hz}\) the second harmonic is \(f_{2} = 400\text{ Hz}\), the third harmonic is \(f_{3} = 600\text{ Hz}\), etc. We know \(v=\lambda f\) so for a fixed speed, doubling the frequency means the wavelength of the second harmonic is half that of the fundamental. Conversely, holding your finger down in the middle of a guitar string and plucking one side cuts the wavelength in half which doubles the frequency being played. For standing waves on a string fixed at each end (such as a guitar string) each harmonic is also called a normal mode of vibration.

    The graph on the upper right in the simulation is the Fourier spectrum and is a short hand way of showing how much of each harmonic is present in the graph on the left. Fourier series usually include sine and cosine functions and can represent periodic functions in time or space or both. In this simulation we only have combinations of sine waves. The Fourier series for the wave function showing in the left graph is given by \(y(t)=\sum_{n=1} A_{n}\sin (n2\pi x/\lambda-n2\pi f_{1}t)\). Here \(t\) is time, \(n\) is the number of the harmonic or mode (\(n=1\) for the fundamental, \(2\) for the second harmonic etc.), \(A_{n}\) is the amplitude of harmonic or mode number \(n\) and \(f_{1}\) is the fundamental frequency (\(f=1/T\)). Amplitude is in arbitrary units, scaled between \(1\) and \(-1\).


    The Fourier Series and Sound JavaScript Model uses the HTML 5 Web Audio API. This API is still under development and may not be supported on all platforms. Press the Reset button to reinitialize the simulation if the sound does not play when the simulations is first loaded.

    Simulation Questions:

    1. Try adjusting the slider A1 to different values. What does this slider do? If you have speakers, turn the sound on and listen. This is a \(200\text{ Hz}\) sine wave.
    2. You may have noticed the amplitude shows up in the graph on the right. You can also see the magnitude of the amplitude by holding the mouse the mouse button down and moving the mouse to the top of one of the peaks on the graph on the left. Does it match the value of \(A1\) set by the slider? Use the mouse to find the wavelength (distance between peaks on the left graph), what is the wavelength of this wave?
    3. Use the 'reset' button and move slider \(A_{2}\) (the second harmonic). What is the wavelength of the second harmonic? How does this wavelength compare to the wavelength of the fundamental? This is a \(400\text{ Hz}\) sine wave. What does it sound like?
    4. The pitch of a sound wave is determined by the fundamental frequency. Turn on the velocity (\(344\text{ m/s}\) for sound at room temperature) by clicking the simulation run button. With only amplitude A1 showing, run the simulation. Find the period by measuring the time (in \(10^{-3}\text{ sec}\)) between when one peak passes the origin and when the next peak passes (use the step button to get an accurate time measurement). What is the frequency of the fundamental?
    5. Now find the period of a wave with several harmonics. What is the period of the combination (the time between successive highest peaks)? Although the wave looks more complicated it has the same fundamental frequency and therefore the same pitch. The additional, smaller peaks are due to the harmonics and give a sound its timbre. A trumpet and trombone playing the same note have the same fundamental frequency but sound different because of the number and amount of harmonics present.
    6. To get the exact shape of an arbitrary periodic function we would need an infinite number of terms in the Fourier series but in this simulation we can only add a maximum of 8 terms. Try the following combination of harmonics (you can type the amplitudes into the boxes next the sliders to get exact values): \(A_{1} = 1.0,\: A_{2} = 0,\: A_{3} = 0.333 (= 1/3),\: A_{4} = 0,\: A_{5} = 0.20 (= 1/5),\: A_{6} = 0,\: A_{7} = 0.143 (= 1/7),\: A_{8} = 0\). What is the approximate shape of this wave? If you have speakers, turn the sound on and listen.
    7. Reset the simulation and try the following combination of harmonics (you can type the amplitudes into the boxes next the sliders to get exact values): \(A_{1} = 1.0,\: A_{2} = -0.5,\: A_{3} = 0.333,\: A_{4} = -0.25,\: A_{5} = 0.20,\: A_{6} = -0.166,\: A_{7} = 0.143,\: A_{8} = -0.125\). What is the approximate shape of this wave? If you have speakers, turn the sound on and listen.
    8. Suppose a clarinet and a trumpet both play the same note (have the same fundamental frequency). Why is it that you can still tell them apart, even though they are playing the same note?
    9. Find a definition of timbre and write it in your own words. Based on your answers to the above questions, what causes timbre?
    10. Suppose you wanted to build an electronic instrument which added waves together to imitate other instruments (this is how some musical synthesizers work). What would you need to know about the sound a trumpet makes in order to reconstruct that sound? (Hint: think about the information contained in the graph at the top right.)

    This page titled 8.2.3: Fourier Series Simulation is shared under a CC BY-NC-SA 3.0 license and was authored, remixed, and/or curated by Kyle Forinash and Wolfgang Christian via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.