This Exercise Set has been submitted for peer review, but it has not yet been accepted for publication in the PICUP collection.

+
Introduction to Fourier Series

Developed by B. D. DePaola

In this exercise we explain the math and concepts that underlie Fourier series. This includes deriving expressions for the Fourier expansion coefficients, using the coefficients to approximate several different wave trains, and then comparing the exact wave trains to the approximate ones by plotting them both. The programs are *not* computationally intense. Rather, they are elementary implementations that use summations and basic plotting techniques to help visualize these important, yet abstract concepts. With an understanding, both mathematical and visual, of Fourier series under their belts, the students will be much better prepared to proceed on to a companion exercise on Fourier transforms and, eventually, wavelet analysis.
Subject Areas Mechanics, Waves & Optics, and Mathematical/Numerical Methods First Year and Beyond the First Year Python and IPython/Jupyter Notebook Students will: * Learn how to derive Fourier series coefficients for arbitrary infinite wave trains, making use of symmetry when possible. * Approximate specific important infinite wave trains by Fourier series. * Plot both exact waveforms and Fourier series approximations. 120 min

These exercises are not tied to a specific programming language. Example implementations are provided under the Code tab, but the Exercises can be implemented in whatever platform you wish to use (e.g., Excel, Python, MATLAB, etc.).

## Exercise 1: The Sawtooth Wave ## Consider the sawtooth wave. To be specific, let's let the wave run vertically from 0 to some height $h$, and let's center it horizontally as shown in the figure. ![" "](images/Intro_Fourier_Series/SawtoothWave.png "") 1. Write a program that creates a plot of a sawtooth wave, similar to that in the figure. (Hint: write a subroutine that creates a single "tooth". Then, as above with the tophat function, generate a sawtooth by splicing together many teeth.) 2. Note that the sawtooth in the figure neither even, nor an odd, function. But if the function were shifted downward by $h/2$ it would have a definite symmetry. Is that symmetry even or odd? 3. Write a subroutine that computes the appropriate summation coefficients. Note that you can "pretend" that your function has the symmetry mentioned in #2, by "pretending" that the function has been shifted down by $h/2$. Then when constructing the Fourier series approximation of the function, you can simply add $h/2$ to each of the summations. 4. Write a program that uses those coefficients to create approximations of a sawtooth wave, for 1, 3, and 50 terms. ## Exercise 2: The Triangle Wave ## Consider the triangle wave. To be specific, let's let the wave run vertically from 0 to some height $h$, and let's arrange it horizontally as shown in the figure, such that the peak of a triangle is at $x = 0$. ![]![](images/Intro_Fourier_Series/TriangleWave.png "") 1. Write a program that creates a plot of a triangle wave, similar to that in the figure. (Hint: Use your subroutine that creates a single "tooth". Then, write a subroutine that uses the "tooth" function (twice) to create a single triangle. Then, as before, generate a triangle wave by splicing together many triangles.) 2. Is the waveform, as defined, even, odd, or neither? If neither, is there anything you can do to give it a definite even or odd parity? 3. Write a subroutine that computes the appropriate summation coefficients. 4. Write a program that uses those coefficients to create approximations of a triangle wave, for 1, 3, and 50 terms. 5. Re-plot the original function, along with your three approximations. For the same number of terms, is a Fourier series a better approximate a triangle wave or a sawtooth wave? Why do you think this is so?