Example: Given $x[n] = [1, 0, -1, 0]$, compute the DFT magnitude for $k = 0, 1, 2, 3$.
Computing one DFT coefficient (k=2)
Given the signal $x[n] = [1, 0, -1, 0]$ with $N = 4$, the DFT formula is:
$X[k] = \sum_{n=0}^{3} x[n] \cdot e^{-j \frac{2\pi}{4} k n}$
For $k = 2$, this becomes:
$X[2] = \sum_{n=0}^{3} x[n] \cdot e^{-j \pi n}$
because $\frac{2\pi}{4} \cdot 2 = \pi$.
Now expand the sum for each $n$:
$X[2] = x[0] \cdot e^{-j \pi \cdot 0} + x[1] \cdot e^{-j \pi \cdot 1} + x[2] \cdot e^{-j \pi \cdot 2} + x[3] \cdot e^{-j \pi \cdot 3}$
Substitute the signal values $x[0] = 1$, $x[1] = 0$, $x[2] = -1$, $x[3] = 0$:
$X[2] = 1 \cdot e^{0} + 0 \cdot e^{-j\pi} + (-1) \cdot e^{-j2\pi} + 0 \cdot e^{-j3\pi}$
Simplify using Euler's identity. Recall that:
- $e^{0} = 1$
- $e^{-j\pi} = -1$
- $e^{-j2\pi} = 1$
- $e^{-j3\pi} = -1$
Thus:
$X[2] = 1 \cdot 1 + 0 \cdot (-1) + (-1) \cdot 1 + 0 \cdot (-1) = 1 - 1 = 0$
Therefore, $X[2] = 0$.
Interpretation: The signal $x[n] = [1, 0, -1, 0]$ contains no energy at frequency $k = 2$ (which corresponds to $f = f_s/2$, the Nyquist frequency). This makes sense because the signal alternates every two samples, which is a different frequency component.
References:
Alan V. Oppenheim and Ronald W. Schafer, Discrete-Time Signal Processing, Prentice Hall, 3rd edition, 2010.
John G. Proakis and Dimitris G. Manolakis, Digital Signal Processing: Principles, Algorithms, and Applications, Pearson, 4th edition, 2006.
Richard G. Lyons, Understanding Digital Signal Processing, Pearson, 3rd edition, 2010.
Steven W. Smith, The Scientist and Engineer's Guide to Digital Signal Processing, California Technical Publishing, 1997. (Available online at dspguide.com)
Bob Meddins, Introduction to Digital Signal Processing, Butterworth-Heinemann, 2000.
See also: FFT Implementation Guide | Window Functions Overview