Fourier serier

Approximation of the square function by Fourier series

Fourier series is a way to represent a function as a combination of simple sine waves. More formally, it decomposes any periodic function or periodic signal into a sum of a (possibly infinite) set of simple oscillating functions, namely sines and cosines. Fourier series does not try to approximate given function around interested point but approximates the whole interval.

With Fourier series, any function, which is periodic on $2\pi$, can be expressed as

$$ \begin{equation} f(t) = \frac{a_0}{2} + \sum_{n=1}^{\infty} a_n\cos nt + b_n\sin nt. \label{ref:fourier_basic} \end{equation} $$

Fourier series for solving DE

Suppose, that the input function of DE is $\sin nt$. Then we are able to calculate response $y(t)$. Fourier series is useful tool to solve linear DE (e.g. $y'' + a_1y' +a_0y = f(t)$). If the solution can be expressed for one sine, then, because of linearity and superposition, the method is applicable also for Fourier series. The advantage is there are no restrictions for the function $\boldsymbol{f(t)}$ on the right side. Recall the other methods which have limitation of the nonhomogeneous member: they have to be expressed in terms as $e^t,\ \sin t$ and so on.

We want to calculate Fourier series for a given function $x(t)$, which is periodic on $2\pi$.

Orthogonality of functions

In order to derive formula expressing coefficients $a_n,\ b_n$ in $(\ref{ref:fourier_basic})$ we have to be familiar with orthogonality of functions.

Two functions are orthogonal on an interval $[a,b]$ if their inner product is zero:

$$ \int_a^b f_1(t)f_2(t)\ dt = 0 $$

The set of functions $\boldsymbol{\{f_0(t), f_1(t), \dots\}}$ is orthogonal on an interval $[a,b]$ if

$$ \int_a^b f_m(t)f_n(t)\ dt = 0 \hskip1em \text{for each}\ m \neq n $$

Orthogonal has meaning similar to perpendicular, however we do not use such term. In this chapter we are more interested into orthogonality of sines and cosines on interval $[-\pi,\pi]$. It can be shown, that if we have a set of functions $S$

$$ \begin{align} S= \hskip1em \left\{ \begin{aligned} \cos nt &\hskip2em n=0,1, \dots , \infty \\ \sin mt &\hskip2em m=1,2, \dots, \infty, \end{aligned} \right.\nonumber \end{align} $$

then any distinct combination from the set is orthogonal (their inner product is zero) on $[-\pi,\pi]$. Only

$$ \left. \begin{aligned} \int_{-\pi}^{\pi}\sin^2nt\ dt& \\ \int_{-\pi}^{\pi}\cos^2nt\ dt& \end{aligned} \right\} = \pi $$
To illustrate the orthogonality of the functions mentioned. It should be obvious, that the inner product in both above examples is zero ($\int_{-\pi}^{\pi}\sin t\ \cos t\ dt = 0$, $\int_{-\pi}^{\pi}\sin t\ \sin 2t\ dt = 0$).

So now we have a task to find values of coefficients $a_n, b_n$ for a given function $f(t)$ of $2\pi$ period. Let us find $a_n$ for cosines, because $b_n$ is the same logic.

$$ f(t) = \dots + a_k\cos kt + \dots + a_n\cos nt + \dots $$

In the above expression $a_n\cos nt$ is the term which we are studying—we want to determine $a_n$. The other term is just some other term. Now let us multiply each member by $\cos nt$.

$$ \cos nt\ f(t) = \dots + a_k\cos kt\cdot \cos nt + \dots + a_n \cos^2 nt + \dots $$

And finally let us integrate on interval $[-\pi, \pi]$:

$$ \int_{-\pi}^{\pi}\cos nt\ f(t) \ dt= \dots + \int_{-\pi}^{\pi}a_k\cos kt\cdot \cos nt \ dt+ \dots + \int_{-\pi}^{\pi}a_n \cos^2 nt \ dt+ \dots $$

Because of orthogonality all some other members are zero, so we can express $a_n$

$$ \begin{align} a_n &= \frac 1 \pi \int_{-\pi}^{\pi} f(t)\cos nt\ dt \label{ref:fourier_basic_an}\\ b_n &= \frac 1 \pi \int_{-\pi}^{\pi} f(t)\sin nt\ dt \label{ref:fourier_basic_bn}\\ \end{align} $$

Tools helpful to shorten the calculations

Function is odd or even

If the function is odd or even, there are only sines or cosines within series.

Function is even: Fourier series consists only of cosine terms, all $b_n$ are zero.
Function is odd: Fourier series consists only of sine terms, all $a_n$ are zero.

If function is odd or even, it is better to integrate on half-interval $[0,\pi]$ instead of $[\pi,\pi]$ and double the result. In the case of cosine it is obvious why we can use the double result of integral $\int_0^{\pi}$. In the case of sine, both sine and function $f(t)$ are either positive or negative, so the result has to be positive also.

Convergence of Fourier series

The series converges to $f(t)$ except the points where the function is not continuous. If there is a discontinuity at $t_0$, the series converges to the midpoint.

Fourier series converges to $f(t)$ except the points of discontinuity. In such points it converts to the middle.

Extensions

Period other than $\boldsymbol{2\pi}$

It would be not much useful if we could work only with functions with period of $2\pi$. Instead of half-period $\pi$ we will have $p$ (the period is $2p$). Instead of $\cos nt$ we have $\cos nt \frac{\pi}{p}$ and for the series

$$ \begin{equation} \color{red}{f(t) = \frac{a_0}{2} + \sum_{n=1}^{\infty} a_n\cos nt \frac{\pi}{p} + b_n\sin nt\frac{\pi}{p}}. \label{ref:fourier_basic1} \end{equation} $$

the rules to express coefficients are

$$ \begin{align} \color{red}{a_n = \frac 1 p \int_{-p}^{p} x(t)\cos nt\frac{\pi}{p}\ dt} \\ \color{red}{b_n = \frac 1 p \int_{-p}^{p} x(t)\sin nt\frac{\pi}{p}\ dt} \\ \end{align} $$

Given function is not periodic

Even if the function is defined on interval $(0,p)$, but is not periodic, we can use Fourier series. The function can be extended either to an odd or even function.

Example

Find the Fourier series of square $2\pi$ periodic wave defined on interval $[-\pi,\pi]$ as

$$ x(t) = \left\{ \begin{aligned} 0\hskip2em & -\pi \lt t \leq 0, \\ 1\hskip2em & 0 \lt t \leq \pi. \\ \end{aligned} \right. $$

See also red line on the below graph.

We have a case with a period of $2\pi$. In order to collect serier $(\ref{ref:fourier_basic})$ we have to evaluate $a_0,\ a_n,\ b_n$. It can be observed from the graph of given periodic function that $a_0 = 1$, because the first term of series (mean, average) has to be $a_0/2 = 0.5$. Then it is clear that the given function is odd.

If the function is odd, all $a_n$ associated with cosines remain zero, the cosine members are inactive, cosines are not helpful in describing the function. We can use integral $(\ref{ref:fourier_basic_an})$ to express coefficients anyway, but it will be wasting the effort since the outcame is given to be zero.

So let us do the math for $b_n$ and also for $a_0$:

$$ \begin{align} a_0 &= \frac 1 \pi \int_0^{\pi}1\cdot dt = \frac 1 \pi \left[ t\right]_0^{\pi} = \frac {\pi} {\pi} = 1 \nonumber \\ b_n &= \frac 1 {\pi} \int_{-\pi}^{\pi} x(t)\sin nt \ dt = \frac 1 {\pi} \int_0^{\pi}1\cdot \sin nt\, dt = \frac 1 {\pi}\left[-\frac{1}{n} \cos nt\right]_0^{\pi} = \nonumber \\ &= -\frac {1}{\pi n} \left[\cos nt\right]_0^{\pi} = \frac{-1}{\pi n} (\cos n\pi - \cos 0) = \frac{1-\cos n\pi}{\pi n} = \frac{1-(-1)^n}{\pi n}\nonumber \end{align} $$

Since $n=1,2,3,\dots$, the term $\cos n\pi$ could be simplified as the below table suggest to $(-1)^n$.

n0123
$\boldsymbol{\cos n\pi}$1-11-1

The coefficients are ready so the Fourier series can be evaluated from $(\ref{ref:fourier_basic})$:

$$ \begin{align} &\underline{\underline{x(t) = \frac{1}{2} + \sum_{n=1}^{\infty}\frac{1-(-1)^n}{\pi n} \sin nt = \frac{1}{2} + \sum_{n=1}^{\text{odd}}\frac{2\sin nt}{\pi n} }} \nonumber \\ n=0:\hskip2em &f(t) = \frac {a_0}{2} = \frac 1 2 \nonumber \\ n=1:\hskip2em &f(t) =\frac 1 2 + \frac{1+1}{\pi}\sin t\nonumber \\ n=2:\hskip2em &f(t) =\frac 1 2 + \frac{2}{\pi}\sin t + 0\nonumber \\ n=3:\hskip2em &f(t) =\frac 1 2 + \frac{2}{\pi}\sin t + 0 + \frac{2}{3\pi}\sin 3t\nonumber \\ n=4:\hskip2em &f(t) =\frac 1 2 + \frac{2}{\pi}\sin t + 0 + \frac{2}{3\pi}\sin 3t + 0\nonumber \\ n=5:\hskip2em &f(t) =\frac 1 2 + \frac{2}{\pi}\sin t + 0 + \frac{2}{3\pi}\sin 3t + 0 + \frac{2}{5\pi}\sin 5t\nonumber \\ \end{align} $$
The given function is a square function in red color.
The function labeled with $n=0$ includes only the zeroest term $a_0/2$.
The function labeled with $n=1$ includes $a_0/2$ and the first member.
The function labeled with $n=3$ includes $a_0/2$ and the first three members.
The function labeled with $n=5$ includes $a_0/2$ and the first five members.

Example

Find the Fourier series of function $x(t)=t^2$ periodic on interval $(-\pi,\pi)$

The given function is depicted in red within the below graph.

The function is symetric so it is going to consist of cosine terms, all $b_n=0$. We are going to use integration by parts $\int u'v = uv-\int uv'$ to evaluate $a_n$.

$$ \begin{align} a_0 &= \frac 1 {\pi} \int_{-\pi}^{\pi}1\cdot t^2\ dt = \frac 2 {\pi} \int_{0}^{\pi}t^2\ dt = \frac 2 {\pi}\left[\frac{t^3}{3}\right]_{t=0}^{\pi} = \frac 2{\pi}\cdot \frac{\pi^3}{3} = \frac 2 3 \pi^2 \nonumber \\ a_n &= \frac 1 {\pi} \int_{-\pi}^{\pi} \cos nt\ t^2\ dt = \frac 2 {\pi} \int_{0}^{\pi} \cos nt\ t^2\ dt = \begin{vmatrix} u' = \cos nt & u = \frac 1 n \sin nt \\ v = t^2 & v'=2t \end{vmatrix} = \nonumber \\ &= \left[\frac 2 {\pi}\left(\frac 1 n\sin nt\ t^2\right)\right]_{t=0}^{\pi} - \frac 2 {\pi}\int_0^{\pi}\frac 1 n \sin nt\cdot 2t\ dt = \nonumber \\ &= \frac{2}{n\pi}(\sin n\pi\ \pi^2 - 0) - \frac{4}{n\pi}\int_{0}^{\pi}\sin nt \cdot t \ dt = \begin{vmatrix} u' = \sin nt & u = -\frac 1 n \cos nt \\ v = t & v' = 1 \end{vmatrix} = \nonumber \\ &= 0 - \frac 4 {n\pi}\left(\left[ -t\frac{1}{n} \cos nt\right]_0^{\pi} - \int_0^{\pi}-\frac{1}n \cos nt\ dt \right) = \nonumber \\ &= -\frac{4}{\pi}\left((-\pi \frac 1 n\cos n\pi -0) + \frac 1 n\left[ \frac 1 n \sin nt\right]_0^{\pi}\right) = -\frac{4}{n\pi}(-\pi \frac 1 n\cos n\pi) = \frac 4 {n^2}\cos n\pi = \nonumber \\ &= \frac 4 {n^2}(-1)^n \nonumber \end{align} $$

Since $n=1,2,3,\dots$, the term $\cos n\pi$ could be simplified as the below table suggest to $(-1)^n$.

n 0 1 2 3
$\boldsymbol{\cos n\pi}$ 1 -1 1 -1

The coefficients are ready so the Fourier series can be evaluated from $(\ref{ref:fourier_basic})$:

$$ \underline{\underline{f(t) = \frac{1}{3}\pi^2 +\sum_{n=1}^{\infty}\frac{4}{n^2}(-1)^n\cos nt}} \nonumber \\ $$
The given function is periodic $t^2$ function in red color.
The function labeled with $n=0$ includes only the zeroest term $a_0/2$.
The function labeled with $n=1$ includes $a_0/2$ and the first member.
The function labeled with $n=2$ includes $a_0/2$ and the first two members.
The function labeled with $n=3$ includes $a_0/2$ and the first three members.

List of chapters