Fourier basis functions

An orthonormal basis for $L^2([0,1],\mathbb{R})$ (the space of real valued square integrable functions on the interval $[0,1]$) is $1, \sqrt{2}\cos(2\pi nx), \sqrt{2}\sin(2\pi nx)$ for $n=1,2,3,...$. These functions can be written as (convergence in $L^2$, many details omitted): $$ f(x)=a_0+\sum_{n=1}^{\infty}a_n\cos(2\pi nx)+b_n\sin(2\pi nx) $$ where $a_0=\int_{[0,1]}f(x)\,dx$, and for $n\geq 1$ $$ a_n=2\int_{[0,1]}f(x)\cos(2\pi nx)dx, \quad b_n=2\int_{[0,1]}f(x)\sin(2\pi nx)dx. $$ The orthonormality of the basis functions is established by showing that $$ \int_{[0,1]}\cos(2\pi nx)\sin(2\pi mx)dx=0, $$ $$ \int_{[0,1]}\cos(2\pi nx)\cos(2\pi mx)dx=0 \text{ if } n\neq m, \ 1/2 \text{ if } n=m,$$ $$ \int_{[0,1]}\sin(2\pi nx)\sin(2\pi mx)dx=0 \text{ if } n\neq m, \ 1/2 \text{ if } n=m,$$ so they are orthonormal with respect to the inner product $$ \langle f,g\rangle=\int_{[0,1]}f(x)g(x)dx. $$ You can learn a lot more by finding a good reference. Most differential equations books cover Fourier series to some extent to provide solutions to the heat/wave/laplace equations (e.g. Boyce and DiPrima). Here is something random from google showing the orthogonality relations (don't know if its good).


As stated in the fourier series definition, any T-periodic function can be writen as a linear combination of the set $B = \{1, \cos{(\frac{2\pi}{T}x)}, \sin{(\frac{2\pi}{T}x)}, \cos{(\frac{4\pi}{T}x)}, \sin{(\frac{4k\pi}{T}x)}, ... \cos{(\frac{2n\pi}{T}x)}, \sin{(\frac{2n\pi}{T}x)}\}$. So $B$ span the T-periodic functions vector space, so $B$ is basis. I don't know yet if this basis is orthonormal.

We define $gc_k = \cos{(\frac{2k\pi}{T}x)}$ and $gs_k = \sin{(\frac{2k\pi}{T}x)}$ , so $B = \{1, gc_1, gs_1, gc_2, gs_2, ..., gc_n, gs_n \}$.

Ok, let's now define the T-periodic functions vector space dot product:

For any T-periodic functions $f(x)$ and $g(x)$: $f\bullet g = \int_{-T/2}^{T/2} f(x)g(x)dx $

This is very similar to the regular vector dot product: You get a summation of the product of their related coordinates...

OK, now we have a basis and a dot product. But we have to check that our basis is an orthonormal basis(Remember that we need unit vectors in order to compute the projection via the dot product ). Thanks to our new dot product, we can check if 2 vectors are orthogonals and we can compute the norm of a vector.

Orthonormal basis

Let's compute now the dot product between every function(vector) of the basis $B = \{1, gc_1, gs_1, gc_2, gs_2, ..., gc_n, gs_n \}$:

$$\int_{-T/2}^{T/2}\cos{(\frac{2k\pi}{T}x)}cos{(\frac{2m\pi}{T}x)}dx = \begin{cases} 0, \text{ if } k \neq m \\ \frac{T}{2} \text{ if } k = m\end{cases}$$

$$\int_{-T/2}^{T/2}\sin{(\frac{2k\pi}{T}x)}sin{(\frac{2m\pi}{T}x)}dx = \begin{cases} 0, \text{ if } k \neq m \\ \frac{T}{2} \text{ if } k = m\end{cases}$$

$$\int_{-T/2}^{T/2}\cos{(\frac{2k\pi}{T}x)}sin{(\frac{2m\pi}{T}x)}dx = 0$$

  • We obtain $gc_k \bullet gs_m = 0$, $gc_k \bullet gc_m = 0, k \neq m$, and $gs_k \bullet gs_m = 0, k \neq m$ this means that each function(vector) of our basis is orthogonal with each other function(vector) of the basis. So B isorthogonal.
  • We obtain also $gc_k \bullet gc_k = gs_k \bullet gs_k = \frac{T}{2} = {\lVert g_k\rVert}^2 $, this means that the functions are not unit vectors, so our Basis is not orthonormal. Notice that $g_0 \bullet g_0 =\int_{-T/2}^{T/2}dx = T$

So to make our basis orthonormal, each vector has to be divided by its norm (${\lVert gc_k\rVert} =\sqrt{\frac{T}{2}}$, ${\lVert gs_k\rVert} =\sqrt{\frac{T}{2}}$ and ${\lVert g_0\rVert} =\sqrt{T}$):

$B' = \{\frac{1}{\sqrt{T}}, \sqrt{\frac{2}{T}}\cos{(\frac{2\pi}{T}x)}, \sqrt{\frac{2}{T}}\sin{(\frac{2\pi}{T}x)}, \sqrt{\frac{2}{T}}\cos{(\frac{4\pi}{T}x)}, \sqrt{\frac{2}{T}}\sin{(\frac{4k\pi}{T}x)}, ...,\\ \sqrt{\frac{2}{T}}\cos{(\frac{2n\pi}{T}x)}, \sqrt{\frac{2}{T}}\sin{(\frac{2n\pi}{T}x)}\}$

Coordinates in the basis

Now that we have an orthonormal basis, we can project $f(x)$ on each function of the basis via the dot product and then get the coordinates of $f(x)$ in this basis:

$$fc_k = f(x) \bullet gc'_k(x) = \sqrt{\frac{2}{T}} \int_{-T/2}^{T/2}f(x)\cos{(\frac{2k\pi}{T}x)}dx$$

$$fs_k = f(x) \bullet gs'_k(x) = \sqrt{\frac{2}{T}} \int_{-T/2}^{T/2}f(x)\sin{(\frac{2k\pi}{T}x)}dx$$

$$f_0 = \frac{1}{\sqrt{T}}\int_{-T/2}^{T/2}f(x)dx$$

We have now the coordinates $(f_0,fc_1, fs_1, fc_2, fs_2, ... ,fc_n, fs_n)$ of f(x) in the basis, so we can write the following linear combination:

$$f(x) = f_0g_0 + \sum_{k=1}^{\infty}fc_k\cdot gc'_k(x) + \sum_{k=1}^{\infty}fs_k\cdot gs'_k(x)$$

$f(x) = (\frac{1}{\sqrt{T}}\int_{-T/2}^{T/2}f(x)dx)\frac{1}{\sqrt{T}} +\\ \sum_{k=1}^{\infty}(\sqrt{\frac{2}{T}} \int_{-T/2}^{T/2}f(x)\cos{(\frac{2k\pi}{T}x)}dx)\sqrt{\frac{2}{T}}\cos{(\frac{2k\pi}{T}x)} +\\ \sum_{k=1}^{\infty}(\sqrt{\frac{2}{T}} \int_{-T/2}^{T/2}f(x)\sin{(\frac{2k\pi}{T}x)}dx)\sqrt{\frac{2}{T}}\sin{(\frac{2k\pi}{T}x)}$

If we regroup the $\sqrt{\frac{2}{T}}$ terms, we finally obtain the fourier series:

$$f(x) = c + \sum_{k=1}^{\infty} a_k\cos{(\frac{2k\pi}{T}x)} + \sum_{k=1}^{\infty} b_k\sin{(\frac{2k\pi}{T}x)}$$

$$c = \frac{1}{T}\int_{-T/2}^{T/2}f(x)dx$$

$$a_k = \frac{2}{T} \int_{-T/2}^{T/2}f(x)\cos{(\frac{2k\pi}{T}x)}dx$$

$$b_k = \frac{2}{T} \int_{-T/2}^{T/2}f(x)\sin{(\frac{2k\pi}{T}x)}dx$$

You will find the complete approach here:

https://xaviergerphagnon.com/2017/11/03/fourier-series/

https://xaviergerphagnon.com/2017/11/03/the-fourier-transform/