TExcelTAD
Home › Fourier Analysis & Signals › Properties of the DFT

Properties of the DFT

The DFT inherits the rules of the Fourier transform, with one twist: everything is circular. Indices wrap around modulo NN, shifts rotate the array, and convolution becomes circular convolution. Knowing these rules lets you predict FFT output before running it and avoid the classic wrap-around bugs.

The rules

With x↔Xx \leftrightarrow X (NN points, indices modulo NN):

Time Frequency
circular shift x[(n−m) mod N]x[(n - m) \bmod N] e−2πikm/NX[k]e^{-2\pi i k m / N} X[k]
modulation e2πik0n/Nx[n]e^{2\pi i k_0 n / N} x[n] X[(k−k0) mod N]X[(k - k_0) \bmod N]
real xx X[N−k]=X[k]‾X[N - k] = \overline{X[k]}
circular convolution (x⊛h)[n]=∑mx[m]h[(n−m) mod N](x \circledast h)[n] = \sum_m x[m] h[(n - m) \bmod N] X[k]H[k]X[k] H[k]
Parseval ∑n∣x[n]∣2=1N∑k∣X[k]∣2\sum_n \lvert x[n] \rvert^2 = \frac{1}{N} \sum_k \lvert X[k] \rvert^2
python · try it yourself
import numpy as np

rng = np.random.default_rng(2)
N = 8
x = rng.integers(-5, 6, N).astype(float)
h = rng.integers(-5, 6, N).astype(float)
X, H = np.fft.fft(x), np.fft.fft(h)
k = np.arange(N)

print("shift rule:     ", np.allclose(np.fft.fft(np.roll(x, 3)), np.exp(-2j * np.pi * k * 3 / N) * X))
print("real symmetry:  ", np.allclose(X[(N - k) % N], np.conj(X)))
circ = np.array([sum(x[m] * h[(n - m) % N] for m in range(N)) for n in range(N)])
print("circular conv:  ", np.allclose(np.fft.ifft(X * H).real, circ))
print("Parseval:       ", np.sum(x ** 2), "=", round(float(np.sum(np.abs(X) ** 2) / N), 10))
shift rule:      True
real symmetry:   True
circular conv:   True
Parseval:        72.0 = 72.0

Circular versus linear convolution

Multiplying DFTs computes circular convolution: the tail of the result wraps around to the start. To get the ordinary (linear) convolution of lengths LL and MM, zero-pad both to at least L+M−1L + M - 1:

python · try it yourself
import numpy as np

x = np.array([1.0, 2.0, 3.0, 4.0])
h = np.array([1.0, 1.0, 1.0])
print("linear (np.convolve):", np.convolve(x, h).tolist())

circ4 = np.fft.ifft(np.fft.fft(x) * np.fft.fft(h, 4)).real
print("circular, N = 4:     ", (np.round(circ4, 10) + 0.0).tolist(), "<- tail wrapped onto the start")

N = len(x) + len(h) - 1
lin = np.fft.ifft(np.fft.fft(x, N) * np.fft.fft(h, N)).real
print("zero-padded, N = 6:  ", (np.round(lin, 10) + 0.0).tolist())
linear (np.convolve): [1.0, 3.0, 6.0, 9.0, 7.0, 4.0]
circular, N = 4:      [8.0, 7.0, 6.0, 9.0] <- tail wrapped onto the start
zero-padded, N = 6:   [1.0, 3.0, 6.0, 9.0, 7.0, 4.0]

With N=4N = 4 the outputs 7 and 4 at positions 4 and 5 were added onto positions 0 and 1: 1+7=81 + 7 = 8 and 3+4=73 + 4 = 7.

Time reversal and the DFT twice

Circular time reversal x[(−n) mod N]x[(-n) \bmod N] corresponds to X[(−k) mod N]X[(-k) \bmod N]. Applying the DFT twice gives N x[(−n) mod N]N\,x[(-n) \bmod N], the discrete version of FFf(t)=f(−t)\mathcal{F}\mathcal{F}f(t) = f(-t). Note the index: n=0n = 0 stays in place, and the rest of the array is reversed.

In software

  • np.roll is a circular shift; for the FFT's view of the signal, it is the natural shift.
  • Wrap-around artifacts appear whenever image processing or audio code multiplies FFTs without padding: echoes at the wrong end, blur leaking from the right edge to the left.

Exercises

Exercise 1: Shift and magnitude

Does a circular shift change ∣X[k]∣\lvert X[k] \rvert?

Answer

No.

Solution

It multiplies X[k]X[k] by e−2πikm/Ne^{-2\pi i k m/N}, which has magnitude 1. Magnitude spectra cannot tell where in the frame an event happened.

Exercise 2: How much padding?

You convolve a 1000-sample signal with a 200-tap filter via FFT. What is the smallest FFT size that avoids wrap-around?

Answer

1199 (in practice the next fast size, such as 1200 or 1280, or the power of two 2048).

Solution

L+M−1=1199L + M - 1 = 1199. FFTs are fastest for sizes with small prime factors; scipy.fft.next_fast_len(1199) returns 1200.

Exercise 3: DFT twice (code)

Apply np.fft.fft twice to [1,2,3,4,5][1, 2, 3, 4, 5] and divide by NN. What do you get?

Answer

[1,5,4,3,2][1, 5, 4, 3, 2].

Solution
python · try it yourself
import numpy as np
x = np.array([1, 2, 3, 4, 5], dtype=float)
y = np.fft.fft(np.fft.fft(x)) / len(x)
print((np.round(y.real, 10) + 0.0).tolist())
[1.0, 5.0, 4.0, 3.0, 2.0]

Index 0 stays; the rest is reversed: x[(−n) mod 5]x[(-n) \bmod 5].

Test yourself

Multiplying two DFTs and inverting computes…

  1. linear convolution always
  2. circular convolution
  3. cross-correlation
  4. the sum

A circular shift by mm samples multiplies X[k]X[k] by…

  1. mm
  2. e−2πikm/Ne^{-2\pi i k m/N}
  3. (−1)m(-1)^m
  4. NN

Parseval for the unnormalized DFT reads…

  1. ∑∣x∣2=∑∣X∣2\sum |x|^2 = \sum |X|^2
  2. ∑∣x∣2=1N∑∣X∣2\sum |x|^2 = \frac{1}{N}\sum |X|^2
  3. ∑x=∑X\sum x = \sum X
  4. max⁡∣x∣=max⁡∣X∣\max |x| = \max |X|