================================ Continuous Time Fourier Series ================================ The CT Fourier Series considers **periodic signals**. A signal $x(t)$ is periodic with period $T$ in case: .. math:: \forall t:\quad x(t+T) = x(t) Note that in case $x$ is periodic with period $T$ it is also periodic with period $2T$ (or $nT$). This leads us to the definition of the **fundamental period** ($T_0$) being the smallest value such that $x(t+T_0)=x(t).$ The **fundamental frequency** then is $f_0=1/T_0$. The Complex Exponential Functions ================================= We have already introduced the complex exponential functions $x(t) = e^{j \w t}$. This function is periodic with period $T = \frac{2\pi}{\w}$. If we fix $\omega$, say at value $\omega_0$ then the fundamental period is $T_0=2\pi/\omega_0$. The functions $x(t)=\exp(j k\omega_0 t)$ for integer $k>0$ then are all $T_0$ periodic, in fact the period for $\exp(j k\omega_0)$ is: .. math:: T_k = \frac{2\pi}{k\omega_0} = \frac{T_0}{k} Consider only the imaginary part of the complex exponential for illustration purposes: .. math:: \sin(k \omega_0 t) = \sin\left(\frac{2 k \pi}{T_0} t\right) for different values of $k>0$. We see that these sine functions fit exactly $k$ times in the interval of length $T_0$. .. exec_python:: harmonics CTP :linenumbers: :code: shutter :Code_label: Show code for figure :results: hide import numpy as np import matplotlib.pyplot as plt plt.clf() T0 = 10 t = np.linspace(0,T0,1000) K = 5 fig, axs = plt.subplots(nrows=K, sharex=True) for k in range(1,K+1): axs[k-1].plot(t, np.sin(2*k*np.pi*t / T0)) plt.savefig('source/figures/sines.png') .. figure:: /figures/sines.png :figwidth: 80% :align: center **Harmonics.** The sine function at fundamental frequence $\w_0$ and the harmonics at frequencies $2\w_0$, $3\w_0$, $4\w_0$ and $5\w_0$. The fundamental (lowest) frequency of the sinusoidal signal is $\omega_0$ and the frequencies $k\omega_0$ for $k>1$ are called the **harmonics**, $k=1$: first harmonic, etc. Why this set of periodic signals is so important has been discovered by Fourier and is the subject of the next subsection. The Fourier Series ================== Fourier (a French mathematician) showed that nearly every periodic function (with period $T_0$) can be written as a linear combination (superposition) of the complex exponential functions $\exp(j k \omega_0 t)$ for $k=0,1,2,\cdots$ where $\omega_0 = 2\pi / T_0$: .. math:: x(t) = \sum_{k=-\infty}^{\infty} a_k e^{ j k \omega_0 t} Note that the coefficients determining the weight of every frequency $k\omega_0$ in general are complex valued. As an example consider the periodic function $x(t)$ with period $T_0$: .. math:: x(t) = \begin{cases} 1 &: 0\leq t 0$. Even Signal ~~~~~~~~~~~ For an **even signal**, i.e. $x(-t)=x(t)$ we have: .. math:: a_k \text{is real} The proof is not to difficult. We start with the definition .. math:: a_k = \frac{1}{T_0} \int_{\langle T_0 \rangle} x(t) e^{-j k \omega_0 t} dt If we make a choice for the interval $t\in[-T_0/2, T_0/2]$ we get .. math:: a_k &= \frac{1}{T_0} \int_{t=-T_0/2}^{T_0/2} x(t) e^{-j k \omega_0 t} dt\\ &= \frac{1}{T_0} \int_{t=0}^{T_0/2} (x(t)+x(-t)) e^{-j k \omega_0 t} dt\\ &= Odd Signal ~~~~~~~~~~ For an **odd signal**, i.e. $x(-t)=-x(t)$ we have: .. math:: a_k \text{is imaginary} Differentiation ~~~~~~~~~~~~~~~ Consider a periodic CT signal $x(t)$ and its corresponding Fourier series coefficients $a_k$. We have that derivate signal $x'(t)$ has Fourier series coefficients $jk\omega_0 a_k$. This is really easy to prove: .. math:: x(t) = \sum_k a_k e^{j k \omega_0 t} and thus differentiating both sides leads to .. math:: x'(t) &= \sum_k a_k \frac{d}{dt} e^{j k \omega_0 t} \\ &= \sum_k a_k\, j k \omega_0 \, e^{j k \omega_0 t} Let $x^{(n)}$ denote the $n$-th order derivative of $x$ then the Fourier series coefficients of $x^{(n)}$ are equal to $(jk \omega_0)^n \, a_k$. Convolution ~~~~~~~~~~~ Let $x$ be a CT periodic signal with period $T_0$. Then convince yourself that the convolution $x\ast y$ on the infinite domain for any function $y$ is periodic too. Relating this convolution to the Fourier series is hard (i think...), most often we restrict the analysis of convolutions to functions $y$ that are $T_0$-periodic as well. In this case the convolution is defined as: .. math:: (x \ast_{T_0} y)(t) = \int_{\langle T_0 \rangle} x(u)y(t-u) du i.e. it is restricted to one period of length $T_0$. Let $a_k$ be the Fourier coefficients of $x$ and $b_k$ be the coefficients for $y$ then the coefficients for $x\ast_{T_0} y$ are $T_0 a_k b_k$. The proof is not too complicated. It is a nice way to exercise your integration skills (see https://math.stackexchange.com/questions/97328/f-g-continuous-and-periodic-functions-with-1-prove-periodic-widehat-fg?rq=1) Fourier Series Examples ~~~~~~~~~~~~~~~~~~~~~~~ Block Wave Function +++++++++++++++++++ We start with the simple block wave function that we have allready seen in the beginning of this section: .. math:: x(t) = \begin{cases} 1 &: 0\leq t 0.5], [lambda t: -1/8+1/2*t, lambda t: 3/8 - 1/2*t]) plt.plot(t,x) plt.savefig('source/figures/trianglesignal.png') .. figure:: /figures/trianglesignal.png :width: 50% :align: center **Triangular signal.** Observe that the derivative $x'(t)$ of $x(t)$ is the block function that we have discussed in the first exercise (except that for $x'(t)$ we have $a_0=0$ (you should be able to conclude that without calculation). For all other Fourier coefficients we have (according to the derivative rule): .. math:: a'_k = jk\w_0 a_k where the $a'_k$'s are the Fourier coefficients of the derivative signal. The derivative is the familiar block function with Fourier coefficients: .. math:: a'_k = \begin{cases} 0 &: k \text{ is even, including }0\\ \frac{1}{j k \pi} &: k \text{ is odd} \end{cases} So for the triangular signal we have: .. math:: a_k = \frac{a'_k}{j k \w_0} = \frac{T_0}{j k 2\pi} a'_k = \frac{1}{j k 2\pi} a'_k leading to: .. math:: a_k = \begin{cases} 0 &: k \text{ is even, including }0\\ \frac{-1}{2 k^2 \pi^2} &: k \text{ is odd} \end{cases} Using the synthesis equation we can applximately reconstruct the triangle signal using a few of the harmonics. .. exec_python:: triangleharmonics CTP :linenumbers: :code: shutter :Code_label: Show code for figure :results: hide plt.clf() def ak(k): if k%2 == 0: return 0 return -1/(2 * k**2 * np.pi**2) def phi(t,k): return ak(k) * np.exp(1j * k * 2 * np.pi * t) def Phi(t,k): r = np.zeros_like(t, dtype=complex) for i in range(-k, k+1): r += phi(t,i) return r.real plt.subplot(3,1,1) plt.plot(t, x) plt.plot(t, Phi(t,1)) plt.subplot(3,1,2) plt.plot(t, x) plt.plot(t, Phi(t,3)) plt.subplot(3,1,3) plt.plot(t, x) plt.plot(t, Phi(t,5)) plt.savefig('source/figures/trianglesignalharmonics.png') .. figure:: /figures/trianglesignalharmonics.png :width: 80% :align: center **Triangle wave signal and its harmonics.** In blue the triangular signal in red the reconstruction using a few harmonics. Top row: $|k|\leq1$, middle row: $|k|\leq3$ and bottom: $|k|\leq5$. .. Convergence of the Fourier Series --------------------------------- .. admonition:: RVDB - difference between point wise and integral (??) convergence - Gibbs phenomenon Exercises ========= #. Parabolic Function Consider the function $x(t)$ defined on the interval from 0 to 1 (and periodically continuated) .. math:: x(t) = t^2 #. Calculate the Fourier coefficients $a_k$. The use of Mathematica or Wolfram alpha or Maple or ... is allowed here. #. Plot both $|a_k|$ and $\angle(a_k)$ as a function of $k$. #. Frequency and Period For each of the following functions calculate radial frequenct $\w$ and the period $T$ #. $\sin(t)$ #. $\cos(3t)$ #. $\sin(\half t)$ #. $\sin(\pi/3 t)$ #. $\sin(0.4 t)$ #. Fundamental Frequency and Period Below several functions of the form $x(t)=x_1(t)+x_2(t)$ are given. For each of them calculate the frequency $\w_1$ and period $T_1$ of $x_1$, the same for $x_2(t)$ and the same 1.or $x(t)=x_1(t)+x_2(t)$ #. $x_1(t) = \sin(t),\quad x_2(t)=2\cos(t)$ #. $x_1(t) = \sin(t), \quad x_2(t) = \cos(t + \pi)$ #. $x_1(t) = \sin(2t), \quad x_2(t) = 0.5 \cos(3t)$ #. $x_1(t) = \sin(0.5t), \quad x_2(t) = 2 \sin(3t)$ #. $x_1(t) = \sin(6t), \quad x_2(t) = \cos(10t)$ #. $x_1(t) = \sin(8t), \quad x_2(t) = 2\sin(12t)$ #. $x_1(t) = \sin(66t), \quad x_2(t) = \cos(77t)$ #. $x_1(t) = \sin(0.3t), \quad x_2(t) = 0.5\cos(4t)$ #. $x_1(t) = \sin(t), \quad x_2(t) = \sin(3\pi t)$ #. Periodic Signal Given the following periodic signal $x(t)=\sum_{k=-3}^{3} a_k e^{j k t}$ with $a_0=1, a_{\pm 1} = 1/4, a_{\pm 2}=1/2, a_{\pm 3}=1/3$ #. What is the period $T$ and fundamental frequency $\w$. #. Write $x(t)$ as a sum of sinusoids. #. Periodic Block Signal Given the periodic function $x(t)$ for one period: .. math:: x(t) = \begin{cases} 1 &: -\frac{\pi}{2}\leq t < \frac{\pi}{2}\\ 0 &: \frac{\pi}{2} \leq t < \frac{7 \pi}{2} \end{cases} #. What is the period and fundamental frequency? #. Calculate $a_k$ for all $k\in\setZ$. #. Plot the amplitude spectrum (i.e. $|a_k|$ as function of $k$). #. Why are all $a_k$ real?