S724 of 55
0 XP
  1. Hook
  2. Play
  3. Predict
  4. Name it
  5. Check
  6. Explain

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?

Name it

The DFT

X[k]=∑n=0N−1x[n]WNkn,x[n]=1N∑k=0N−1X[k]WN−kn,WN=e−j2π/N
  • X[k] are N samples of the DTFT at ωk=2πk/N, spaced fs/N in hertz.
  • Sampling the DTFT aliases in time: inverting N samples of X(e^{jω}) gives ∑rx[n+rN], which equals x[n] only if the sequence is no longer than N.
  • For real x, X[N−k]=X*[k]. A real cosine Acos⁡(2πk0n/N) with integer k0 gives exactly two nonzero bins, X[k0]=X[N−k0]=AN/2.

Circular operations

  • Circular shift: x[((n−m))N]↔WNkmX[k]; samples leaving one end re-enter at the other.
  • Circular convolution: X1[k]X2[k]↔∑m=0N−1x1[m]x2[((n−m))N], 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
  1. Linear convolution. The linear result is [1, 3, 5, 3].
  2. With N = 3. The last sample folds onto the first: [4, 3, 5].
  3. With N = 4. Since 4 ≥ 3 + 2 − 1, nothing wraps: [1, 3, 5, 3].
  4. In general. The circular result is yN[n]=∑rylin[n+rN] 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 x[n]=2cos⁡(2π⋅3n/16). Which bins are nonzero, and what are they?

Show the solution
  1. Which bins. Bins 3 and 13 (= 16 − 3) are nonzero.
  2. Their value. X[3]=AN2=2×162=16 and the same for bin 13.
  3. The other bins. All others are exactly zero because the cosine completes a whole number of cycles in the record.
  4. In hertz. At fs = 8 kHz, bin 3 is at f=3×800016Hz=1.5kHz
  5. 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
  1. The DFT. X[k]=∑x[n](−j)kn gives X = [10, −2 + 2j, −2, −2 − 2j].
  2. Shift theorem. Shifting by one multiplies bin k by W4k=(−j)k: X′=[10,(−2+2j)(−j),(−2)(−1),(−2−2j)(j)]=[10,2+2j,2,2−2j]
  3. Check directly. X′[1]=4−j−2+3j=2+2j as predicted.
  4. 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

Acos⁡(2πk0n/N) with A = 0.5, N = 16 and integer k0. What's |X[k0]|?

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

x[n]=Acos⁡(2πk0n/N) with an integer 0<k0<N/2.

Step 1

What is |X[k0]|?

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

Explain why

Why does multiplying two DFTs give circular rather than linear convolution?

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.