The DTFT: the spectrum of a sampled signal
About this lesson
The discrete-time Fourier transform (DTFT) gives the spectrum of a sampled signal: X(e^jω) = Σ x[n]·e^(−jωn). Watch it work on four samples of a pulse. For one test frequency ω, every sample turns into an arrow; the arrows are added head to tail, and the length of the sum says how much of that frequency the signal holds. Sweep ω and the lengths draw the spectrum, which repeats every 2π, just like the spectrum copies from sampling. It builds on "Sampling in the frequency domain: spectrum copies" and reads e^(−jωn) as the spinning arrow from "Complex exponentials: growing, decaying and spinning" (complex numbers are in the Maths lessons); it ends with numpy and points to the DFT.
Four samples of a pulse
A converter samples a short pulse 8000 times a second. We keep four samples: x[0] to x[3] are all 1, and every other x[n] is 0. The pulse lasts 4/8000 s = 0.5 ms.
x[n] = 1 for n = 0, 1, 2, 3 x[n] = 0 for every other n fs = 8000 samples per second 4 samples × 1/8000 s = 0.5 ms question: which frequencies make up this pulse?
Read the lesson step by step
Four samples of a pulse
A converter samples a short pulse 8000 times a second. We keep four samples: x[0] to x[3] are all 1, and every other x[n] is 0. The pulse lasts 4/8000 s = 0.5 ms.
x[n] = 1 for n = 0, 1, 2, 3 x[n] = 0 for every other n fs = 8000 samples per second 4 samples × 1/8000 s = 0.5 ms question: which frequencies make up this pulse?Pick a test frequency ω
The spectrum says how much of each frequency a signal holds. We test one frequency at a time. For samples, frequency ω is measured in radians per sample: ω = 2π·f/fs. Here ω = π/4, which is 1000 Hz.
ω = 2π · f / fs (radians per sample) ω = π/4 = 0.785 rad/sample f = ω · fs / 2π = 8000 / 8 = 1000 Hz radian: the angle where the arc equals the radius; π rad = 180° so π/4 = 45° per samplee^−jωn: an arrow that turns
For each n, e^(−jωn) = cos(ωn) − j·sin(ωn). That is an arrow of length 1 at angle −ωn. From one sample to the next it turns by ω. At ω = π/4 the arrows point to 0°, −45°, −90° and −135°.
e^(−jθ) = cos θ − j sin θ (Euler) length 1, angle −θ n = 0: angle 0° -> 1 n = 1: angle −45° -> 0.71 − 0.71j n = 2: angle −90° -> −j n = 3: angle −135° -> −0.71 − 0.71j spinning arrows: see "Complex exponentials: growing, decaying and spinning"; complex numbers: the Maths lessonsMultiply each sample by its arrow
Each sample scales its own arrow: x[n]·e^(−jωn). A bigger sample makes a longer arrow; a zero sample makes no arrow at all. All four samples here are 1, so every arrow keeps length 1.
term n = x[n] · e^(−jωn) x[0..3] = 1 -> arrows unchanged x[n] = 0 elsewhere -> no arrow so the sum has only four terms, though it runs over every nAdd the arrows head to tail
Add the arrows by placing each one where the last one ends. The sum is the DTFT at this ω: X(e^jπ/4) = 1.00 − 2.41j. Its length, |X| = 2.61, says how much of 1000 Hz the pulse holds.
X(e^jω) = Σ x[n] · e^(−jωn) X(e^jπ/4) = 1 + (0.71 − 0.71j) + (−j) + (−0.71 − 0.71j) = 1.00 − 2.41j |X| = 2.613 (the length) angle = −67.5° (the phase)ω = 0: all arrows agree
Turn the test frequency down to ω = 0. Every arrow now points the same way, so they add up fully: X(e^j0) = x[0] + x[1] + x[2] + x[3] = 4. A pulse holds a lot of the slowest frequencies.
ω = 0: e^(−j·0·n) = 1 for every n X(e^j0) = Σ x[n] = 1 + 1 + 1 + 1 = 4.00 the largest |X| can be here: all four arrows are alignedω = π/2: the arrows cancel
At ω = π/2 (2000 Hz) the arrows turn 90° each time: right, down, left, up. Head to tail they close a square and end where they began. The sum is 0: this pulse holds none of 2000 Hz.
ω = π/2 = 90° per sample 1 + (−j) + (−1) + (+j) = 0 X(e^jπ/2) = 0.00 a zero of the spectrum: the arrows cancel exactlySweep ω: the spectrum
Now sweep ω from −π to π and plot the length |X| each time. The result is the spectrum of the pulse: tall at ω = 0, zero at ±π/2 and ±π. The DTFT gives a value at every ω, not just a few.
|X(e^jω)| = |sin(2ω) / sin(ω/2)| (the sum of four arrows, in closed form) ω = 0 |X| = 4.00 ω = π/4 |X| = 2.61 ω = π/2 |X| = 0.00 ω = π |X| = 0.00 ω is a real number: X is a continuous function of ωIt repeats every 2π
Keep turning past π. Since n is a whole number, adding 2π to ω turns each arrow by whole circles, so nothing changes. The DTFT repeats every 2π: the spectrum copies sampling makes. Only −π to π (±4000 Hz) is new.
e^(−j(ω+2π)n) = e^(−jωn) · e^(−j2πn) = e^(−jωn) (n whole) so X(e^j(ω+2π)) = X(e^jω) ω = π <-> f = fs/2 = 4000 Hz ω = 2π <-> f = fs = 8000 Hz see "Sampling in the frequency domain: spectrum copies"The DTFT in Python
With numpy (Python 3) the sum is one line: np.exp makes the arrows and np.sum adds them. A computer can only try a finite list of ω values. Choosing them well is the DFT, the next lesson.
import numpy as np x, n = np.ones(4), np.arange(4) w = np.pi / 4 X = np.sum(x * np.exp(-1j*w*n)) >>> print(np.round(X, 2)) (1-2.41j) >>> print(abs(X)) 2.613125929752753 # many ω at once: w = np.linspace(-np.pi, np.pi, 801) X = np.exp(-1j*np.outer(w, n)) @ x
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01A signal is sampled at fs = 8000 samples per second. Which ω (radians per sample) matches a tone at 2000 Hz?
ω = 2π·f/fs = 2π × 2000 / 8000 = π/2.
02In the DTFT, what is e^(−jωn)?
By Euler's formula e^(−jωn) = cos(ωn) − j·sin(ωn). Its length is always 1 and its angle is −ωn, so it turns by ω from one sample to the next.
03For x[n] = 1 at n = 0, 1, 2, 3 (and 0 elsewhere), what is X(e^j0)?
At ω = 0 every arrow is 1, so X(e^j0) = x[0] + x[1] + x[2] + x[3] = 4.
04Why is X(e^j(ω+2π)) always equal to X(e^jω)?
n is a whole number, so adding 2π to ω adds 2πn to each angle: whole turns. Every arrow ends where it was, so the sum is the same. This holds for any x[n], periodic or not.
05Why can a computer not calculate the whole DTFT exactly as a list of numbers?
The DTFT is a continuous function of ω. A computer evaluates it at a finite set of ω values; picking N evenly spaced ones is the DFT, the next lesson.
Glossary
- DTFT
- Discrete-time Fourier transform: X(e^jω) = Σ x[n]·e^(−jωn), the spectrum of a sequence x[n] as a function of ω.
- ω (normalised frequency)
- Frequency of a sampled signal in radians per sample; ω = 2π·f/fs, so ω = π is half the sampling rate.
- Radian
- The angle at which an arc of a circle is as long as its radius; π radians = 180°.
- j and complex numbers
- j is the imaginary unit, the number with j² = −1. A complex number a + b·j has a real part a and an imaginary part b; draw it as the point (a, b), or an arrow from 0 to it.
- Phasor (arrow)
- A complex number drawn as an arrow from 0; e^(−jθ) has length 1 and angle −θ.
- Magnitude |X|
- The length of the complex number X(e^jω): how much of frequency ω the signal holds.
- Phase
- The angle of X(e^jω); for the four-sample pulse it is −1.5ω (plus π where sin(2ω)/sin(ω/2) is negative).
- Periodic in 2π
- X(e^j(ω+2π)) = X(e^jω) for every sequence, because e^(−j2πn) = 1 for whole n.
Notes and sources
- The four samples of 1 are a chosen example; 8000 samples a second is the telephone rate used in "What a signal is". Every arrow, sum and curve in the figure is computed from the DTFT definition in this model.
- Some books write the DTFT as X(ω) or X(Ω); this lesson follows Oppenheim & Schafer and writes X(e^jω), a reminder that it depends on ω only through e^jω and so repeats every 2π.
- On the dials the real part points right and the imaginary part points to the back of the table, so −j points toward you; in the flat plot −j points down.
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson (ch. 5: The Discrete-Time Fourier Transform)
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing, 2nd ed. (course text listed on MIT OCW 6.341 readings)
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011)
- MIT OpenCourseWare RES.6-007 Signals and Systems (A. V. Oppenheim)
- Discrete-time Fourier transform (Wikipedia): definition, ω = 2πfT in radians per sample, period 2π, DFT as samples of one period
- NumPy documentation: numpy.exp (complex arguments: e^(ib) = cos b + i sin b)
- NumPy documentation: numpy.arange
- NumPy documentation: numpy.linspace
Quiz Unlocks after the last step.