# The Fourier Series

## Continuous Time

{% hint style="info" %}
#### Definition 19

A function $$x(t)$$ is periodic if $$\exists T$$ such that $$\forall t, x(t-T)=x(t)$$.
{% endhint %}

{% hint style="info" %}
#### Definition 20

The fundamental period is the smallest such $$T$$ which satisfies the periodicity property in Definition 19
{% endhint %}

{% hint style="info" %}
#### Theorem 1

If $$x(t)$$ and $$y(t)$$ are functions with period $$T_1$$ and $$T_2$$ respectively, then $$x(t)+y(t)$$ is periodic if $$\exists m, n \in \mathbb{Z}$$ such that $$mT_1 = nT_2$$.
{% endhint %}

{% hint style="info" %}
#### Definition 21

Given a periodic function $$x(t)$$ with fundamental period $$T$$ and fundamental frequency $$\omega_0=\frac{2\pi}{T}$$, the Fourier Series of $$x$$ is a weighted sum of the harmonic functions.

$$x(t) = \sum_{k=-\infty}^{\infty}{a_ke^{jk\omega_0t}}$$
{% endhint %}

To find the coefficients $$a_k$$:

$$\begin{aligned} x(t) \cdot e^{-jn\omega_0t} &= \sum_{k=-\infty}^{\infty}{a_ke^{j\omega_0t(k-n)}}\\ \int_{T}{x(t) \cdot e^{-jn\omega_0t}dt} &= \sum_{k=-\infty}^{\infty}{a_k\int_{T}{e^{j\omega_0t(k-n)}}dt}\\ &= \begin{cases} Ta_k & \text{if } $k=n$,\\ 0 & \text{else } \end{cases}\end{aligned}$$

Rearranging this, we can see that

$$a_n = \frac{1}{T}\int_{T}{x(t)e^{-jn\omega_0t}dt}.$$

For $$a_0$$, the DC offset term, this formula makes a lot of sense because it is just the average value of the function over one period.

$$a_0 = \frac{1}{T}\int_{T}{x(t)dt}$$

Because the Fourier Series is an infinite sum, there is a worry that for some functions $$x(t)$$, it will not converge. The **Dirichlet Convergent Requirements** tell us when the Fourier Series converges. More specificially, they tell us when

$$\forall \tau, \ \lim_{M \rightarrow \infty}{x_M(\tau) = x(\tau)} \qquad x_M(t) = \sum_{k=-M}^{M}{a_k e^{jk\omega_0t}}$$

will converge.

{% hint style="info" %}
#### Theorem 2

The Fourier Series of a continuous time periodic function $$x(t)$$ will converge when $$x$$ is piecewise continuous and $$\frac{d}{dt}x$$is piecewise continuous.
{% endhint %}

* If $$x$$ is continuous at $$\tau$$, $$\lim_{M \rightarrow \infty}x_M(\tau) = x(\tau)$$
* If $$x$$ is discontinuous at $$\tau$$, then $$\lim_{M\rightarrow \infty}x_M(\tau) = \frac{1}{2}(x(\tau^-) + x(\tau^+))$$

These convergence requirements are for pointwise convergence only. They do not necessarily imply that the graphs of the Fourier Series and the original function will look the same.

## Discrete Time

The definition for periodicity in discrete time is the exact same as the definition in continuous time.

{% hint style="info" %}
#### Definition 22

A function $$x[n]$$ is periodic with period $$N \in \mathbb{Z}$$ if $$\forall n, x[n+N]=x[n]$$
{% endhint %}

However, there are some differences. For example, $$x[n] = cos(\omega_0 n)$$ is only periodic in discrete time if $$\exists N, M \in \mathbb{Z}, \omega_0 N = 2 \pi M$$.

{% hint style="info" %}
#### Theorem 3

The sum of two discrete periodic signals is periodic
{% endhint %}

Theorem 3 is not always true in continuous time but it is in discrete time.

The Fourier Series in discrete time is the same idea as the Fourier series in continuous time: to express every signal as a linear combination of complex exponentials. The discrete time basis that we use are the Nth roots of unity.

$$\phi_k[n] = e^{jk\frac{2\pi}{N}n}$$

* $$\phi_k[n]$$ is perioidic in n (i.e $$\phi_k[n+N] = \phi_k[n]$$)
* $$\phi_k[n]$$ is periodic in k (i.e $$\phi_{k+N}[n] = \phi_k[n]$$)
* $$\phi_k[n]\cdot \phi_m[n] = \phi_{k + m}[n]$$

Notice that with this basis, there are only N unique functions that we can use. An additional property of the $$\phi_k[n]$$ is that

$$\sum_{n=<N>}{\phi_k[n]} = \begin{cases} N & \text{if } k = 0, \pm N, \pm 2N, \cdots\\ 0 & \text{otherwise.} \end{cases}$$

{% hint style="info" %}
#### Definition 23

Given a periodic discrete-time function $$x[n]$$ with period $$N$$, the Fourier series of the function is a weighted sum of the roots of unity basis functions.

$$x[n] = \sum_{k=0}^{N-1}{a_k\phi_k[n]}$$
{% endhint %}

In order to find the values of $$a_k$$, we can perform a similar process as in continuous time.

$$\begin{aligned} x[n] &= \sum_{k=0}^{N-1}{a_k\phi_k[n]}\\ x[n]\phi_{-M}[n] &= \sum_{k=0}^{N-1}{a_k\phi_k[n]\phi_{-M}[n]}\\ \sum_{n=<N>}{x[n]\phi_{-M}[n]} &= \sum_{n=<N>}{\sum_{k=<N>}{a_k\phi_{k-M}[n]}} = \sum_{k=<N>}{a_k\sum_{n=<N>}{\phi_{k-M}[n]}}\\ \sum_{n=<N>}{x[n]\phi_{-M}[n]} &= a_MN\\ a_M &= \frac{1}{N}\sum_{n=<N>}{x[n]\phi_{-M}[n]}\end{aligned}$$

## Properties of the Fourier Series

**Linearity:** If $$a_k$$ and $$b_k$$ are the coefficients of the Fourier Series of $$x(t)$$ and $$y(t)$$ respectively, then $$Aa_k + Bb_k$$ are the coefficients of the Fourier series of $$Ax(t)+By(t)$$

**Time Shift:** If $$a_k$$ are the coefficients of the Fourier Series of $$x(t)$$, then $$b_k = e^{-jk\frac{2\pi}{T}t_0}a_k$$ are the coefficients of the Fourier Series of $$\hat{x}(t)=x(t-t_0)$$

**Time Reversal:** If $$a_k$$ are the coefficients of the Fourier Series of $$x(t)$$, then $$b_k=a_{-k}$$ are the coefficients of the Fourier Series of $$x(-t)$$

**Conjugate Symmetry:** If $$a_k$$ are the coefficients of the Fourier Series of $$x(t)$$, then $$a_k^*$$ are the coefficients of the Fourier Series of $$x^*(t)$$. This means that $$x(t)$$ is a real valued signal, then $$a_k=a_{-k}^*$$

{% hint style="info" %}
#### Theorem 4 (Parseval's Theorem) <a href="#theorem-4" id="theorem-4"></a>

$$\textbf{Continuous Time: } \frac{1}{T}\int{|x(t)|^2dt} = \sum_{k=-\infty}^{\infty}{|a_k|^2}$$

$$\textbf{Discrete Time: } \frac{1}{N}\sum_{n=<N>}{|x[n]|^2} = \sum_{k=<N>}{|a_k|^2}$$
{% endhint %}

## Interpreting the Fourier Series

A good way to interpret the Fourier Series is as a change of basis. In both the continuous and discrete case, we are projecting our signal $$x$$ onto a set of basis functions, and the coefficients $$a_k$$ are the coordinates of our signal in the new space.

### Discrete Time

Since in discrete time, signal is peroidic in $$N$$, we can turn any it into a vector $$\vec{x}\in \mathbb{C}^N$$.

$$\vec{x} = \left[ \begin{array}{c} x[0]\\ x[1]\\ \vdots\\ x[N-1] \end{array} \right] \in \mathbb{C}^N$$

We can use this to show that $$\phi_k$$ form an orthogonal basis. If we take two of them $$\phi_k[n]$$ and $$\phi_M[n]$$ ($$k\ne M$$) and compute their dot product of their vector forms, then

$$\phi_k[n] \cdot \phi_M[n] = \phi_M^*\phi_k = \sum_{<n>}{\phi_{k-M}[n]} = 0$$

That means that $$\phi_k$$ and $$\phi_M$$ are orthogonal, and they are $$N$$ of them, therefore they are a basis. If we compute their magnitudes, we see

$$\phi_k \cdot \phi_k = ||\phi_k||^2 = N, \therefore ||\phi_k|| = \sqrt{N}$$

Finally, if we compute $$\vec{x}\phi_M$$ where $$\vec{x}$$ is the vector form of an N-periodic signal,

$$\vec{x}\cdot \vec{\phi_M} = \left(\sum_{i=0}^{N-1}{a_i\phi_i}\right)\cdot \phi_M = Na_m$$

$$a_m = \frac{1}{N}\vec{x}\cdot \phi_M$$

This is exactly the equation we use for finding the Fourier Series coefficients, and notice that it is a projection since $$N = ||\phi_m||^2$$. This gives a nice geometric intution for Parseval’s theorem

$$\frac{1}{N}\sum{|x[n]|^2} = \frac{1}{N}||\vec{x}||^2 = \sum{|a_k|^2}$$

because we know the norms of two vectors in different bases must be equal.

### Continuous Time

In continuous time, our bases functions are $$\phi_k(t) = e^{jk\frac{2\pi}{T}t}$$ for $$k \in (-\infty, \infty)$$ Since we can’t convert continuous functions into vectors, these $$\phi_k$$ are really a basis for the vector space of square integrable functions on the interval $$[0, T]$$. The inner product for this vector space is

$$<x, y> = \int_{0}^{T}{x(t)y^*(t)}.$$

We can use this inner product to conduct the same proof as we did in discrete time.
