MIT 6.300 — Lecture 12

Discrete Fourier Transform I

§ Lecture: Discrete Fourier Transform

The problem with Fourier transforms is that, unlike Fourier series, they are not easily expressible in code: they're continuous data, not discrete. The discrete Fourier transform, as its name suggests, is the fix for this.

Definition. Given a possibly aperiodic DT signal x[n]x[n] and any positive integer NN, the discrete Fourier transform (DFT) of x[n]x[n] is the same as the Fourier series of the periodic signal x[n]:=x[n%N]x'[n] := x[n \% N].

Remark. Recall that this means the DFT of x[n]x[n] is an array XX, where X[k]X[k] denotes the coefficient of ej(2πk/N)ne^{j(2\pi k/N)n} in the DT Fourier series of x[n]x'[n]. Note that XX is an array of length NN.

Importantly, it does not make sense to ask for “the DFT of x[n]x[n]”. One must always also specify a length NN.

In some ways, the DFT is the culmination of all of the Fourier analysis in 6.300 up to this point: it combines the signal-aperiodicity of the DTFT with the computational feasibility of the DTFS.

Example. The DFT of x[n]=cos(2πn64)x[n] = \cos\left(\frac{2\pi n}{64}\right) for N=64N = 64 is the same as the Fourier series of x[n]x[n], plotted below.

Example. The DFT of x[n]=cos(3πn64)x[n] = \cos\left(\frac{3\pi n}{64}\right) for N=64N = 64, plotted below, differs from the Fourier series of x[n]x[n].

The reason why is that x[n]x[n] does not have period N=64N = 64; its period is 128128. However, the DFT of x[n]x[n] for N=64N = 64 does match the Fourier series of the signal pictured below.

Unsurprisingly, here's what the analysis and synthesis equations for the DFT look like.

Theorem. (DFT Formulas) Given a DT signal x[n]x[n] and a positive integer NN, the DFT of x[n]x[n] is X[k]:=1Nn=0N1x[n]ej2πkNnX[k] := \frac{1}{N} \sum_{n = 0}^{N - 1} x[n] e^{-j \frac{2\pi k}{N} n}, which satisfies x[n]=k=0N1X[k]ej2πkNnx[n] = \sum_{k = 0}^{N - 1} X[k] e^{j \frac{2\pi k}{N} n} for all n=0,1,,N1n = 0, 1, \dots, N - 1.

These formulas look exactly the same as the DT Fourier series formulas presented in Lecture 5, expectedly.

§ Lecture: DFT vs. DTFT and Windows

We know the relationship between the DFT and the DTFS: they're exactly the same. What about the DFT and the DTFT?

Theorem. (DFT vs. DTFT) Consider a DT signal x[n]x[n] and a positive integer NN. Define a new signal xw[n]x_w[n] as follows:

xw[n]:={x[n] if n[0,N1].0 otherwise.x_w[n] := \begin{cases} x[n] & \text{ if } n \in [0, N - 1]. \\ 0 & \text{ otherwise.} \end{cases}

Suppose X[k]X[k] is the DFT of x[n]x[n], and Xw(Ω)X_w(\Omega) is the DTFT of xw[n]x_w[n]. Then X[k]=1NXw(2πkN)X[k] = \frac{1}{N} X_w\left(\frac{2\pi k}{N}\right).

In other words, X[k]X[k] is the result of taking NN samples from XwX_w at an interval of 2πN\frac{2\pi}{N} and dividing all samples by NN.

Proof: Recall from Lecture 7 that the DTFT Xw(Ω)X_w(\Omega) is defined via Xw(Ω)=n=xw[n]ejΩnX_w(\Omega) = \sum_{n = -\infty}^{\infty} x_w[n] e^{-j \Omega n}. Comparing with the formula X[k]:=1Nn=0N1x[n]ej2πkNnX[k] := \frac{1}{N} \sum_{n = 0}^{N - 1} x[n] e^{-j \frac{2\pi k}{N} n} for the DFT, the relationship is immediate.   \blacksquare

The diagram below paraphrases the statement of the theorem above.

To summarize: the DFT of a DT signal x[n]x[n] can be thought of as either…

Note that the constant NN decides the size of the “window” that our DFT takes into account.

Problem. Compute the DFT of the pure-frequency DT signal x[n]:=ejΩ0nx[n] := e^{j\Omega_0 n} for varying window sizes NN.

Solution: Equivalently, we compute the DTFT of w[n]x[n]w[n] \cdot x[n], where w[n]w[n] is the signal given by:

w[n]:={1 if n[0,N1]0 otherwise.w[n] := \begin{cases} 1 & \text{ if } n \in [0, N - 1] \\ 0 & \text{ otherwise.} \end{cases}

Note that the DTFT of w[n]w[n] itself looks like the following:

W(Ω)=n=w[n]ejΩn=n=0N1ejΩn=1ejΩN1ejΩ=[sin(NΩ2)sin(Ω2)]ejΩ(N1)/2.W(\Omega) = \sum_{n = -\infty}^{\infty} w[n] e^{-j \Omega n} = \sum_{n = 0}^{N - 1} e^{-j \Omega n} = \frac{1 - e^{-j \Omega N}}{1 - e^{-j \Omega}} = \left[\frac{ \sin \left(\frac{N \Omega}{2}\right) }{ \sin \left(\frac{\Omega}{2}\right) }\right] \cdot e^{-j \Omega(N - 1) / 2}.

Now we invoke a “dual” of one of the properties from Lecture 7: the DTFT of w[n]x[n]=w[n]ejΩ0nw[n] \cdot x[n] = w[n] \cdot e^{j\Omega_0 n} is just W(ΩΩ0)W(\Omega - \Omega_0).

Thus, the DFT of x[n]x[n] is the result of sampling from W(ΩΩ0)W(\Omega - \Omega_0) at intervals of 2πN\frac{2\pi}{N} and dividing the samples by NN.

For N=15N = 15 and Ω0=4π15\Omega_0 = \frac{4\pi}{15} (shown above), the resulting DFT reads as strong evidence that the original DT frequency was 4π15\frac{4\pi}{15}.

For Ω0=3.2π15\Omega_0 = \frac{3.2\pi}{15} (shown above), the resulting DFT is less informative…

We can get more informative DFTs by increasing the window size NN. The larger the value of NN, the finer our frequency resolution, and the more samples we get to read.

§ Recitation: Spectral Analysis (Interpreting the DFT)

Problem. A DT signal x[n]x[n] is produced by sampling from a CT signal with sampling frequency fsf_s, and its DFT X[k]X[k] is computed using a window length of NN. Assume x[n]x[n] is periodic modulo NN. What does X[7]X[7] say about the original CT signal?

Solution: Since x[n]x[n] is periodic modulo NN, the DFT of x[n]x[n] is very informative: it's exactly the same as the DTFS of x[n]x[n].

The rest is dimensional analysis. Note that X[7]X[7] is the coefficient of ej(2π(7)/N)ne^{j(2\pi(7)/N)n} in the DTFS, so it represents the strength of the discrete-time angular frequency Ω0=7×2πN\Omega_0 = 7 \times \frac{2\pi}{N}.

In continuous-time, this translates to (recalling Lecture 4) a continuous-time angular frequency of ω0=7×2πN×fs\omega_0 = 7 \times \frac{2\pi}{N} \times f_s.

More generally, we can say the following:

Theorem. (Spectral Analysis) The DFT X[k]X[k] measures the strength of the continuous-time cyclical frequency f0=kN×fsf_0 = \frac{k}{N} \times f_s.

Problem. Suppose fs=44100f_s = 44 \, 100, and consider a DFT X[k]X[k] using window size N=100N = 100. Given that X[13]=X[87]=1X[13] = X[87] = 1 and all other entries of XX are zero, what can we say about the original CT signal?

Solution: The original CT signal probably had a cyclical frequency of 13100×44100=5733\frac{13}{100} \times 44 \, 100 = 5 \, 733 Hz.

Notably, the data provided by the DFT is discrete, so the set of CT frequencies it may tell us about is also discrete.

Definition. Two angular frequencies Ω1\Omega_1 and Ω2\Omega_2 are resolved (that is, distinguishable in the DFT) if Ω1Ω2>ΔΩ|\Omega_1 - \Omega_2| > \Delta\Omega, where ΔΩ:=2πN\Delta\Omega := \frac{2\pi}{N} is the frequency resolution. (For cyclical frequencies, it looks like Δf:=fsN\Delta f := \frac{f_s}{N}.)