## Section10.7Fourier Series: Worked Example

Make sure to complete the activity in Section 10.2 before attempting this one.

In this section, we will use the formulas in Section 10.5 to work out an example, the Fourier series for the function $$f(x)=-\frac12+\sin(2\pi x)\sin(4\pi x)\text{.}$$ Then you will plot the individual terms in the Fourier series and their partials sums using an applet.

The formula for the first coefficient $$a_0$$ is given in (10.5.3). You can use the Sage code below to calculate the value of this integral.

L=1
m=0
f=-0.5+sin(2*pi*x)*sin(4*pi*x)
2/L*integrate(f*cos(2*pi*m*x/L),x,0,L)


Using the applet in Figure 10.7.1, set the $$a_0/2$$ slider to correspond to the value you just calcuated. Compare your approximate Fourier series, containing just one term (shown in green), to the actual function (shown in blue).

You should notice that $$\frac12 a_0$$ is just the average value of the function. Because the given function is symmetric vertically, this zeroth-order approximation (green) runs across the middle of the graph of the function (blue). In general, the integral in (10.5.3) defines what you mean by “the middle”.

Now you can alter the Sage code above to compute the other coefficients, using (10.5.2) and (10.5.4) in Section 10.5. After each calculation, move the corresponding slider to the value you obtain, and compare the approximation to the given function.

If you move the sliders one by one, resetting the others to zero, you will see how much each individual term contributes to the Fourier series.

If you don't reset the other sliders, but instead combine the contributions from each slider, the applet plots the sum of the corresponding terms (in green), representing an approximation to the actual function (in blue). In the given example, you should obtain an exact match when you include all of the terms with $$m=0,1,2,3$$ (most of which will be $$0$$). In general, there are an infinite number of nonzero terms in the Fourier series; your approximation will get better and better as you include more terms.