Section 10.13 Fourier Series Example
Let's consider an example. Suppose \(f(x)\) describes a square wave, so that
\begin{equation}
f(x) = \Theta(\frac{L}{2}-x)=
\begin{cases}
1 \amp (0\le x\lt \frac{L}{2}) \\
0 \amp (\frac{L}{2}\lt x\le L)
\end{cases}\tag{10.13.1}
\end{equation}
(the value of \(f\) at the single point \(x=L/2\) doesn't matter). According to the results of the previous sections, we have
\begin{equation}
f(x) = \frac12 a_0 + \sum_{n=1}^\infty a_n
\cos\left(\frac{2\pi n x}{L}\right)
+ \sum_{n=1}^\infty b_n \sin\left(\frac{2\pi n x}{L}\right)\tag{10.13.2}
\end{equation}
where
\begin{align}
a_0 \amp = \frac{2C}{L} \int_0^{\frac{L}{2}} dx = C,\tag{10.13.3}\\
a_n \amp = \frac{2C}{L} \int_0^{\frac{L}{2}}
\cos\left(\frac{2\pi nx}{L}\right) \,dx
= 0 ,\tag{10.13.4}\\
b_n \amp = \frac{2C}{L} \int_0^{\frac{L}{2}}
\sin\left(\frac{2\pi nx}{L}\right) \,dx
=
\begin{cases}
\frac{2C}{\pi n} \amp \hbox{($n$ odd)}\\
0 \amp \hbox{($n$ even)}
\end{cases}\tag{10.13.5}
\end{align}
Putting this all together,
\begin{equation}
f(x) = C + \sum_{\substack{n=1\\ n\hspace{1.5pt}\mathrm{odd}} }^\infty
\frac{2C}{\pi n} \sin\left(\frac{2\pi nx}{L}\right)\text{.}\tag{10.13.6}
\end{equation}
It is instructive to plot the first few terms of this Fourier series and watch the approximation improve as more terms are included, as shown in Figure 10.13.1.
