Lecture 3 · Digital Signal Processing · University of Klagenfurt, 2022
Lecture 3 of 6
From Digital Signal Processing at the University of Klagenfurt, first taught in 2020: this is the edition of summer 2022, so some of it may be a little dated. All lectures.
01
Any periodic signal can be decomposed into sine and cosine components:
x(t)=\frac{A_0}{2}+\sum_{k=1}^{+\infty}A_k\cos(2\pi kf_0t)+B_k\sin(2\pi kf_0t)
where f_0=\frac{1}{T_0} is the fundamental frequency of x(t), and the Fourier coefficients are
A_k=\frac{2}{T_0}\int_{-T_0/2}^{T_0/2}x(t)\cos(2\pi kf_0t)\,dt,\qquad B_k=\frac{2}{T_0}\int_{-T_0/2}^{T_0/2}x(t)\sin(2\pi kf_0t)\,dt
The Fourier series decomposes a signal x(t) into harmonics, at the multiples kf_0 of the fundamental frequency.
The coefficients say how much of each harmonic the signal contains. A sawtooth has a jump every period, and its coefficients decay slowly, as 1/k:
Parseval’s theorem relates the energy of the signal in a period to the energy of its Fourier coefficients:
\frac{2}{T_0}\int_{-T_0/2}^{T_0/2}|x(t)|^2\,dt=\frac{A_0^2}{2}+\sum_{k=1}^{+\infty}\left(A_k^2+B_k^2\right)
Multiply the series by \cos(2\pi mf_0t), with m\ge1, and integrate over one period. The constant and all the sines integrate to zero, and the cosines are orthogonal:
\int_{-T_0/2}^{T_0/2}\cos(2\pi kf_0t)\cos(2\pi mf_0t)\,dt=\frac{T_0}{2}\,\delta_{k,m},\qquad \delta_{k,m}=\begin{cases}1&k=m\\0&k\neq m\end{cases}
so only the term k=m survives:
\int_{-T_0/2}^{T_0/2}x(t)\cos(2\pi mf_0t)\,dt=A_m\,\frac{T_0}{2}\quad\Longrightarrow\quad A_m=\frac{2}{T_0}\int_{-T_0/2}^{T_0/2}x(t)\cos(2\pi mf_0t)\,dt
The same with \sin(2\pi mf_0t) gives B_m; integrating x(t) directly gives A_0, which is why the constant term is written \frac{A_0}{2}.
Calculate the Fourier series of
1. T_0=2, f_0=\frac12; even, so B_k=0:
A_0=\int_{-1/2}^{1/2}1\,dt=1,\qquad A_k=\int_{-1/2}^{1/2}\cos(\pi kt)\,dt=\frac{2\sin(\pi k/2)}{\pi k}=\mathrm{sinc}\left(\frac k2\right),\qquad x(t)=\frac12+\sum_{k=1}^{\infty}\mathrm{sinc}\left(\frac k2\right)\cos(\pi kt)
2. Odd, so A_k=0; by parts,
B_k=2\int_0^1t\sin(\pi kt)\,dt=-\frac{2\cos(\pi k)}{\pi k}+0=\frac{2(-1)^{k+1}}{\pi k},\qquad x(t)=\sum_{k=1}^{\infty}\frac{2(-1)^{k+1}}{\pi k}\sin(\pi kt)
At t=\frac12, \sin\frac{\pi k}{2}=1,0,-1,0,\dots, so
\frac12=\frac2\pi\left(1-\frac13+\frac15-\frac17+\dots\right)\quad\Longrightarrow\quad1-\frac13+\frac15-\frac17+\dots=\frac\pi4
3. Take the period \left[-\frac\pi2,\frac\pi2\right]: T_0=\pi, 2\pi kf_0t=2kt, even. With 2\cos t\cos2kt=\cos((2k+1)t)+\cos((2k-1)t):
A_0=\frac4\pi,\qquad A_k=\frac2\pi(-1)^k\left(\frac{1}{2k+1}-\frac{1}{2k-1}\right)=\frac{4(-1)^{k+1}}{\pi(4k^2-1)},\qquad |\cos t|=\frac2\pi+\frac4\pi\sum_{k=1}^{\infty}\frac{(-1)^{k+1}}{4k^2-1}\cos(2kt)
4. T_0=2, even; by parts the boundary terms vanish:
A_0=1,\qquad A_k=2\int_0^1(1-t)\cos(\pi kt)\,dt=\frac{2\left(1-(-1)^k\right)}{\pi^2k^2}=\mathrm{sinc}^2\left(\frac k2\right)
5. T_0=2L; with \sin(\pi k)=0,
A_0=\frac{2\sinh(aL)}{aL},\qquad A_k=\frac{2aL(-1)^k\sinh(aL)}{a^2L^2+\pi^2k^2},\qquad B_k=\frac{2\pi k(-1)^{k+1}\sinh(aL)}{a^2L^2+\pi^2k^2}
Items 4 and 5 had no written solution in my notes for this course: item 4 follows my solution for Communications Engineering, item 5 is added for the web version.
a. Compute the convolution z(t)=x*y(t), a>0, where x(t)=\mathrm{rect}(t) and
y(t)=\begin{cases}\sin(t)&0\le t<a\\0&\text{otherwise}\end{cases}
b. Compute the Fourier series of the periodic signal in the figure.
the signal of exercise b
x lasts 1 and y lasts a, so z(t)=\int_{t-1/2}^{t+1/2}y(\tau)\,d\tau lasts a+1. For a\le1 and for a>1:
z(t)=\begin{cases}1-\cos\left(t+\frac12\right)&-\frac12\le t<a-\frac12\\1-\cos a&a-\frac12\le t<\frac12\\\cos\left(t-\frac12\right)-\cos a&\frac12\le t<a+\frac12\end{cases}\qquad z(t)=\begin{cases}1-\cos\left(t+\frac12\right)&-\frac12\le t<\frac12\\2\sin\frac12\,\sin t&\frac12\le t<a-\frac12\\\cos\left(t-\frac12\right)-\cos a&a-\frac12\le t<a+\frac12\end{cases}
and 0 elsewhere. The area is A(z)=A(x)\,A(y)=1-\cos a. The window of length 1 collects at most 2\sin\frac12 of the sine, when it is centred on its peak at \frac\pi2:
\max z=\begin{cases}1-\cos a&0<a\le1\\2\sin\frac12\,\sin\left(a-\frac12\right)&1<a\le\frac\pi2+\frac12\\2\sin\frac12\approx0.959&a>\frac\pi2+\frac12\end{cases}
It depends on a until it saturates.
My solution sheet left the maximum for a>1 blank: the last two cases are added for the web version.
One period is x(t)=\sin(\pi t)\,\mathrm{rect}(t), and x_p(t)=\sum_kx(t-2k): T_0=2, f_0=\frac12. The signal is odd, so only the sines remain:
B_k=2\int_0^{1/2}\sin(\pi t)\sin(\pi kt)\,dt=\frac12\,\mathrm{sinc}\left(\frac{k-1}{2}\right)-\frac12\,\mathrm{sinc}\left(\frac{k+1}{2}\right)
that is B_1=\frac12, B_k=0 for odd k\ge3, and B_k=\dfrac{-2k\cos\frac{k\pi}{2}}{\pi(k^2-1)} for even k:
x_p(t)=\frac12\sin(\pi t)+\frac4\pi\sum_{m=1}^{\infty}\frac{(-1)^{m+1}m}{4m^2-1}\sin(2\pi mt)
The transform of one period: a product in time, a convolution in frequency,
X(f)=\mathrm{sinc}(f)*\frac{1}{2j}\left[\delta\left(f-\tfrac12\right)-\delta\left(f+\tfrac12\right)\right]=\frac{1}{2j}\left[\mathrm{sinc}\left(f-\tfrac12\right)-\mathrm{sinc}\left(f+\tfrac12\right)\right]=\frac{4f\cos(\pi f)}{j\pi\left(1-4f^2\right)}
and indeed B_k=j\,X\left(\frac k2\right): the coefficients are samples of the transform.
What if the signal is not periodic? An aperiodic signal can be seen as a periodic signal with period T_0\to\infty. Take x(t)=\mathrm{rect}(t), repeated with period T_0=2, 10 and 100:
The lines T_0c_k sit at f=k/T_0, closer and closer: in the limit they become a continuous function of f, the Fourier transform.
02
The Fourier transform decomposes a signal into its constituent frequencies:
X(f)=\int_{-\infty}^{+\infty}x(t)\,e^{-j2\pi ft}\,dt
Under some conditions it is invertible:
x(t)=\int_{-\infty}^{+\infty}X(f)\,e^{j2\pi ft}\,df
On a computer: the FFT and its inverse, the IFFT.
x(t) is defined on a group I, here the time domain, and X(f) on the dual group \hat I, the frequency domain.
| Signal | Time, I | Frequency, \hat I |
|---|---|---|
| continuous, aperiodic | \mathbb{R} | \mathbb{R} |
| continuous, periodic | \mathbb{R}/\mathbb{Z}(T_0) | \mathbb{Z}(1/T_0) |
| discrete, aperiodic | \mathbb{Z}(T) | \mathbb{R}/\mathbb{Z}(1/T) |
| discrete, periodic | \mathbb{Z}(T)/\mathbb{Z}(T_0) | \mathbb{Z}(1/T_0)/\mathbb{Z}(1/T) |
Periodic in one domain means discrete in the other: the Fourier series of the first part is the transform on \mathbb{R}/\mathbb{Z}(T_0).
With I=\mathbb{R} and \mathcal{F}[x(t)]:=X(f)=\displaystyle\int_{-\infty}^{+\infty}x(t)\,e^{-j2\pi ft}\,dt:
| linearity | \mathcal{F}[\alpha_1x_1(t)+\alpha_2x_2(t)]=\alpha_1X_1(f)+\alpha_2X_2(f) |
| flipping | \mathcal{F}[x(-t)]=X(-f) |
| conjugation | \mathcal{F}[x^*(t)]=X^*(-f) |
| time shift | \mathcal{F}[x(t-t_0)]=X(f)\,e^{-j2\pi ft_0} |
| frequency shift | \mathcal{F}\left[x(t)\,e^{j2\pi f_0t}\right]=X(f-f_0) |
| scaling | \mathcal{F}[x(at)]=\frac{1}{|a|}X\left(\frac{f}{a}\right) |
| derivative | \mathcal{F}\left[\frac{dx(t)}{dt}\right]=j2\pi f\,X(f) |
| integral | \mathcal{F}\left[\int_{-\infty}^{t}x(\tau)\,d\tau\right]=\frac12X(0)\,\delta(f)+\frac{X(f)}{j2\pi f} |
Product/convolution rule. Let z(t)=x*y(t). Then
Z(f)=X(f)\cdot Y(f)
where X(f) and Y(f) are the Fourier transforms of x(t) and y(t).
Parseval’s theorem. For x(t), y(t), t\in I:
\int_{I}x(t)\,y^*(t)\,dt=\int_{\hat I}X(f)\,Y^*(f)\,df
where \hat I is the dual domain of I. With y=x, the energy is the same in both domains.
Compute the Fourier transform X(f) of
Evaluate the area of x(t)=\mathrm{sinc}^4(t).
1. \displaystyle\mathcal{F}[\mathrm{rect}(t)]=\int_{-1/2}^{1/2}e^{-j2\pi ft}\,dt=\frac{e^{j\pi f}-e^{-j\pi f}}{j2\pi f}=\mathrm{sinc}(f); scaling by D and shifting by t_0: \ X(f)=D\,\mathrm{sinc}(Df)\,e^{-j2\pi ft_0}.
2. \mathcal{F}[\delta(t)]=1 and, by duality, \mathcal{F}[1]=\delta(f). Writing the cosine with exponentials:
X(f)=\frac12\delta(f-f_0)+\frac12\delta(f+f_0),\qquad \mathcal{F}[\sin(2\pi f_0t)]=\frac{1}{2j}\left[\delta(f-f_0)-\delta(f+f_0)\right]
3. \mathrm{triangle}=\mathrm{rect}*\mathrm{rect}, so X(f)=\mathrm{sinc}^2(f).
4. \displaystyle X(f)=\int_{-\infty}^0e^{t(a-j2\pi f)}dt+\int_0^{\infty}e^{-t(a+j2\pi f)}dt=\frac{1}{a-j2\pi f}+\frac{1}{a+j2\pi f}=\frac{2a}{a^2+4\pi^2f^2}
5. Complete the square, -\pi(t^2+j2ft)=-\pi(t+jf)^2-\pi f^2, and shift the integration path by jf (Cauchy’s theorem allows it):
X(f)=e^{-\pi f^2}\int_{-\infty}^{+\infty}e^{-\pi(t+jf)^2}\,dt=e^{-\pi f^2}
6. A product in time is a convolution in frequency:
X(f)=\frac{1}{2j}\left[\delta(f-f_0)-\delta(f+f_0)\right]*e^{-\pi f^2}=\frac{1}{2j}\left[e^{-\pi(f-f_0)^2}-e^{-\pi(f+f_0)^2}\right]
purely imaginary and odd: two Gaussian bumps, at \pm f_0, with opposite signs.
Area. \mathrm{sinc}^4=\mathrm{sinc}^2\cdot\mathrm{sinc}^2 and \mathcal{F}\left[\mathrm{sinc}^2\right]=\mathrm{triangle}; by Parseval,
\int_{-\infty}^{+\infty}\mathrm{sinc}^4(t)\,dt=\int_{-1}^{1}\mathrm{triangle}^2(f)\,df=2\int_0^1(1-f)^2\,df=\frac23
03
If x(t) is real, X(f)=X^*(-f) is Hermitian and its magnitude is symmetric around the origin, |X(f)|=|X(-f)|. Then the band B is defined through the interval (-B,B): X(f)=0 for |f|>B.
Let x(t) be a real band-limited signal, X(f)=0 for |f|>B. Then it can be exactly reconstructed from its samples x(nT) if the sampling frequency is
F_c=\frac{1}{T}>2B
The reconstruction formula is
x(t)=\sum_{n=-\infty}^{\infty}x(nT)\,\mathrm{sinc}\left(\frac{t-nT}{T}\right)
Sampling every T repeats the spectrum every F_c=1/T. The reconstruction filter keeps |f|<F_c/2: it gets the original spectrum back only if the copies do not overlap.
What is the minimum sampling frequency F_s to reconstruct x(t)=\sin(2\pi t)\cdot\mathrm{sinc}^2(t) from its samples?
\mathcal{F}\left[\mathrm{sinc}^2(t)\right]=\mathrm{triangle}(f), band 1 Hz; multiplying by \sin(2\pi t) moves it to \pm1 Hz: \ X(f)=\frac{1}{2j}\left[\mathrm{triangle}(f-1)-\mathrm{triangle}(f+1)\right], so B=2 Hz and F_s>4 Hz.

the reconstructions, saved from the run
The signal is simulated at 100 Hz, then one sample out of N is kept: N=20, 33, 40 give 5, about 3 and 2.5 Hz. Only 5 Hz is above 2B=4 Hz, and only that reconstruction follows the signal.
What if the signal is discrete? First an aperiodic discrete-time signal: its Fourier transform is the discrete-time Fourier transform (DTFT). It goes from I=\mathbb{Z}(T) to \hat I=\mathbb{R}/\mathbb{Z}(1/T): the transform is continuous and periodic, with period 1/T.
X(f)=T\sum_{k=-\infty}^{+\infty}x(kT)\,e^{-j2\pi fkT}
It satisfies the first five properties of the Fourier transform: linearity, flipping, conjugation, time and frequency shift.
Compute the discrete-time Fourier transform X(f) of
1. A geometric series in q=a\,e^{-j2\pi fT}, with |q|=|a|<1:
X(f)=T\sum_{k=0}^{\infty}\left(a\,e^{-j2\pi fT}\right)^k=\frac{T}{1-a\,e^{-j2\pi fT}}
2. With a=\frac12:
|X(f)|=\frac{T}{\left|1-\frac12e^{-j2\pi fT}\right|}=\frac{T}{\sqrt{\frac54-\cos(2\pi fT)}}
periodic with period \frac1T, from 2T at f=0 down to \frac23T at f=\pm\frac{1}{2T}.
3. Shift the index by \frac{N-1}{2} and sum the geometric series:
X(f)=T\,e^{j\pi f(N-1)T}\,\frac{1-e^{-j2\pi fNT}}{1-e^{-j2\pi fT}}=T\,\frac{\sin(\pi fNT)}{\sin(\pi fT)}
real, since p_N is symmetric, and equal to NT at f=0: the discrete counterpart of the sinc.
What if the signal is discrete and periodic? Its Fourier transform is the discrete Fourier transform (DFT). It goes from I=\mathbb{Z}(T)/\mathbb{Z}(T_0) to \hat I=\mathbb{Z}(1/T_0)/\mathbb{Z}(1/T): the transform is discrete and periodic, with period 1/T.
Here T_0=NT. Call F=1/T_0 the quantum frequency; then F\cdot T=\frac{1}{T_0}\cdot\frac{T_0}{N}=\frac1N, and the DFT of the periodic signal x(kT) is
X(hF)=T\sum_{k=0}^{N-1}x(kT)\,e^{-j2\pi hFkT}=T\sum_{k=0}^{N-1}x(kT)\,e^{-j2\pi\frac{hk}{N}}=T\sum_{k=0}^{N-1}x(kT)\,W_N^{hk}
where W_N=e^{-j\frac{2\pi}{N}} is a root of unity and 0\le h<N.
It can be read as the sampled version of the DTFT, or as the DTFT of the periodic version of x(kT). The FFT is a fast algorithm to compute it.
Compute the discrete Fourier transform X(hF) of the periodic signals
An N-point signal is x(n)=[1,-1,1,-1,\dots,(-1)^{N-1}], 0\le n\le N-1.
With T=1, X(hF)=\sum_{k=0}^{N-1}x(k)\,e^{-j2\pi hk/N}.
1. N=2: \ X=20+10\,e^{-j\pi h}=[30,\ 10].
2. N=4: \ X=1+2e^{-j\frac{\pi h}{2}}+3e^{-j\pi h}+4e^{-j\frac{3\pi h}{2}}=[10,\ -2+2j,\ -2,\ -2-2j].
3. X(hF)=1+e^{-j2\pi h\frac{N-1}{N}}=1+e^{j\frac{2\pi h}{N}}=2\,e^{j\frac{\pi h}{N}}\cos\left(\frac{\pi h}{N}\right).
4. With \cos\frac{2\pi k}{N}=\frac12\left(e^{j\frac{2\pi k}{N}}+e^{-j\frac{2\pi k}{N}}\right), each half is a sum of N roots of unity:
X(hF)=\frac12\sum_{k=0}^{N-1}e^{-j\frac{2\pi k(h-1)}{N}}+\frac12\sum_{k=0}^{N-1}e^{-j\frac{2\pi k(h+1)}{N}}
The first sum is N at h=1 and 0 otherwise; the second is N at h=N-1 and 0 otherwise. So X=\left[0,\ \frac N2,\ 0,\dots,0,\ \frac N2\right]: one line at \pm\frac1N, as for the cosine in continuous time.
1. X(h)=1-e^{-j\pi h}=2j\,e^{-j\frac{\pi h}{2}}\sin\left(\frac{\pi h}{2}\right)=2\sin\left(\frac{\pi h}{2}\right)e^{-j\left(\frac{\pi h}{2}-\frac\pi2\right)}, that is X=[0,\ 2].
2. A geometric series in q=-e^{-j\frac{2\pi h}{N}}:
X(h)=\sum_{k=0}^{N-1}\left(-e^{-j\frac{2\pi h}{N}}\right)^k=\frac{1-(-1)^N}{1+e^{-j\frac{2\pi h}{N}}}
3. Flipping in time flips in frequency: X_f(h)=X(-h)=X(N-h). For N even nothing changes; for N odd, X_f(h)=1-j\tan\left(\frac{\pi h}{N}\right).
Item 3 had no written solution in my notes: this one is added for the web version.
How many operations does the DFT need? Take T=1:
X\left(\frac hN\right)=\sum_{k=0}^{N-1}x(k)\,W_N^{hk}
Each product x(k)\cdot W_N^{hk} takes 6 real operations, 4 products and 2 sums (real and imaginary part). It is repeated N times and summed (2N real sums): 8N operations for each of the N components, 8N^2 in total.
\text{DFT}\sim O(N^2)
Can we get the same result with less work? The fast Fourier transform.
The idea: compute the even and the odd components separately. For N=2^m,
X(h)=\sum_{k=0}^{N-1}x(k)\,W_N^{hk},\qquad h=0,1,\dots,N-1
and for l=0,1,\dots,\frac N2-1,
X(2l)=\sum_{a=0}^{\frac N2-1}x_+(a)\,W_{N/2}^{al},\qquad X(2l+1)=\sum_{a=0}^{\frac N2-1}x_-(a)\,W_{N/2}^{al}
with x_+(a)=x(a)+x\left(a+\frac N2\right) and x_-(a)=\left[x(a)-x\left(a+\frac N2\right)\right]W_N^a: two DFTs on \frac N2 samples each.
That costs 8\left(\frac N2\right)^2+8\left(\frac N2\right)^2=4N^2 operations instead of 8N^2. Repeating the split \log_2N times gives
\text{FFT}\sim O(N\log_2N)
each butterfly: the sum goes up, the difference times W_8^a goes down; the outputs come out in bit-reversed order
letizia.tech · Digital Signal Processing · University of Klagenfurt