# Engineering Analysis/Fourier Series

The L2 space is an infinite function space, and therefore a linear combination of any infinite set of orthogonal functions can be used to represent any single member of the L2 space. The decomposition of an L2 function in terms of an infinite basis set is a technique known as the Fourier Decomposition of the function, and produces a result called the Fourier Series.

## Fourier Basis

Let's consider a set of L2 functions, ${\displaystyle \phi }$ , as follows:

${\displaystyle \phi =\{1,\sin(\pi x),\cos(\pi x),\sin(2\pi x),\cos(2\pi x),\sin(3\pi x),\cos(3\pi x)...\}.\ }$

We can prove that over a range ${\displaystyle [0,2\pi ]}$ , all of these functions are orthogonal:

${\displaystyle \int _{0}^{2\pi }1\cdot \cos(n\pi x)dx=0}$
${\displaystyle \int _{0}^{2\pi }1\cdot \sin(n\pi x)dx=0}$
${\displaystyle \int _{0}^{2\pi }\sin(n\pi x)\sin(m\pi x)dx=0,n\neq m}$
${\displaystyle \int _{0}^{2\pi }\sin(n\pi x)\cos(m\pi x)dx=0}$
${\displaystyle \int _{0}^{2\pi }\cos(n\pi x)\cos(m\pi x)dx=0,n\neq m}$

Because ${\displaystyle \phi }$  is as an infinite orthogonal set in L2, ${\displaystyle \phi }$  is also a valid basis set in the L2 space. Therefore, we can decompose any function in L2 as the following sum:

[Classical Fourier Series]

${\displaystyle \psi (x)=a_{0}(1)+\sum _{n=1}^{\infty }a_{n}\sin(n\pi x)+\sum _{m=1}^{\infty }b_{m}\cos(m\pi x)}$

However, the difficulty occurs when we need to calculate the a and b coefficients. We will show the method to do this below:

## a0: The Constant Term

Calculation of a0 is the easiest, and therefore we will show how to calculate it first. We use the value of a0 which minimizes the error in approximating ${\displaystyle f(x)}$  by the Fourier series.

First, define an error function, E, that is equal to the squared norm of the difference between the function f(x) and the infinite sum above:

${\displaystyle E={\frac {1}{2}}\int _{0}^{2\pi }\|f(x)-a_{0}(1)-\sum _{n=1}^{\infty }a_{n}\sin(n\pi x)-\sum _{m=1}^{\infty }b_{m}\cos(m\pi x)\|^{2}dx}$

For ease, we will write all the basis functions as the set φ, described above:

${\displaystyle \sum _{i=0}^{\infty }a_{i}\phi _{i}=a_{0}+\sum _{n=1}^{\infty }a_{n}\sin(n\pi x)+\sum _{m=1}^{\infty }b_{m}\cos(m\pi x)}$

Combining the last two functions together, and writing the norm as an integral, we can say:

${\displaystyle E={\frac {1}{2}}\int _{0}^{2\pi }|\sum _{i=0}^{\infty }a_{i}\phi _{i}|^{2}dx}$

We attempt to minimize this error function with respect to the constant term. To do this, we differentiate both sides with respect to a0, and set the result to zero:

${\displaystyle 0={\frac {\partial E}{\partial a_{0}}}=\int _{0}^{2\pi }(f(x)-\sum _{i=0}^{\infty }a_{i}\phi _{i}(x))(-\phi _{0}(x))dx}$

The φ0 term comes out of the sum because of the chain rule: it is the only term in the entire sum dependent on a0. We can separate out the integral above as follows:

${\displaystyle \int _{0}^{2\pi }(f(x)-\sum _{i=0}^{\infty }a_{i}\phi _{i})(-\phi _{0})dx=-\int _{0}^{2\pi }f(x)\phi _{0}(x)dx+a_{0}\int _{0}^{2\pi }\phi _{0}(x)\phi _{0}(x)dx}$

All the other terms drop out of the infinite sum because they are all orthogonal to φ0. Again, we can rewrite the above equation in terms of the scalar product:

${\displaystyle 0=-\langle f(x),\phi _{0}(x)\rangle +a_{0}\langle \phi _{0}(x),\phi _{0}(x)\rangle }$

And solving for a0, we get our final result:

${\displaystyle a_{0}={\frac {\langle f(x),\phi _{0}(x)\rangle }{\langle \phi _{0}(x),\phi _{0}(x)\rangle }}}$

## Sin Coefficients

Using the above method, we can solve for the an coefficients of the sin terms:

${\displaystyle a_{n}={\frac {\langle f(x),\sin(n\pi x)\rangle }{\langle \sin(n\pi x),\sin(n\pi x)\rangle }}}$

## Cos Coefficients

Also using the above method, we can solve for the bn terms of the cos term.

${\displaystyle b_{n}={\frac {\langle f(x),\cos(n\pi x)\rangle }{\langle \cos(n\pi x),\cos(n\pi x)\rangle }}}$