Discrete Fourier transform and FFT
Defines the N-point DFT as samples of the DTFT, interprets bins, resolution, leakage, zero-padding and circular convolution, and explains the radix-2 FFT and its operation count.
Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
The spectrum shown on a digital oscilloscope, a vibration analyser or a power-quality meter is computed with the FFT. To read it correctly you need to know what each bin means, how fine the frequency resolution is, why a pure tone can smear into neighbouring bins, and how much computation the FFT saves — all of which comes from the discrete Fourier transform (DFT).
Key ideas
What the DFT is. For a finite block of N samples x[0] … x[N − 1], the N-point DFT gives N complex numbers X[0] … X[N − 1]. They are exactly N equally spaced samples of the DTFT over one period: X[k] = X(e^(jω)) at ω = 2πk/N.
Meaning of the bins (sampling rate fs)
- Bin
kcorresponds to frequencyfk = k·fs/N. Bin spacing (resolution)Δf = fs/N = 1/(N·Ts)— the reciprocal of the record length in seconds. X[0]isNtimes the mean value (DC).- For real
x[n]:X[N − k] = X*[k], so bins aboveN/2mirror those below; onlyk = 0 … N/2carry independent information, up tofs/2. - A cosine of amplitude
Aat exactly bink0gives|X[k0]| = |X[N − k0]| = A·N/2.
Implied periodicity. The DFT treats the N samples as one period of a periodic sequence, and the IDFT returns a periodic sequence. All shifts are therefore circular (modulo N).
Circular convolution. Multiplying two N-point DFTs corresponds to N-point circular convolution in time. To get the ordinary (linear) convolution of an L-point and an M-point sequence, zero-pad both to N ≥ L + M − 1. Long data streams are filtered block by block with overlap-add or overlap-save.
Spectral leakage. If the record does not contain a whole number of periods of a tone, the tone falls between bins and its energy spreads into many bins, with the peak reduced (up to about 36 % amplitude, or 3.9 dB, for a rectangular window). Remedies: synchronise sampling to the signal, use a tapered window (Hann, Hamming, flat-top), or use a longer record.
Zero-padding samples the same DTFT more densely; it makes peaks easier to locate but does not improve the true resolution, which is fixed by the record length.
FFT. The FFT is not a different transform; it is a fast algorithm for the DFT. Radix-2 decimation-in-time (or decimation-in-frequency) splits an N-point DFT (N a power of 2) into log2 N stages of N/2 butterflies, each needing one complex multiplication by a twiddle factor W_N^k. Decimation-in-time takes input in bit-reversed order (for N = 8: 0, 4, 2, 6, 1, 5, 3, 7) and gives output in natural order.
Formulas
X[k] = Σ from n=0 to N−1 of x[n] W_N^(kn),k = 0 … N − 1— DFT.x[n] = (1/N) Σ from k=0 to N−1 of X[k] W_N^(−kn)— inverse DFT.W_N = e^(−j2π/N)— twiddle factor;W_N^N = 1,W_N^(N/2) = −1.fk = k·fs/N,Δf = fs/N— bin frequency and resolution.Σ |x[n]|² = (1/N) Σ |X[k]|²— Parseval for the DFT.y[n] = Σ from m=0 to N−1 of x[m] h[(n − m) mod N]— circular convolution,Y[k] = X[k]H[k].N²complex multiplications (direct DFT) versus(N/2)·log2 N(radix-2 FFT); additionsN(N − 1)versusN·log2 N.
Symbols: N number of points; n time index; k frequency index (bin); fs sampling frequency (Hz); Ts = 1/fs (s); Δf resolution (Hz); W_N twiddle factor (dimensionless).
Worked examples
Example 1 (standard). Find the 4-point DFT of x[n] = {1, 2, 3, 4} and check it with Parseval.
- For N = 4,
W_4 = e^(−jπ/2) = −j, so the powers are1, −j, −1, j. X[0] = 1 + 2 + 3 + 4 = 10.X[1] = 1 + 2(−j) + 3(−1) + 4(j) = −2 + 2j.X[2] = 1 − 2 + 3 − 4 = −2.X[3] = 1 + 2(j) + 3(−1) + 4(−j) = −2 − 2j(=X*[1], as expected for real x).- Parseval:
Σ x² = 30;(1/4)(100 + 8 + 4 + 8) = 30✓. X[k] = {10, −2 + 2j, −2, −2 − 2j}.
Example 2 (GATE level). (a) A vibration signal is sampled at 1 kHz and a 256-point FFT is taken. Find the resolution, the bin position of a 100 Hz component, and the saving in complex multiplications versus a direct DFT. (b) Find the 4-point circular convolution of {1, 2, 3, 4} with {1, 1, 0, 0}.
- (a)
Δf = 1000/256 = 3.906 Hz. 100/3.906 = 25.6— not an integer, so the tone lies between bins 25 and 26 and leaks.- Direct DFT:
256² = 65 536multiplications. FFT:(256/2)·log2 256 = 128 × 8 = 1024. Saving factor= 64. - (b) With
h = {1, 1, 0, 0}:y[n] = x[n] + x[(n − 1) mod 4]. y[0] = 1 + 4 = 5,y[1] = 2 + 1 = 3,y[2] = 3 + 2 = 5,y[3] = 4 + 3 = 7.- (a) Δf ≈ 3.91 Hz, 100 Hz at bin 25.6 (leakage), 64 times fewer multiplications; (b) y = {5, 3, 5, 7}. The linear convolution
{1, 3, 5, 7, 4}has its last sample wrapped ontoy[0](1 + 4 = 5); padding to N ≥ 5 avoids this.
Common mistakes
- Calling
fs/Nthe highest frequency; it is the spacing. The highest isfs/2. - Expecting zero-padding to separate two close tones.
- Using linear convolution where the DFT gives circular (and vice versa).
- Forgetting the
1/Nin the inverse DFT or in Parseval. - Reading
|X[k]|as the amplitude directly — divide byN/2for a sinusoid (byNfor DC). - Thinking the FFT gives a different or more accurate answer than the DFT — it gives the same numbers faster.
For GATE IN
Expect: computing a 4- or 8-point DFT (or one coefficient of it), using DFT properties such as X[0] = Σx[n], symmetry X[N − k] = X*[k] or Parseval to find missing values, circular convolution and the padding needed for linear convolution, bin frequency and resolution from fs and N, and FFT operation counts or bit-reversed ordering. Practise the 4-point DFT by the {1, −j, −1, j} pattern until it is mechanical.
Quick check
- A 512-point FFT at
fs = 10.24 kHz— resolution? - For real
x,X[3] = 2 − jin an 8-point DFT. What isX[5]? - Minimum DFT length for linear convolution of 6-point and 4-point sequences?
- Number of stages in a 64-point radix-2 FFT?
- 4-point DFT of
{1, 0, 1, 0}— value ofX[2]? Answers: 1. 20 Hz. 2.2 + j. 3. 9. 4.log2 64 = 6. 5.1 + 1 = 2.
Interview questions
All Signals and Systems interview questionsTry answering each one aloud before you open it.
1.What is the Discrete Fourier Transform (DFT)?Concept
The Discrete Fourier Transform (DFT) is a mathematical technique used to convert a sequence of values into components of different frequencies. It is used to analyze the frequency content of discrete signals. The DFT is defined for a sequence of N complex numbers and results in another sequence of N complex numbers, representing the amplitude and phase of the frequency components.
2.Explain the Fast Fourier Transform (FFT) and its significance.Concept
The Fast Fourier Transform (FFT) is an algorithm to compute the Discrete Fourier Transform (DFT) and its inverse efficiently. The significance of FFT lies in its ability to reduce the computational complexity from O(N^2) to O(N log N), making it feasible to process large datasets quickly. This efficiency is crucial in applications like signal processing, image analysis, and solving partial differential equations.
3.How does the DFT differ from the continuous Fourier Transform?Concept
The DFT is used for discrete signals, while the continuous Fourier Transform is used for continuous signals. The DFT analyzes a finite set of data points, resulting in a periodic frequency spectrum, whereas the continuous Fourier Transform analyzes an infinite signal, resulting in a continuous frequency spectrum. The DFT is particularly useful in digital signal processing where signals are inherently discrete.
4.Why is the FFT preferred over the DFT in practical applications?Application
The FFT is preferred over the DFT in practical applications because it significantly reduces the computational time and resources required to perform the transformation. While the DFT has a computational complexity of O(N^2), the FFT reduces this to O(N log N), making it much faster and more efficient, especially for large datasets. This efficiency is crucial in real-time signal processing applications.
5.What are some common applications of the FFT?Application
Common applications of the FFT include signal processing, image processing, audio compression, and solving differential equations. In signal processing, FFT is used to analyze the frequency components of signals. In image processing, it helps in filtering and image compression. FFT is also used in audio compression formats like MP3 to transform audio signals into frequency components for efficient storage.
6.What happens if you apply a DFT to a signal with noise?Application
When a DFT is applied to a signal with noise, the frequency spectrum will include components corresponding to the noise, which can obscure the true frequency components of the signal. This can make it challenging to distinguish between the signal and noise frequencies. Techniques such as windowing and filtering are often used to mitigate the effects of noise in the frequency domain.
7.Explain the concept of spectral leakage in the context of DFT.Concept
The DFT treats the N-sample record as one period of a periodic signal. If the record does not contain a whole number of cycles of a tone, the periodic extension has a discontinuity and the tone falls between bins, so its energy spreads into many neighbouring bins and the peak reads low (by up to about 3.9 dB with a rectangular window). Leakage is reduced by sampling synchronously, by using tapered windows such as Hann or flat-top, or by using longer records.
8.How does zero-padding affect the DFT of a signal?Application
Zero-padding involves adding zeros to the end of a signal before applying the DFT. This does not increase the actual frequency resolution but provides a smoother and more interpolated frequency spectrum. Zero-padding can make it easier to identify peak frequencies and visualize the spectrum, but it does not add new information about the signal's frequency content.
9.Calculate the DFT of a simple sequence: x[n] = {1, 2, 3, 4}.Numerical
To calculate the DFT of the sequence x[n] = {1, 2, 3, 4}, we use the formula: X[k] = Σ (x[n] * e^(-j2πkn/N)) for n = 0 to N-1. For N = 4, the DFT results in: X[0] = 10, X[1] = -2 + 2j, X[2] = -2, X[3] = -2 - 2j.
10.Given a signal with a sampling rate of 1000 Hz, what is the frequency resolution of its DFT if the signal length is 500 samples?Numerical
The frequency resolution of a DFT is given by the formula: Δf = Fs / N, where Fs is the sampling rate and N is the number of samples. For a sampling rate of 1000 Hz and 500 samples, the frequency resolution is Δf = 1000 / 500 = 2 Hz.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?