# Advanced Mathematics for Engineers and Scientists/Details and Applications of Fourier Series

## Details and Applications of Fourier Series

In the study of PDEs (and much elsewhere), a Fourier series (or more generally, trigonometric expansion) often needs to be constructed.

### Preliminaries

Suppose that a function f(x) may be expressed in the following way:

$f(x)={\frac {A_{0}}{2}}+\sum _{n=1}^{\infty }\left(A_{n}\cos \left({\frac {n\pi }{L}}x\right)+B_{n}\sin \left({\frac {n\pi }{L}}x\right)\right)$

It can be shown (not too difficult, but beyond this text) that the above expansion will converge to f(x), except at discontinuities, if the following conditions hold:

• f(x) = f(x + 2L), i.e. f(x) has period 2L .
• f(x), f'(x), and f''(x) are piecewise continuous on the interval -LxL.
• The pieces that make up f(x), f'(x), and f''(x) are continuous over closed subintervals.

The first requirement is most significant; the last two requirements can, to an extent, be partly eased off in most cases without any trouble. An interesting thing happens at discontinuities. Suppose that f(x) is discontinuous at x = a; the expansion will converge to the following value:

${\frac {1}{2}}\left(\lim _{x\rightarrow a^{-}}f(x)+\lim _{x\rightarrow a^{+}}f(x)\right)\,$

So the expansion converges to the average of the values to the left and the right of the discontinuity. This, and the fact that it converges in the first place, is very convenient. The Fourier series looks unfriendly but it's honestly working for you.

The information needed to express f(x) as a Fourier series are the sequences An and Bn. This is done using orthogonality, which for the sinusoids may be derived easily using a few identities. The following are some useful orthogonality relations, with m and n restricted to integers:

$\int _{0}^{L}{\frac {2}{L}}\sin \left({\frac {m\pi }{L}}x\right)\sin \left({\frac {n\pi }{L}}x\right)dx=\delta _{m,n}$
$\int _{0}^{L}{\frac {2}{L}}\cos \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)dx=\delta _{m,n}$
$\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)\sin \left({\frac {n\pi }{L}}x\right)dx=\delta _{m,n}$
$\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)dx=\delta _{m,n}$
$\int _{-L}^{L}\sin \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)dx=0$

δm,n is called the Kronecker delta, defined by:

$\delta _{m,n}={\begin{cases}1,&m=n\\0,&m\neq n\end{cases}}$

The Kronecker delta may be thought of as a discrete version of the Dirac delta "function". Relevant to this topic is its sifting property:

$\sum _{n=-\infty }^{\infty }A_{n}\delta _{m,n}=A_{m}\,$

### Derivation of the Fourier Series

We're now ready to find An and Bn.

$f(x)={\frac {A_{0}}{2}}+\sum _{n=1}^{\infty }\left(A_{n}\cos \left({\frac {n\pi }{L}}x\right)+B_{n}\sin \left({\frac {n\pi }{L}}x\right)\right)$
${\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)\cdot f(x)={\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)\cdot \left({\frac {A_{0}}{2}}+\sum _{n=1}^{\infty }\left(A_{n}\cos \left({\frac {n\pi }{L}}x\right)B_{n}\sin \left({\frac {n\pi }{L}}x\right)\right)\right)\,$
 ${\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)f(x)=$ ${\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right){\frac {A_{0}}{2}}+$ $\sum _{n=1}^{\infty }\left(A_{n}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)+B_{n}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)\sin \left({\frac {n\pi }{L}}x\right)\right)$ $\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)f(x)dx$ $=\int _{-L}^{L}{\frac {A_{0}}{2L}}\cos \left({\frac {m\pi }{L}}x\right)+$ $\sum _{n=1}^{\infty }\left(A_{n}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)+{\frac {B_{n}}{L}}\cos \left({\frac {m\pi }{L}}x\right)\sin \left({\frac {n\pi }{L}}x\right)\right)dx$ $\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)f(x)dx$ $=\int _{-L}^{L}{\frac {A_{0}}{2L}}\cos \left({\frac {m\pi }{L}}x\right)dx+$ $\sum _{n=1}^{\infty }\left(A_{n}\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)dx+{\frac {B_{n}}{L}}\int _{-L}^{L}\cos \left({\frac {m\pi }{L}}x\right)\sin \left({\frac {n\pi }{L}}x\right)dx\right)$ $\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)f(x)dx=\int _{-L}^{L}{\frac {A_{0}}{2L}}\cos \left({\frac {m\pi }{L}}x\right)dx+\sum _{n=1}^{\infty }\left(A_{n}\delta _{m,n}+{\frac {B_{n}}{L}}\cdot 0\right)$

This is supposed to hold for an arbitrary integer m. If m = 0, note that the sum doesn't allow n = 0 and so the sum would be zero since in no case does m = n. This leads to:

$\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {0\cdot \pi }{L}}x\right)f(x)dx=\int _{-L}^{L}{\frac {A_{0}}{2L}}\cos \left({\frac {0\cdot \pi }{L}}x\right)dx$
$\int _{-L}^{L}{\frac {1}{L}}f(x)dx=A_{0}\int _{-L}^{L}{\frac {dx}{2L}}$
$\int _{-L}^{L}{\frac {1}{L}}f(x)dx=A_{0}$

This secures A0. Now suppose that m > 0. Since m and n are now in the same domain, the Kronecker delta will do its sifting:

$\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)f(x)dx=\int _{-L}^{L}{\frac {A_{0}}{2L}}\cos \left({\frac {m\pi }{L}}x\right)dx+\sum _{n=1}^{\infty }\left(A_{n}\delta _{m,n}\right)$
$\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)f(x)dx={\frac {A_{0}\sin(m\pi )}{m\pi }}+A_{m}$
$\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {m\pi }{L}}x\right)f(x)dx=0+A_{m}$
$A_{n}=\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {n\pi }{L}}x\right)f(x)dx$

In the second to the last step, sin(mπ) = 0 for integer m. In the last step, m was replaced with n. This defines An for n > 0. For the case n = 0,

$A_{0}=\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {0\cdot \pi }{L}}x\right)f(x)dx$
$A_{0}=\int _{-L}^{L}{\frac {1}{L}}f(x)dx$

Which happens to match the previous development (now you know why it's A0/2 and not just A0). So the sequence An is now completely defined for any value of n of interest:

$A_{n}=\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {n\pi }{L}}x\right)f(x)dx$

To get Bn, nearly the same routine is used.

$f(x)={\frac {A_{0}}{2}}+\sum _{n=1}^{\infty }\left(A_{n}\cos \left({\frac {n\pi }{L}}x\right)+B_{n}\sin \left({\frac {n\pi }{L}}x\right)\right)$
${\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)\cdot f(x)={\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)\cdot \left({\frac {A_{0}}{2}}+\sum _{n=1}^{\infty }\left(A_{n}\cos \left({\frac {n\pi }{L}}x\right)B_{n}\sin \left({\frac {n\pi }{L}}x\right)\right)\right)\,$
 ${\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)f(x)=$ ${\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right){\frac {A_{0}}{2}}+$ $\sum _{n=1}^{\infty }\left(A_{n}{\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)+B_{n}{\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)\sin \left({\frac {n\pi }{L}}x\right)\right)$ $\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)f(x)dx$ $=\int _{-L}^{L}{\frac {A_{0}}{2L}}\sin \left({\frac {m\pi }{L}}x\right)+$ $\sum _{n=1}^{\infty }\left({\frac {A_{n}}{L}}\sin \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)+B_{n}{\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)\sin \left({\frac {n\pi }{L}}x\right)\right)dx$ $\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)f(x)dx$ $={\frac {A_{0}}{2L}}\int _{-L}^{L}\sin \left({\frac {m\pi }{L}}x\right)dx+$ $\sum _{n=1}^{\infty }\left({\frac {A_{n}}{L}}\int _{-L}^{L}\sin \left({\frac {m\pi }{L}}x\right)\cos \left({\frac {n\pi }{L}}x\right)dx+{\frac {B_{n}}{L}}\int _{-L}^{L}\sin \left({\frac {m\pi }{L}}x\right)\sin \left({\frac {n\pi }{L}}x\right)dx\right)$ $\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)f(x)dx={\frac {A_{0}}{2L}}\cdot 0+\sum _{n=1}^{\infty }\left({\frac {A_{n}}{L}}\cdot 0+B_{n}\delta _{m,n}\right)$
$\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {m\pi }{L}}x\right)f(x)dx=B_{m}$
$B_{n}=\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {n\pi }{L}}x\right)f(x)dx$

The Fourier series expansion of f(x) is now complete. To have it all in one place:

$f(x)={\frac {A_{0}}{2}}+\sum _{n=1}^{\infty }\left(A_{n}\cos \left({\frac {n\pi }{L}}x\right)+B_{n}\sin \left({\frac {n\pi }{L}}x\right)\right)$
$A_{n}=\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {n\pi }{L}}x\right)f(x)dx$
$B_{n}=\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {n\pi }{L}}x\right)f(x)dx$

It's finally time for an example. Let's derive the Fourier series representation of a square wave, pictured at the right:

This "wave" may be quantified as f(x):

$f(x)={\begin{cases}1,&-1

f(x) has period 2. Since 2L = P, L = 1. Now, finding the Fourier coefficients:

 $A_{n}\,$ $=\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {n\pi }{L}}x\right)f(x)dx$ $=\int _{-1}^{1}\cos(n\pi x)f(x)dx$ $=\int _{-1}^{0}\cos(n\pi x)(-1)dx+\int _{0}^{1}\cos(n\pi x)(1)dx$ $=-{\frac {\sin(n\pi )}{n\pi }}+{\frac {\sin(n\pi )}{n\pi }}$ $=0\,$ $B_{n}\,$ $=\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {n\pi }{L}}x\right)f(x)dx$ $=\int _{-1}^{1}\sin(n\pi x)f(x)dx$ $=\int _{-1}^{0}\sin(n\pi x)(-1)dx+\int _{0}^{1}\sin(n\pi x)(1)dx$ $=\left({\frac {1}{n\pi }}-{\frac {\cos(n\pi )}{n\pi }}\right)+\left({\frac {1}{n\pi }}-{\frac {\cos(n\pi )}{n\pi }}\right)$ $={\frac {2}{n\pi }}\left(1-\cos(n\pi )\right)\,$ $={\frac {2}{n\pi }}\left(1-(-1)^{n}\right)\,$ $f(x)=\sum _{n=1}^{\infty }B_{n}\sin(n\pi x)$
$f(x)=\sum _{n=1}^{\infty }{\frac {2}{n\pi }}\left(1-(-1)^{n}\right)\sin(n\pi x)$
$f(x)=\sum _{n=1}^{\infty }{\frac {4\sin((2n-1)\pi x)}{(2n-1)\pi }}$

In the last bit we used the fact that all of the even terms happened to be absent, and the odd numbers are given by 2n - 1 for integer n. The sum will indeed converge to the square wave, except at the discontinuities where it'll converge to zero (the average of 1 and -1).

Graphs of partial sums are shown at right. Note that this particular expansion doesn't converge too quickly, and that as an approximation of the square wave it's poorest near the discontinuities.

There's another interesting thing to note: all of the cosine terms are absent. It's no coincidence, and this may be a good time to introduce the Fourier sine and cosine expansions for, respectively, odd and even functions.

### Periodic Extension and Expansions for Even and Odd functions

Two important expansions may be derived from the Fourier expansion: the Fourier sine series and the Fourier cosine series, the first one was used in the previous section. Before diving in, we must talk about even and odd functions.

Suppose that feven(x) is an even function and fodd(x) is an odd function. That is:

$f_{\text{even}}(-x)=f_{\text{even}}(x)\,$
$f_{\text{odd}}(-x)=-f_{\text{odd}}(x)\,$

Some interesting identities hold for such functions. Relevant ones include:

$f_{\text{even}}(x)\cdot f_{\text{even}}(x)={\mbox{an even function}}\,$
$f_{\text{odd}}(x)\cdot f_{\text{odd}}(x)={\mbox{an even function}}\,$
$f_{\text{even}}(x)\cdot f_{\text{odd}}(x)={\mbox{an odd function}}\,$
$\int _{-a}^{a}f_{\text{even}}(x)dx=2\int _{0}^{a}f_{\text{even}}(x)dx$
$\int _{-a}^{a}f_{\text{odd}}(x)dx=0$

This is all very relevant to Fourier series. Suppose that an even function is expanded. Recall that sine is odd and cosine is even. Then:

 $A_{n}\,$ $=\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {n\pi }{L}}x\right)f_{\text{even}}(x)dx$ (whole integrand is even) $=\int _{0}^{L}{\frac {2}{L}}\cos \left({\frac {n\pi }{L}}x\right)f_{\text{even}}(x)dx$ $B_{n}\,$ $=\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {n\pi }{L}}x\right)f_{\text{even}}(x)dx$ (whole integrand is odd) $=0\,$ So the Fourier cosine series (note that all sine terms disappear) is just the Fourier series for an even function, given as:

$f_{\text{even}}(x)={\frac {A_{0}}{2}}+\sum _{n=1}^{\infty }\left(A_{n}\cos \left({\frac {n\pi }{L}}x\right)\right)$
$A_{n}=\int _{0}^{L}{\frac {2}{L}}\cos \left({\frac {n\pi }{L}}x\right)f_{even}(x)dx$

A Fourier expansion may be similarly built for an odd function:

 $A_{n}\,$ $=\int _{-L}^{L}{\frac {1}{L}}\cos \left({\frac {n\pi }{L}}x\right)f_{\text{odd}}(x)dx$ (whole integrand is odd) $=0\,$ $B_{n}\,$ $=\int _{-L}^{L}{\frac {1}{L}}\sin \left({\frac {n\pi }{L}}x\right)f_{\text{odd}}(x)dx$ (whole integrand is even) $=\int _{0}^{L}{\frac {2}{L}}\sin \left({\frac {n\pi }{L}}x\right)f_{\text{odd}}(x)dx$ And the Fourier sine series is:

$f_{\text{odd}}(x)=\sum _{n=1}^{\infty }\left(B_{n}\sin \left({\frac {n\pi }{L}}x\right)\right)$
$B_{n}=\int _{0}^{L}{\frac {2}{L}}\sin \left({\frac {n\pi }{L}}x\right)f_{\text{odd}}(x)dx$

At this point, the periodic extension may be considered. In the previous chapter, the problem mandated a sine expansion of a parabola. A parabola is by no means a periodic function, and yet a Fourier sine expansion was done on it. What actually happened was that the function was expanded as expected within its domain of interest: the interval 0 ≤ x ≤ 1. Inside this interval, the expansion truly is a parabola. Outside this interval, the expansion is periodic, and as a whole is odd (just like the sine functions it's built on).

The parabola could've been expanded just as well using cosines (resulting in an even expansion) or a full Fourier expansion on, say, -1 ≤ x ≤ 1.

Note that we weren't able to pick which expansion to use, however. While the parabola could be expanded any way we want on any interval we want, only the sine expansion on 0 ≤ x ≤ 1 would solve the problem. The ODE and BCs together picked the expansion and the interval. In fact, before the expansion was even constructed we had:

$u(y,t)=\sum _{n=1}^{\infty }u_{n}(y,t)=\sum _{n=1}^{\infty }e^{-(n\pi )^{2}\nu t}A_{n}\sin(n\pi y)\,$

Which is a Fourier sine series only at t = 0. That the IC was defined at t = 0 allowed the expansion. For t > 0, the solution has nothing in common with a Fourier series.

What's trying to be emphasized is flexibility. Knowledge of Fourier series makes it much easier to solve problems. In the parallel plate problem, knowing what a Fourier sine series is motivates the construction of the sum of un. In the end it's the problem that dictates what needs to be done. For the separable IBVPs, expansions will be a recurring nightmare theme and it is most important to be familiar and comfortable with orthogonality and its application to making sense out of infinite sums. Many functions have orthogonality properties, including Bessel functions, Legendre polynomials, and others.

The keyword is orthogonality. If an orthogonality relation exists for a given situation, then a series solution is easily possible. As an example, the diffusion equation used in the previous chapter can, with sufficiently ugly BCs, require a trigonometric series solution that is not a Fourier series (non-integer, not evenly spaced frequencies of the sinusoids). Sturm-Liouville theory rescues us in such cases, providing the right orthogonality relation.