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: .. math:: x(t) = e^{j \omega t} This funtion is periodic with period .. math:: T = \frac{2\pi}{\omega} 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 fundamental period is: .. math:: T_k = \frac{2\pi}{k\omega_0} = \frac{T_0}{k} Consider only the imaginary part of the complex exponential: .. math:: \sin(k \omega_0 t) = \sin\left(\frac{2 k \pi}{T_0} t\right) .. ipython:: python from matplotlib.pylab import * T0 = 10 t = linspace(0,T0,1000) for k in range(1,5): subplot(4,1,k) plot(t, sin(2*k*pi*t / T0)) @savefig sines.png show() 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$. For an **even signal**, i.e. $x(-t)=x(t)$ we have: .. math:: a_k \text{is real} For an **odd signal**, i.e. $x(-t)=-x(t)$ we have: .. math:: a_k \text{is imaginary} Fourier Series Examples ----------------------- Showing examples requires the calculation of integrals in order to get at the values of $a_k$ (the analysis equation). Most computer scientists are not that fond of integral calculations so we try to do it here using Sympy, a symbolic math package. .. ipython:: python import matplotlib.pylab as plt import sympy as sp t, T0 = sp.symbols("t, T0") x = sp.Piecewise( (1, t % T0<=T0/2), (0, True)) sp.plot(x.subs(T0,1), (t,-.2, 1.7), xlabel="t", ylabel="x(t)", line_width=3); @savefig sp_block.png plt.show() Next we define a function that calculates the $a_k$: .. ipython:: python import numpy as np def ak(k): return 1/1 * sp.integrate( x.subs(T0,1) * sp.exp(-1j * k * 2 * sp.pi / 1 * t), (t, 0, 1)) #%timeit print(sp.N(ak(0))) # swwitched off because it takes around 30 s on my machine... But this functions is very very slow... (probably due to the fact that the piecewise function makes integration hard when Sympy doesn't recognize the fact that it just has to integrate the exponential function over half the period. Using this knowledge expicitly we get: .. ipython:: python import numpy as np def ak(k): return 1/1 * sp.integrate( sp.exp(-1j * k * 2 * sp.pi / 1 * t), (t, 0, 1/2)) for k in range(-5,6): print(k, sp.N(ak(k))) # almost instantanuous .. admonition:: Plot the frequency components and their sum for several values of K (k=0,...,K) Properties II ------------- .. admonition:: RVDB Differentiation Convergence of the Fourier Series --------------------------------- .. admonition:: RVDB - difference between point wise and integral (??) convergence - Gibbs phenomenon