Fourier Series for Solving Partial Differential Equations
Definition
For a function $f \in \mathcal{L}^{2} [- \pi , \pi] $ in a Hilbert space, given $\displaystyle a_{k} = {{1} \over {\pi}} \int_{- \pi}^{\pi} f(x) \cos kx dx$ and $\displaystyle b_{k} = {{1} \over {\pi}} \int_{- \pi}^{\pi} f(x) \sin kx dx$,
$$ f(x) \sim {{a_{0}} \over {2}} + \sum_{k=1}^{\infty} \left( a_{k} \cos kx + b_{x} \sin kx \right) $$
is called the fourier series of $f$.
Explanation
Unlike the Taylor series, which approximates a function with polynomials, the Fourier series approximates it with trigonometric polynomials. Because of its complex form, the Fourier series is useful in that it can be applied to all sorts of functions that are difficult to approach with the conventional Taylor series. However, there is no guarantee that a Fourier series converges, and even if it can be shown to converge, whether it converges exactly to $f$ is a separate matter. For solving partial differential equations at the undergraduate level we set such issues aside for now, but one should be aware of these defects.
For convenience, from here on we will use $=$ instead of $\sim$. Let us take a look at why the Fourier series is defined in that particular form. Since $\mathcal{L}^2$ is the case $p=2$ of $\mathcal{L}^{p}$, for $f,g : [-\pi, \pi] \to \mathbb{R}$ we can define the inner product and norm as follows.
$$ \left< f, g \right> := {{1} \over{\pi}} \int_{-\pi}^{\pi} f(x) g(x) dx \left\| f \right\| : = \left< f, f \right> := \sqrt{ {{1} \over{\pi}} \int_{-\pi}^{\pi} \left| f(x) \right| ^2 dx } $$
For the odd function $\sin k x$ and the even function $\cos k x$, we have $\displaystyle \left< \cos kx , \cos lx \right> = \left< \sin kx , \cos lx \right> = 0$ when $k \ne l$. Of course, even for $k = l$ we have $\displaystyle \left< \cos lx , \sin lx \right> = \left< \sin lx , \cos lx \right> = 0$. Among inner products of trigonometric functions, the only case where the result is not $0$ is $\displaystyle \left< \cos lx , \cos lx \right> \ne 0 \ne \left< \sin lx , \sin lx \right>$.
Using the above facts, computing $\left< f, \cos lx \right> f$ gives, by the linearity of the inner product,
$$ \left< f, \cos lx \right> = {{a_{0}} \over {2}} \left< 1 , \cos lx \right> + \sum_{k=1}^{\infty} \left( a_{k} \left< \cos kx , \cos lx \right> + b_{x} \left< \sin kx , \cos lx \right> \right) = a_{l} $$
Similarly, we can obtain $\left< f , \sin lx \right> = b_{l}$, and
$$ \left< f , 1 \right> = {{a_{0}} \over {2}} \left< 1, 1 \right> = {{a_{0}} \over {2}} \left\| 1 \right\| ^2 = {{a_{0}} \over {2}} $$
holds.
Approximating $f$ with a trigonometric polynomial is projecting $f$ onto the vector space of trigonometric functions. Thinking about each term in the sense of linear algebra, the form is $\left< f(x) , \cos nx \right> \cos nx$ or $\left< f(x) , \sin nx \right> \sin nx$, which can be seen as projecting the function $f$ onto the basis $\left\{ \cos nx , \sin nx \ | \ n \in \mathbb{N} \right\}$.
Using the properties of even and odd functions, we can reduce the computation considerably not only in this case but also through the formulas below.
If $f \in \mathcal{L}^{2} [-\pi , \pi ]$ is an even function, then for $\displaystyle a_{k} = {{2} \over {\pi}} \int_{0} \pi f(x) \cos kx dx$,
$$ f(x) \sim {{a_{0 } } \over {2 }} + \sum_{k=1}^{\infty} a_{k} \cos kx $$
If $f \in \mathcal{L}^{2} [-\pi , \pi ]$ is an odd function, then for $\displaystyle b_{k} = {{2} \over {\pi}} \int_{0} \pi f(x) \sin kx dx$,
$$ f(x) \sim \sum_{k=1}^{\infty} b_{k} \sin kx $$
Meanwhile, for $f,g : [-\pi, \pi] \to \mathbb{C}$, introducing the following definitions allows a generalization to complex numbers.
$$ \left< f, g \right> := {{1} \over{2 \pi}} \int_{-\pi}^{\pi} f(x) \overline{ g(x) } dx $$
$$ \left\| f \right\| : = \left< f, f \right> := \sqrt{ {{1} \over{2 \pi}} \int_{-\pi}^{\pi} \left| f(x) \right| ^2 dx } $$
$$ f(x) \sim \sum_{k \in \mathbb{Z}} c_{k} e^{ikx} = \cdots +c_{-2}e^{-i 2 x } + c_{-1}e^{-i x } + c_{0} +c_{1}e^{i x } + c_{2}e^{i 2 x } + \cdots $$
$$ c_{k} = \left<f , e^{ikx} \right> = {{1} \over {2 \pi}} \int_{-\pi}^{\pi} f(x) e^{-ikx} dx $$
Since, by Euler’s formula, $\displaystyle \cos kx = {{e^{ikx} + e^{-ikx} } \over {2}}$ and $\displaystyle \sin kx = {{e^{ikx} - e^{-ikx} } \over {2i}}$,
$$ \begin{align*} c_{k} + c_{-k} =& {{1 } \over {2 \pi }} \int_{-\pi}^{\pi} f(x) \left(e^{ikx} + e^{-ikx} \right) dx \\ =& {{1 } \over { 2 \pi }} \int_{-\pi}^{\pi} f(x) \cdot 2 \cos kx dx \\ =& {{1 } \over { \pi }} \int_{-\pi}^{\pi} f(x) \cos kx dx \\ =& a_{k} \end{align*} $$
Similarly, we can obtain $b_{k} = i (c_{k} - c_{-k})$.
Therefore, although it appears superficially that the normalization constant has changed, in reality it properly covers $f,g : [-\pi, \pi] \to \mathbb{R}$. As can be seen, understanding these techniques even roughly requires background knowledge in linear algebra, complex analysis, real analysis, and so on.
