S7 · Lesson 24 · The DFT and circular convolution
The DFT as samples of the DTFT, time aliasing, circular shifts and circular convolution, and computing linear convolution with the DFT
The DFT is the only Fourier transform a computer can actually evaluate, and it isn't quite the transform it's often taken for. It treats every finite sequence as one period of a periodic one. Shifting a sequence wraps samples around from the end to the start; multiplying two DFTs convolves the sequences circularly, with the tail of the result folded back onto its beginning. Used carelessly, that wrap-around corrupts filtering done in the frequency domain. Used with the right amount of zero padding, the DFT computes ordinary linear convolution exactly, and with the FFT it does it fast.
- Two rectangular pulses of length L convolved linearly (a triangle 2L − 1 long) and circularly with N-point DFTs.
- If N ≥ 2L − 1 the circular result equals the linear one. If N is smaller, the triangle's tail wraps around and adds onto its start.
- With L = 6 and N = 8 the circular result is [4, 4, 4, 4, 5, 6, 5, 4]: the first four samples are corrupted by the wrapped tail.
Predict
x = [1, 2, 3] and h = [1, 1] are convolved by multiplying their 3-point DFTs. What comes out?
The linear convolution is [1, 3, 5, 3], four samples long, but a 3-point DFT can only hold three. Multiplying DFTs gives circular convolution, so the fourth sample wraps onto the first: [1 + 3, 3, 5] = [4, 3, 5]. With 4-point (or longer) DFTs, after zero padding, the result would be the true [1, 3, 5, 3].
Name it
The DFT
- X[k] are N samples of the DTFT at , spaced in hertz.
- Sampling the DTFT aliases in time: inverting N samples of X(e^{jω}) gives , which equals x[n] only if the sequence is no longer than N.
- For real x, . A real cosine with integer gives exactly two nonzero bins, .
Circular operations
- Circular shift: ; samples leaving one end re-enter at the other.
- Circular convolution: , the linear convolution with its samples beyond N − 1 folded back.
Linear convolution with the DFT
For sequences of lengths L and P, the linear convolution is L + P − 1 long. Zero-padding both to N ≥ L + P − 1 points and multiplying their DFTs gives the linear convolution exactly. With the FFT, N is usually the next power of two.
Worked example
Compute [1, 2, 3] ⊛ [1, 1] with 3-point and with 4-point DFTs.
Show the solution
- Linear convolution. The linear result is [1, 3, 5, 3].
- With N = 3. The last sample folds onto the first: [4, 3, 5].
- With N = 4. Since 4 ≥ 3 + 2 − 1, nothing wraps: [1, 3, 5, 3].
- In general. The circular result is for 0 ≤ n < N.
Answer [4, 3, 5] with 3-point DFTs, and [1, 3, 5, 3] with 4-point DFTs.
Worked example
A 16-point DFT of . Which bins are nonzero, and what are they?
Show the solution
- Which bins. Bins 3 and 13 (= 16 − 3) are nonzero.
- Their value. and the same for bin 13.
- The other bins. All others are exactly zero because the cosine completes a whole number of cycles in the record.
- In hertz. At = 8 kHz, bin 3 is at
- Between bins. A frequency between bins, say 3.5 cycles per record, would spread into every bin, the leakage of lesson 29.
Answer only bins 3 and 13 are nonzero, each equal to 16.
Worked example
Find the 4-point DFT of x = [1, 2, 3, 4], then the DFT of its circular shift [4, 1, 2, 3].
Show the solution
- The DFT. gives X = [10, −2 + 2j, −2, −2 − 2j].
- Shift theorem. Shifting by one multiplies bin k by :
- Check directly. as predicted.
- What changed. The magnitudes are unchanged; only the phases rotate.
Answer X = [10, −2 + 2j, −2, −2 − 2j], and the shifted sequence has X′ = [10, 2 + 2j, 2, 2 − 2j].
Check
Sequences of lengths 100 and 21 are convolved. How long is the result?
Check
To compute that convolution with power-of-two FFTs, what's the smallest usable FFT size?
Check
Two length-8 pulses of ones are convolved circularly with 9-point DFTs. What's output sample n = 2?
Check
A 2.5 kHz tone is sampled at 8 kHz and analyzed with a 1024-point DFT. At what bin index does it fall?
Check
with A = 0.5, N = 16 and integer . What's ?
Check
What's the bin spacing of a 128-point DFT at 44.1 kHz?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
Sequences of lengths 100 and 20 are convolved circularly with 256-point DFTs.
(a)
How long is their linear convolution?
(b)
How many output samples are corrupted by wraparound?
Check
with an integer .
Step 1
What is ?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What is the signal's energy ?
Step 3
What does Parseval's give?
Explain why
Why does multiplying two DFTs give circular rather than linear convolution?
The DFT treats its N samples as one period of a periodic sequence, because its basis functions, , all repeat every N samples. Multiplying two DFTs therefore convolves two periodic sequences, and the convolution of periodic sequences is itself periodic with period N. Any part of the true linear convolution that extends beyond N samples has nowhere to go except into the next period, which overlaps the current one, so it adds onto the beginning. Padding both sequences with zeros to at least the full length of their linear convolution makes the periods long enough that nothing overlaps, and then the circular result is exactly the linear one.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.