Frequency response H(e^jω)
About this lesson
Feed a sine into a linear, time-invariant system and a sine of the same frequency comes out, only scaled and shifted. The frequency response H(e^jω) says by how much, for every frequency. Follow a two-point average, y[n] = 0.5·x[n] + 0.5·x[n−1]: at ω = π/4 it passes 0.924 of the sine and delays it half a sample; at ω = π it cancels the sine completely. You will build H as a sum of arrows, read its gain and phase, see why it repeats every 2π, and compute it with scipy. It builds on the DTFT lesson, the impulse response lesson and complex exponentials.
A two-point average
This system averages each new sample with the one before: y[n] = 0.5·x[n] + 0.5·x[n−1]. A delay box keeps the previous input. Its impulse response is h = [0.5, 0.5]. What does it do to each frequency?
y[n] = 0.5·x[n] + 0.5·x[n−1] impulse response h[0] = 0.5, h[1] = 0.5 (finite: an FIR system, linear and time-invariant: LTI) parts: delay remembers x[n−1] for one tick ×0.5 two multipliers (the taps) + the adder
Read the lesson step by step
A two-point average
This system averages each new sample with the one before: y[n] = 0.5·x[n] + 0.5·x[n−1]. A delay box keeps the previous input. Its impulse response is h = [0.5, 0.5]. What does it do to each frequency?
y[n] = 0.5·x[n] + 0.5·x[n−1] impulse response h[0] = 0.5, h[1] = 0.5 (finite: an FIR system, linear and time-invariant: LTI) parts: delay remembers x[n−1] for one tick ×0.5 two multipliers (the taps) + the adderFeed it a sine
Feed it x[n] = cos(ω·n) with ω = π/4 radians per sample: 1000 Hz at 8000 samples a second. Each tick, x[n] and the stored x[n−1] are halved and added: y = 0.85, 0.85, 0.35, −0.35 ...
x[n] = cos(π/4 · n) (has run forever, so the delay holds x[−1]) n x[n] x[n−1] y[n] 0 1.00 0.71 0.85 1 0.71 1.00 0.85 2 0.00 0.71 0.35 3 −0.71 0.00 −0.35 4 −1.00 −0.71 −0.85 ω in radians per sample; f = ω·fs/2π π/4 × 8000 / 2π = 1000 HzOut comes the same sine
The output is a sine of the same frequency. Only two things changed: it is smaller (peak 0.924 instead of 1) and later (shifted by half a sample). A sine into an LTI (linear, time-invariant) system gives a sine out.
x[n] = cos(π/4 · n) y[n] = 0.924 · cos(π/4 · n − π/8) same frequency π/4 height × 0.924 shifted by π/8 rad = half a sample check n = 0: 0.924 × cos(−π/8) = 0.85Why: a spinning arrow goes in
Use the spinning arrow e^(jωn) = cos ωn + j·sin ωn. Delaying it one sample turns it back by ω: e^(jω(n−1)) = e^(jωn)·e^(−jω). So y[n] = (0.5 + 0.5·e^(−jω))·e^(jωn): the same arrow, times one number.
input x[n] = e^(jωn) delayed x[n−1] = e^(jω(n−1)) = e^(jωn)·e^(−jω) y[n] = 0.5·e^(jωn) + 0.5·e^(jωn)·e^(−jω) = (0.5 + 0.5·e^(−jω)) · e^(jωn) ^ one complex number e^(jωn) comes out unchanged in shape: an eigenfunction of every LTI system cos ωn = (e^(jωn) + e^(−jωn)) / 2H is a sum of arrows
That number is the frequency response: H(e^jω) = Σ h[k]·e^(−jωk). Add one arrow per tap: 0.5 at angle 0, then 0.5 turned by −ω. At ω = π/4 the sum ends at 0.854 − 0.354j.
H(e^jω) = Σ h[k]·e^(−jωk) = 0.5 + 0.5·e^(−jω) ω = π/4: 0.5·e^(−jπ/4) = 0.354 − 0.354j H = 0.5 + 0.354 − 0.354j = 0.854 − 0.354j this sum is the DTFT of h[n]Gain: the length |H|
The length of H is the gain: |H(e^jω)| = |cos(ω/2)|. At ω = π/4 it is 0.924, so a sine of height 1 comes out with height 0.924. The output amplitude is the input amplitude times |H|.
|H| = √(0.854² + 0.354²) = 0.924 closed form: 0.5 + 0.5·e^(−jω) = e^(−jω/2)·cos(ω/2) so |H(e^jω)| = |cos(ω/2)| cos(π/8) = 0.924 in decibels: 20·log10(0.924) = −0.69 dBPhase: the angle ∠H
The angle of H is the phase shift: ∠H = −ω/2 = −π/8 rad = −22.5°. The output sine is shifted back by 22.5°. Here that is a delay of half a sample (62.5 µs) at every frequency.
∠H = atan2(−0.354, 0.854) = −0.393 rad = −π/8 = −22.5° from e^(−jω/2)·cos(ω/2): ∠H = −ω/2 (for |ω| < π) delay = −∠H / ω = 0.5 sample = 0.5 / 8000 s = 62.5 µs phase straight in ω: linear phaseSweep the frequency
Turn the frequency from 0 to π. At ω = 0 (a constant) the arrows line up: gain 1. As ω rises, the second arrow swings away and the gain falls; half the power is lost at π/2. This average is a low-pass filter.
ω f (Hz) |H| ∠H 0 0 1.000 0° π/4 1000 0.924 −22.5° π/2 2000 0.707 −45.0° 3π/4 3000 0.383 −67.5° π 4000 0 (no angle) half power: |H|² = 0.5 at ω = π/2 (−3 dB) low frequencies pass, high ones are cutAt ω = π the output is zero
At ω = π (4000 Hz) the input flips sign every sample: 1, −1, 1, −1. Each sample plus the one before is 0, so y[n] = 0. The two arrows point opposite ways and cancel: |H(e^jπ)| = 0.
x[n] = cos(π·n) = 1, −1, 1, −1 ... y[n] = 0.5·x[n] + 0.5·x[n−1] = 0 H(e^jπ) = 0.5 + 0.5·e^(−jπ) = 0.5 − 0.5 = 0 π rad per sample = fs/2 = 4000 Hz: the fastest a sampled sine can swingIt repeats every 2π
ω and ω + 2π give the same samples, because e^(j2πn) = 1. So H repeats every 2π. With a real h[n], |H| is mirror-symmetric, so 0 to π (0 to fs/2) tells everything. In hertz: f = ω·fs/(2π).
e^(j(ω+2π)n) = e^(jωn)·e^(j2πn) = e^(jωn) so H(e^j(ω+2π)) = H(e^jω) real h[n]: H(e^−jω) = H(e^jω)* (conjugate) |H| even, ∠H odd ω = 2π − π/4 = 7π/4 acts like −π/4: |H| = 0.924, ∠H = +22.5° f = ω·fs/2π: π -> 4000 Hz, 2π -> 8000 HzIn Python: scipy's freqz
In Python 3, scipy.signal.freqz evaluates H(e^jω) = Σ b[k]·e^(−jωk) at the frequencies w. abs(H) gives the gains [0.924, 0]; np.angle gives the phase, −0.393 rad. H is the DTFT of h[n].
import numpy as np from scipy.signal import freqz w = [np.pi/4, np.pi] _, H = freqz([0.5, 0.5], worN=w) print(abs(H).round(3)) print(np.angle(H[0])) prints: [0.924 0. ] -0.39269908169872414 (numpy 2.5.4, scipy 1.18.1) freqz's default fs = 2π: w in rad/sample pass fs=8000 to work in hertz instead
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01A sine of frequency ω goes into an LTI system. What comes out (after any start-up transient)?
Complex exponentials are eigenfunctions of LTI systems: e^(jωn) comes out as H(e^jω)·e^(jωn). A real sine is two of them, so it comes out as the same sine, multiplied by |H| and shifted by ∠H.
02A system has h = [0.5, 0.5]. What is H(e^jω) at ω = π/2?
H = 0.5 + 0.5·e^(−jπ/2) = 0.5 + 0.5·(−j) = 0.5 − 0.5j. Its length is 0.707 (half the power) and its angle is −45°.
03At fs = 8000 samples a second, which frequency in hertz is ω = π/2 rad per sample?
f = ω·fs/(2π) = (π/2) × 8000 / (2π) = 2000 Hz. ω = π is fs/2 = 4000 Hz, the highest frequency a sampled sine can show.
04For the two-point average, the phase is ∠H = −ω/2. What does that do to a sine at any frequency (below π)?
A phase of −ω/2 at frequency ω is a time shift of (ω/2)/ω = 0.5 sample. A phase that is a straight line in ω (linear phase) delays every frequency by the same time.
05Why is it enough to look at H(e^jω) for 0 ≤ ω ≤ π when h[n] is real?
e^(j(ω+2π)n) = e^(jωn), so H repeats every 2π. For a real h, H(e^−jω) is the conjugate of H(e^jω): the gain is mirror-symmetric, so 0 to π (0 to fs/2) holds all the information.
Glossary
- Frequency response H(e^jω)
- The complex number an LTI system multiplies e^(jωn) by, for each frequency ω: H(e^jω) = Σ h[k]·e^(−jωk), the DTFT of the impulse response.
- ω (radians per sample)
- The frequency of a sampled signal: how far the arrow e^(jωn) turns from one sample to the next. In hertz, f = ω·fs/(2π).
- Gain (magnitude) |H|
- The length of H: how much the system scales a sine of that frequency. 20·log10|H| gives it in decibels.
- Phase ∠H
- The angle of H: how far the system shifts a sine of that frequency, in radians or degrees.
- Eigenfunction
- An input that comes out of a system unchanged in shape, only multiplied by a number. For LTI systems the complex exponentials e^(jωn) are eigenfunctions.
- Linear phase
- A phase that is a straight line in ω, such as −ω/2. It delays every frequency by the same time.
- Low-pass filter
- A system that passes low frequencies and weakens high ones, like the two-point average (gain 1 at ω = 0, 0 at ω = π).
Notes and sources
- The taps 0.5 and 0.5 and the rate of 8000 samples a second are chosen to keep the numbers short. Every value, curve and arrow in the figure is computed from this model.
- The input sine is taken to have been running forever, so the delay box already holds x[−1] = cos(−ω). A sine switched on at n = 0 gives one different first output (a short transient), then the same steady sine.
- In the time plot the dots are the samples; the thin lines only join them along the sinusoid they lie on.
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing, 2nd ed., §2.6 (frequency response, eigenfunctions) (required text on MIT OCW 6.341 readings)
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson (ch. 5 the DTFT; ch. 6 magnitude and phase of the frequency response)
- MIT OpenCourseWare 6.341 Discrete-Time Signal Processing (A. V. Oppenheim)
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011)
- SciPy documentation: scipy.signal.freqz (H(e^jω) = B(e^jω)/A(e^jω); default fs = 2π)
- NumPy documentation: numpy.angle (radians in (−π, π])
- Linear time-invariant system (Wikipedia): exponentials are eigenfunctions; the DTFT gives their eigenvalues
- Discrete-time Fourier transform (Wikipedia): 2π-periodic in ω
- Moving average (Wikipedia): viewed as a low-pass FIR filter
Quiz Unlocks after the last step.