# 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.
