# Fourier series

## Period T0 stretched to infinity: envelope function

The Fourier series expects that the function $f(t)$ is periodic. What if we want to use Fourier series for a nonperiodic function? Either we can make such function periodic—but that is not always welcome—or we can make that function periodic with size of the period $T_0 \to \infty$. If we stretch the period $T_0$ to infinity, then periodic expression become nonperiodic.

So let us use Fourier series to represent periodic function and then observe what happens to Fourier series if we stretch its period $T_0$ to infinity.

Approximation of the square function by three terms of Fourier series ($n=3)$.
A—The square wave is of width 1, the period $T_0=2$
B—The square wave is of width 1, stretched to the period $T_0=4$
C—The square wave is of width 1, stretched to the period $T_0=8$

The three series depicted above use only the constant term $a_0/2$ and then first three terms $b_1,\ b_2,\ b_3$ for sine and $a_1,\ a_2,\ a_3$ for cosine functions. The coefficients for series were derived from integrals (not solved here) as:

\begin{align} f(t) &= \frac{a_0}{2} + \sum_{n=1}^{\infty} a_n\cos nt\frac{\pi}{p} + b_n\sin nt\frac{\pi}{p},\hskip2em p = T_0/2\nonumber \\ a_n &= \frac{1}{\pi n} \sin \frac{\pi n}{p}\nonumber \\ b_n &= -\frac{1}{\pi n}(\cos{\frac{\pi n}{p}} -1)\nonumber \\ \end{align}

and if we list some of the first terms:

\begin{align} f_2(t) &= \frac 1 2 \color{red}{+ 0.637 \sin \pi t} + 0.212 \sin 3 \pi t + 0.127 \sin 5 \pi t + \dots \label{ref:fourier_coef1} \\ f_4(t) &= \frac 1 4 \color{blue}{+ 0.318 \sin \frac{\pi t}{2}} \color{green}{+ 0.318 \cos \frac{\pi t}{2}} \color{red}{+ 0.318 \sin \frac{2 \pi t}{2}} + 0.106 \sin \frac{3 \pi t}{2} - 0.106 \cos \frac{3 \pi t}{2} + \dots \label{ref:fourier_coef2} \\ f_8(t) &= \frac 1 8 + 0.093 \sin \frac{\pi t}{4} + 0.225 \cos \frac{\pi t}{4} \color{blue}{+ 0.159 \sin \frac{2 \pi t}{4} } \color{green}{+ 0.159 \cos \frac{2 \pi t}{4}} + 0.181 \sin \frac{3 \pi t}{4} + \label{ref:fourier_coef3} \dots \end{align}

We can express and use more terms of these functions. The coefficient $a_n,\ b_n$ were evaluated to build the series and first one hundred of them are presented in graphs below. All the coefficients $a_n,\ b_n$ from $(\ref{ref:fourier_coef1})$ to $(\ref{ref:fourier_coef3})$ can be found in graphs below. It can be also read form the below graphs that the Fourier expansion of the above square wave function A ($T_0=2$) does not contain any cosine member $a_n\cos \omega_n t$:

First one hundred coefficients $a_1,\ a_2,\ \dots,\ a_{100}$ of cosines (on the left) and $b_1,\ b_2,\ \dots,\ b_{100}$ for sines (on the right).
Although it might be not obvious, there is a repeating pattern for $a_n$ and other pattern for $b_n$
1—The first row depicts coefficients $a_n,\ b_n$ for the square wave A of width 1 with the period $T_0=2$
2—The second row depicts coefficients $a_n,\ b_n$ for the square wave B of width 1 with period $T_0=4$
3—The third row depicts coefficients $a_n,\ b_n$ for the square wave C of width 1 with period $T_0=8$

Now let us show the same graphs again with slight difference. The domain of horizontal axis will not be $n$ (sequence of the coefficient) but it will be frequency $\omega_n$ associated with the coefficient $a_n$ or $b_n$. The vertical axis will be normalized as well: we will divide its values by $T_0/2$ ($T_0$ is the period of the given function).

Coefficients $a_n$ (left) and $\ b_n$ (right) for cosine and sine terms until $\omega=16\pi$.
The repeating pattern for both $a_n$ and $b_n$ is now obvious. The envelope is Fourier transform of function $\boldsymbol{x(t)}$ made periodic with period $\boldsymbol{T_0 = \infty}$
1—The first row depicts coefficients $a_n,\ b_n$ for the above square wave A of width 1 with the period $T_0=2$
2—The second row depicts coefficients $a_n,\ b_n$ for the above square wave B of width 1 with period $T_0=4$
3—The third row depicts coefficients $a_n,\ b_n$ for the above square wave C of width 1 with period $T_0=8$

It can be observed that: when the coefficients $a_n,\ b_n$ for a function $x(t)$ are drawn in domain of frequencies, they are closed by envelopes (one for sines, the other one for cosines). The envelope remains the same regardless the period of the given function. If we stretch the period to infinity, there will be no red bars for each coefficient, it becomes continuous, as the envelope is.

The opposite way is possible then: all the coefficients $a_n,\ b_n$ for Fourier series of a function can be read from the envelope (which is the Fourier transform of $x(t)$). Only need them to refactor considering the required period $T_0$.

## Fourier transform

Because Fourier series involves both sines and cosines, it is reasonable rather to work with Fourier series in terms of complex numbers instead of real numbers:

$$f(t) = \sum_{n=-\infty}^{\infty}c_ne^{i\omega_nt},\hskip2em \omega_n = n\frac{2\pi}{T_0}$$ In such approach the series operates with both positive and negative frequencies $\omega$. Euler established the relationship between the trigonometric functions and the complex exponential function: $e^{it} = \cos t + i\sin t$.

\begin{align} X(\omega) = \int_{-\infty}^{\infty}x(t)e^{-iwt}\ dt \label{ref:fourier_transform_eq} \end{align}

The envelope of coefficients is the Fourier transform $\boldsymbol{X(\omega)}$ of the function $\boldsymbol{x(t)}$. The function $x(t)$ is transformed into domain of frequencies, where it is defined as $X(\omega)$. The function is the same but its representation is different. Unlike in Laplace transform, Fourier transform is easily intepretable: transformed function $X(\omega)$ holds Fourier series' coefficients $c_n$ for frequencies $\omega_n$. It can be also seen how much of any given frequencies are present in $x(t)$.

Then particular coefficient for particular frequency $\omega_n$ and a periodicity $T_0$ is

\begin{align} c_n = \frac{X(\omega_n)}{T_0} \label{ref:fourier_coef4}. \end{align}

Since the Fourier transform holds representation of the given $f(t)$ in the domain of frequencies, then by means of the above formula for every $\omega_n$ the coefficient of the Fourier series can be asked to reconstruct function $x(t)$ (in term of the Fourier series—see the example below). Note that $c_n$ is a complex number. Conversion has to be done between real and complex numbers: $a_n=2\Re(c_n),\ b_n=-2\Im(c_n)$. The inverse Fourier transform is

$$x(t) = \frac{1}{2\pi}\int_{-\infty}^{\infty}X(\omega)e^{i\omega t}\ d\omega$$

Note: although not mentioned in the chapter Laplace transform, also inverse Laplace transform has integral similar to the above one as a way to evaluate inverse Laplace transform. Similarly to Laplace transform, if $X(\omega)$ is Fourier transform of $x(t)$, then we write

\begin{align} {\scr F}[x(t)] & = X(\omega) \nonumber \\ {\scr F}^{-1}[X(\omega)] &= x(t) \nonumber \end{align}

and transform can be also used to solve differential equations.

Now, when we have a definition and a tool $(\ref{ref:fourier_transform_eq})$ to transform a nonperiodic signal into frequency domain, we can make some example.

#### Example

Find a Fourier tranform of Dirac impulse function $\delta(t)$ (a unit impulse at $t=0$).

We will use definition $(\ref{ref:fourier_transform_eq})$ to transform given function into frequency domain:

$$X(\omega) = \int_{-\infty}^{\infty}x(t)e^{-iwt}\ dt = \int_{-\infty}^{\infty}\delta(t)e^{-iwt}\ dt$$

The value of $\delta(t)$ is zero everywhere except at $t=0$. And at $t=0$, when integrated, its area is one (from definition of Dirac delta function). Further, at the point $t=0$ the member $e^{-i\omega t}$ can be considered constant and taken out of the integral. Then $e^{-i\omega t} = e^{-i\omega\cdot 0} = 1$:

$$X(\omega) = e^{-i\omega\cdot 0} \int_{-\infty}^{\infty}\delta(t)\ dt = 1 \cdot 1 = 1$$

The result says that all the frequencies have the same coefficient. We can draw the impulse as a Fourier series. Let us choose for the purpose $T_0 = 2\pi$. The coefficient from $(\ref{ref:fourier_coef4})$ $c_n = 1/2\pi$ has real part only, so only cosine is involved with a coefficient $a_n = 2 \cdot \Re(c_n) = 1/\pi$.

$$f(t) = \frac 1{2\pi} + \sum\frac{1}{\pi}\cos \omega_nt = \frac 1 {2\pi}+\sum_{n=1}^{\infty} \frac{1}{\pi}\cos n\pi t$$

Let us draw how the impulse is represented by Fourier series if 5 and 10 terms are evaluated:

Dirac delta function $\delta(t)$ at $t=0$ expressed by cosines from Fourier transform in 5 and in 10 terms.

Note: there are many functions on $(-\infty,\infty)$, which do not posses a Fourier transform; e.g. $x(t) = t,\ x(t)=t^2,\ x(t)=e^t$.

List of chapters