The frequency domain

Lecture 3 · Communications Engineering · University of Klagenfurt, 2023

Nunzio Alexandro Letizia

This lecture

Lecture 3 of 6

  1. The Fourier series
  2. The Fourier transform
  3. Sampling, the DTFT and the DFT

From Communications Engineering at the University of Klagenfurt, first taught in 2020: this is the edition of winter 2023, so some of it may be a little dated. All lectures.

The Fourier series

01

Fourier series

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

A sum of harmonics

The Fourier series decomposes a signal x(t) into harmonics, at the multiples kf_0 of the fundamental frequency.

A square wave and its Fourier series truncated at the first, the third and the twenty-fifth harmonic, closer and closer to the square.

The spectrum of a sawtooth

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:

Left: a sawtooth of period T0. Right: the magnitude of its Fourier coefficients, decaying as one over k.

Properties

  • If x(t) is even in \left[-\frac{T_0}{2},\frac{T_0}{2}\right], then B_k\equiv0 for all k>0.
  • If x(t) is odd in \left[-\frac{T_0}{2},\frac{T_0}{2}\right], then A_k\equiv0 for all k\ge0.

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)

Ex. 1

Calculate the Fourier series of

  1. x(t)=\mathrm{rect}\left(\frac{t}{D}\right) on \left[-\frac{T_0}{2},\frac{T_0}{2}\right], with D<T_0;
  2. x(t)=\mathrm{sgn}(t) on [-1,1], and evaluate the series \displaystyle\sum_{k=1}^{\infty}\frac{1}{(2k-1)^2};
  3. x(t)=\mathrm{triangle}(t) on [-1,1];
  4. x(t)=|\cos(t)| on [0,\pi];
  5. x(t)=e^{at} on [-L,L], and evaluate \displaystyle\sum_{n=0}^{+\infty}\frac{1}{n^2+a^2}, where a is real (optional).

Ex. 1: solutions

1. Even, so B_k=0:

A_0=\frac{2D}{T_0},\qquad A_k=\frac{4}{T_0}\int_0^{D/2}\cos(2\pi kf_0t)\,dt=\frac{2}{\pi k}\sin(\pi kf_0D)=2f_0D\,\mathrm{sinc}(kf_0D)

2. Odd, so A_k=0; T_0=2, f_0=\frac12:

B_k=2\int_0^1\sin(\pi kt)\,dt=\frac{2}{\pi k}\left(1-(-1)^k\right),\qquad x(t)=\sum_{k\ \text{odd}}\frac{4}{\pi k}\sin(\pi kt)

Parseval: \displaystyle\int_{-1}^{1}1\,dt=2=\sum_{k\ \text{odd}}\frac{16}{\pi^2k^2}, so \displaystyle\sum_{k=1}^{\infty}\frac{1}{(2k-1)^2}=\frac{\pi^2}{8}.

3. Even, T_0=2: integrating by parts, the boundary terms vanish since \sin(\pi k)=0,

A_0=1,\qquad A_k=2\int_0^1(1-t)\cos(\pi kt)\,dt=\frac{2}{\pi^2k^2}\left(1-(-1)^k\right)=\mathrm{sinc}^2\left(\frac k2\right)

the samples of \mathrm{sinc}^2, the Fourier transform of the triangle (Ex. 2).

Ex. 1: solutions, continued

4. Take the period \left[-\frac\pi2,\frac\pi2\right]: T_0=\pi, so 2\pi kf_0t=2kt, and the signal is even.

A_0=\frac{2}{\pi}\int_{-\pi/2}^{\pi/2}\cos t\,dt=\frac{4}{\pi},\qquad A_k=\frac{2}{\pi}\int_0^{\pi/2}\big[\cos((2k+1)t)+\cos((2k-1)t)\big]\,dt=\frac{2(-1)^k}{\pi}\left(\frac{1}{2k+1}-\frac{1}{2k-1}\right)

A_k=\frac{4(-1)^{k+1}}{\pi(4k^2-1)},\qquad |\cos t|=\frac{2}{\pi}+\frac{4}{\pi}\sum_{k=1}^{\infty}\frac{(-1)^{k+1}}{4k^2-1}\cos(2kt)

5. With T_0=2L, and \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}

At the jump t=L the series converges to the midpoint, \cosh(aL). With L=\pi this gives

\sum_{n=0}^{+\infty}\frac{1}{n^2+a^2}=\frac{1}{2a^2}+\frac{\pi\coth(\pi a)}{2a}

Item 5 had no written solution in my notes: this one is added for the web version.

Ex. 1 in Matlab

%% Fourier Series EX.1
D = 0.1;
T_0 = 2;
% ...
armonics = 100; % Number of armonics, k = 1 to 100
a = zeros(1,armonics+1);
a(1) = 2*D/T_0;
for i = 1:armonics
    a(i+1) = sin(pi*i/2*D)/(pi*i/2); % Coefficient of the Fourier series
    y = a(i+1)*cos(pi*i*tt) + y;
end
y = a(1)/2+y;

%% Fourier Series EX.4 ABS(COS t)
armonics = 5;
a = zeros(1,armonics+1);
a(1) = 4/pi;
for i = 1:armonics
    a(i+1) = (-1)^(i+1)/(4*i^2-1);
    y = a(i+1)*cos(2*i*tt) + y;
end
y = 4/pi*y+a(1)/2;

The series of items 1 and 4, summed and plotted against the original signal, with the coefficients as stems.

No saved run survives. What to expect: for the pulse train (D=0.1, T_0=2, 100 harmonics) a close copy of the pulses with small ripples at the edges, and coefficients that trace a slowly decaying sinc; for |\cos t|, already with 5 harmonics, a curve almost on top of the original, coefficients decaying as 1/k^2.

The script uses the sign (-1)^{k+1}, the right one.

Complex exponentials

The Fourier series has an equivalent form with complex exponentials. With

\cos(2\pi kf_0t)=\frac{e^{j2\pi kf_0t}+e^{-j2\pi kf_0t}}{2},\qquad \sin(2\pi kf_0t)=\frac{e^{j2\pi kf_0t}-e^{-j2\pi kf_0t}}{2j}

the series becomes

x(t)=\sum_{k=-\infty}^{+\infty}c_k\,e^{j2\pi kf_0t},\qquad c_k=\frac{1}{T_0}\int_{-T_0/2}^{T_0/2}x(t)\,e^{-j2\pi kf_0t}\,dt

and

c_0=\frac{A_0}{2},\qquad c_k=\frac{A_k-jB_k}{2},\qquad c_{-k}=\frac{A_k+jB_k}{2}

From series to 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:

Rect pulses repeated every 2, 10 and 100 seconds, and their Fourier coefficients times T0: the lines get denser and fill in the sinc curve.

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.

The Fourier transform

02

The Fourier transform

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.

The rect in time and its Fourier transform, the sinc in frequency.

Time and frequency domains

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

Properties

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}

Convolution and Parseval

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.

Ex. 2

Compute the Fourier transform X(f) of

  1. x(t)=\mathrm{rect}\left(\frac{t-t_0}{D}\right)
  2. x(t)=\cos(2\pi f_0t)
  3. x(t)=\mathrm{triangle}(t)
  4. x(t)=\sin^3(2\pi f_0t) (exam, 2019)
  1. x(t)=e^{-a|t|}, with a>0
  2. x(t)=e^{-\pi t^2}
  3. x(t)=\mathrm{rect}*\mathrm{rect}*\mathrm{rect}(t) (exam, 2021)
  4. x(t)=\int_{t-1}^{t+1}e^{-\alpha\tau}\cdot1(\tau)\,d\tau, with \alpha>0

Evaluate the area of x(t)=\mathrm{sinc}(t)\cdot e^{-\pi t^2}, and the energy of x(t)=\mathrm{sinc}(t).

Ex. 2: solutions

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); with scaling and shift, X(f)=D\,\mathrm{sinc}(fD)\,e^{-j2\pi ft_0}.

2. Since \mathcal{F}[\delta(t)]=1 and, by duality, \mathcal{F}[1]=\delta(f): \quad X(f)=\frac12\left[\delta(f-f_0)+\delta(f+f_0)\right]. Likewise \mathcal{F}[\sin(2\pi f_0t)]=\frac{1}{2j}\left[\delta(f-f_0)-\delta(f+f_0)\right].

3. \mathrm{triangle}(t)=\mathrm{rect}*\mathrm{rect}(t), so X(f)=\mathrm{sinc}^2(f).

4. \sin^3\alpha=\frac34\sin\alpha-\frac14\sin3\alpha, so

X(f)=\frac{3}{8j}\left[\delta(f-f_0)-\delta(f+f_0)\right]-\frac{1}{8j}\left[\delta(f-3f_0)-\delta(f+3f_0)\right]

5. For e^{-|t|}: \displaystyle\int_{-\infty}^0e^{t(1-j2\pi f)}dt+\int_0^{\infty}e^{-t(1+j2\pi f)}dt=\frac{2}{1+4\pi^2f^2}; with scaling, X(f)=\dfrac{2a}{a^2+4\pi^2f^2}.

Ex. 2: solutions, continued

6. Complete the square, -\pi(t^2+j2ft)=-\pi(t+jf)^2-\pi f^2:

X(f)=e^{-\pi f^2}\int_{-\infty}^{+\infty}e^{-\pi(t+jf)^2}\,dt=e^{-\pi f^2}\quad\text{(the Gaussian is its own transform)}

7. By the convolution rule, X(f)=\mathrm{sinc}^3(f).

8. The integral over a window of width 2 is a convolution with \mathrm{rect}\left(\frac t2\right): x(t)=\left\{e^{-\alpha t}1(t)\right\}*\mathrm{rect}\left(\frac t2\right), so

X(f)=\frac{1}{\alpha+j2\pi f}\cdot2\,\mathrm{sinc}(2f)

Area. A(x)=X(0)=\int x(t)\,dt; by Parseval, with \mathcal{F}[\mathrm{sinc}]=\mathrm{rect} and \mathcal{F}\left[e^{-\pi t^2}\right]=e^{-\pi f^2},

\int_{-\infty}^{+\infty}\mathrm{sinc}(t)\,e^{-\pi t^2}\,dt=\int_{-1/2}^{1/2}e^{-\pi f^2}\,df=1-2Q\left(\sqrt{\tfrac{\pi}{2}}\right)\approx0.790

since e^{-\pi f^2} is a Gaussian with variance \frac{1}{2\pi} and unit area. Energy. \displaystyle\int\mathrm{sinc}^2(t)\,dt=\int\mathrm{rect}^2(f)\,df=1.

Assignment 1

Exercise 1. With t_0\ge\frac32, let x(t)=2-|t-t_0| if |t-t_0|<1, x(t)=2-|t+t_0| if |t+t_0|<1, and 0 otherwise, and let h(t)=1 for |t|\le\frac12, 0 otherwise.

  • What is the convolution y(t)=x*h(t)? What are its maximum M and its area?
  • Write a Matlab script that takes t_0 as a numerical input and plots the convolved signal.

Exercise 2. Let x_p(t) be the periodic extension, with period T_0=2, of the symmetric trapezoid in the figure.

  • Compute the Fourier series of x_p(t).
  • In Matlab, verify it, and find how many harmonics H are needed for the integral squared error \mathrm{ISE}_H=\sqrt{\int_{-T_0/2}^{T_0/2}\left(x_{p,H}(t)-x_p(t)\right)^2dt} to fall below 0.1\%, where x_{p,H} keeps the first H harmonics.
  • Compute the Fourier transform X(f) of x(t).

A symmetric trapezoid: zero at t equal to minus one and one, flat at one between minus a half and a half.

the trapezoid of exercise 2

Assignment 1: the solution, exercise 1

Each bump is a rect plus a triangle: x(t)=\mathrm{rect}\left(\frac{t-t_0}{2}\right)+\mathrm{triangle}(t-t_0)+\mathrm{rect}\left(\frac{t+t_0}{2}\right)+\mathrm{triangle}(t+t_0) and h(t)=\mathrm{rect}(t). By linearity and time invariance, y(t)=f(t-t_0)+f(t+t_0) with

f(t)=\mathrm{rect}\left(\tfrac t2\right)*\mathrm{rect}(t)+\mathrm{triangle}(t)*\mathrm{rect}(t)=\begin{cases}\frac{\left(\frac32+t\right)^2}{2}+\frac32+t&-\frac32\le t<-\frac12\\[3pt]\frac74-t^2&-\frac12\le t<\frac12\\[3pt]\frac{\left(\frac32-t\right)^2}{2}+\frac32-t&\frac12\le t<\frac32\end{cases}

and 0 elsewhere. For t_0\ge\frac32 the two copies do not overlap, so

M=f(0)=\frac74\ \text{ at } t=\pm t_0,\qquad A(y)=A(x)\,A(h)=6\cdot1=6

Assignment 1: the solution, exercise 2

With the flat top on |t|\le D, D=\frac12, and x even:

\frac{A_0}{2}=\frac{1+D}{2},\qquad A_k=\frac{2\left((-1)^{k+1}+\cos(\pi kD)\right)}{(1-D)\pi^2k^2}

By Parseval, \mathrm{ISE}_H^2=\sum_{k>H}A_k^2: the error drops below 10^{-3} at H=43 (at H=39 if the 0.1\% is taken relative to the norm of x_p).

The trapezoid is \frac{1}{1-D}\,\mathrm{rect}\left(\frac{t}{1-D}\right)*\mathrm{rect}\left(\frac{t}{1+D}\right), so

X(f)=(1+D)\,\mathrm{sinc}((1-D)f)\,\mathrm{sinc}((1+D)f)

=\tfrac32\,\mathrm{sinc}\left(\tfrac f2\right)\mathrm{sinc}\left(\tfrac{3f}{2}\right)

Check: X(0)=\frac32, the area.

dt = 0.00001;
T0 = 2;
D = 0.5;
% ...
harmonics = 43;
a = zeros(1,harmonics+1);
a(1) = (1+D)/2;
y = y+a(1);
for i = 1:harmonics
    a(i+1) = 2/((1-D)*pi^2)*(cos(pi*D*i)+(-1)^(i+1))/(i^2);
    y = y + a(i+1)*cos(2*pi*i*1/T0*tt);
end

err_norm_2 = sqrt(dt*(sum((xx-y).^2)));

No saved run survives. What to expect: the series on top of the trapezoid, with a tiny ripple at the corners, and err_norm_2 just under 1e-3. The script fixes H=43 rather than searching for it.

Sampling, DTFT, DFT

03

Band and bandwidth

  • Spectral extension: \varepsilon(X)=(f_0,f_1) such that X(f)=0 for f\notin\varepsilon(X)
  • Bandwidth: the measure of \varepsilon(X)

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.

A spectrum magnitude that is zero outside the interval from minus B to B.

The sampling theorem

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)

  • If F_c<2B, aliasing occurs.
  • A signal of finite duration has an unlimited band; and in practice \mathrm{sinc}(t) has infinite duration.

Aliasing

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.

Sampling copies the spectrum every Fc. Top: Fc larger than 2B, the copies stay apart. Bottom: Fc smaller than 2B, the copies overlap and add up.

An example

What is the minimum sampling frequency F_s to reconstruct x(t)=\sin(2\pi t)\cdot\mathrm{sinc}^2(t) from its samples?

Left: the signal, an oscillation inside a decaying envelope. Right: its spectrum, purely imaginary, two triangles centred at plus and minus one hertz, zero beyond two hertz.

\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 example in Matlab

%% Sampling theorem example signal with Fc = 100
Fc = 100;
t0 = [-2:1/Fc:2]+0.0001;
x0 = sin(2*pi*t0).*sin(pi*t0).^2./(pi*pi*t0.^2);

[x_r1,x_d] = SamplingTheorem(t0,x0,20);
[x_r2,~] = SamplingTheorem(t0,x0,33);
[x_r3,~] = SamplingTheorem(t0,x0,40);
function [x_r,x_d] = SamplingTheorem(t,x,N)
% keep one sample out of N, reconstruct with sinc
% ...
s = sin(pi*t./T2)./(pi*t./T2);
x_r = conv(x_d,s,'same');

Matlab plot of the three reconstructions: at 5 Hz the curve follows the original signal, at 3 and 2.5 Hz it departs from it.

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.

The DTFT

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}

Left: samples of a sinc-like signal. Right: its DTFT, a rect repeated every 1 over T.

The DFT

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.