TExcelTAD
Home › Fourier Analysis & Signals › Frequency Response

Frequency Response

The frequency response H(s)=h^(s)H(s) = \hat{h}(s) is the impulse response seen in the frequency domain: for each frequency, a complex number whose magnitude is the gain and whose angle is the phase shift the system applies. Because LTI systems only scale and shift sinusoids, the frequency response describes the system completely, and it is how audio equipment, filters and control loops are specified.

Definition for discrete systems

For a discrete system with impulse response h[n]h[n], the frequency response is a function of the normalized frequency ω\omega (radians per sample, −π<ω≤π-\pi < \omega \le \pi):

H(eiω)=∑nh[n] e−iωnH(e^{i\omega}) = \sum_n h[n]\, e^{-i\omega n}

Feeding x[n]=cos⁡(ωn)x[n] = \cos(\omega n) produces y[n]=∣H∣cos⁡(ωn+arg⁡H)y[n] = \lvert H \rvert \cos(\omega n + \arg H). With sampling rate fsf_s, ω=2πf/fs\omega = 2\pi f / f_s, so ω=π\omega = \pi corresponds to fs/2f_s/2.

python · try it yourself
import numpy as np

h = np.array([0.25, 0.5, 0.25])                    # a tiny smoothing filter
def H(w):
    return np.sum(h * np.exp(-1j * w * np.arange(len(h))))

for w in (0, np.pi / 4, np.pi / 2, 3 * np.pi / 4, np.pi):
    print(f"omega = {w / np.pi:.2f} pi: gain {abs(H(w)):.4f}   phase {np.angle(H(w)) + 0.0:+.4f} rad")

n = np.arange(200)
x = np.cos(np.pi / 4 * n)
y = np.convolve(x, h)[:200]
print("measured output amplitude at pi/4:", round(np.max(np.abs(y[50:])), 4))
omega = 0.00 pi: gain 1.0000   phase +0.0000 rad
omega = 0.25 pi: gain 0.8536   phase -0.7854 rad
omega = 0.50 pi: gain 0.5000   phase -1.5708 rad
omega = 0.75 pi: gain 0.1464   phase -2.3562 rad
omega = 1.00 pi: gain 0.0000   phase +0.0000 rad
measured output amplitude at pi/4: 0.8536

The gain cos⁡2(ω/2)\cos^2(\omega/2) falls from 1 at DC to 0 at ω=π\omega = \pi: a low-pass filter. The phase −ω-\omega is linear, meaning every frequency is delayed by the same 1 sample.

Gain in decibels and the Bode plot

Gains are usually shown in decibels, 20log⁡10∣H∣20\log_{10}\lvert H \rvert, against log frequency (a Bode plot). −3-3 dB means half power; −20-20 dB means the amplitude is divided by 10.

python · try it yourself
import numpy as np

fs = 48000
a = 0.9                                            # one-pole low-pass y[n] = a y[n-1] + (1-a) x[n]
for f in (10, 100, 300, 1000, 3000, 10000, 24000):
    w = 2 * np.pi * f / fs
    H = (1 - a) / (1 - a * np.exp(-1j * w))
    print(f"{f:6d} Hz: {round(20 * np.log10(abs(H)), 2) + 0.0:7.2f} dB   phase {round(np.degrees(np.angle(H)), 2) + 0.0:7.2f} deg")
    10 Hz:    0.00 dB   phase   -0.67 deg
   100 Hz:   -0.07 dB   phase   -6.71 deg
   300 Hz:   -0.56 dB   phase  -19.34 deg
  1000 Hz:   -4.05 dB   phase  -47.49 deg
  3000 Hz:  -11.67 dB   phase  -63.93 deg
 10000 Hz:  -21.28 dB   phase  -48.58 deg
 24000 Hz:  -25.58 dB   phase    0.00 deg

The gain drops through −3-3 dB near 800 Hz and then falls about 6 dB per doubling of frequency, the signature of a first-order filter.

Cascades multiply

Two systems in series have impulse response h1∗h2h_1 * h_2 and therefore frequency response H1H2H_1 H_2: gains multiply (decibels add) and phases add. This is why filters are designed as cascades of simple sections.

In software

  • scipy.signal.freqz(b, a) evaluates H(eiω)H(e^{i\omega}) of a digital filter; freqs does the same for analog ones.
  • Headphone and room correction measure HH and apply an equalizer approximating 1/H1/H in the bands where that is safe.

Exercises

Exercise 1: Gain of a difference

What is the frequency response of h=[1,−1]h = [1, -1], and which frequencies does it remove?

Answer

H=1−e−iωH = 1 - e^{-i\omega} with ∣H∣=2∣sin⁡(ω/2)∣\lvert H \rvert = 2\lvert \sin(\omega/2) \rvert; it removes DC.

Solution

∣1−e−iω∣=∣e−iω/2∣⋅∣eiω/2−e−iω/2∣=2∣sin⁡(ω/2)∣\lvert 1 - e^{-i\omega} \rvert = \lvert e^{-i\omega/2} \rvert \cdot \lvert e^{i\omega/2} - e^{-i\omega/2} \rvert = 2\lvert \sin(\omega/2) \rvert, zero at ω=0\omega = 0 and 2 at ω=π\omega = \pi. A differencer is a high-pass filter.

Exercise 2: Decibels

A system has gain −40-40 dB at 10 kHz. By what factor does it reduce the amplitude?

Answer

By 100.

Solution

20log⁡10g=−4020 \log_{10} g = -40 gives g=10−2g = 10^{-2}.

Exercise 3: Cascade (code)

Cascade the smoother [0.25,0.5,0.25][0.25, 0.5, 0.25] with itself. What is the gain at ω=π/2\omega = \pi/2?

Answer

0.25, the square of the single filter's 0.5.

Solution
python · try it yourself
import numpy as np
h = np.array([0.25, 0.5, 0.25])
h2 = np.convolve(h, h)
w = np.pi / 2
H2 = np.sum(h2 * np.exp(-1j * w * np.arange(len(h2))))
print(h2.tolist(), round(abs(H2), 4))
[0.0625, 0.25, 0.375, 0.25, 0.0625] 0.25

Test yourself

The magnitude of the frequency response at ω\omega is…

  1. the delay
  2. the gain applied to a sinusoid at ω\omega
  3. the impulse response at ω\omega
  4. always 1

Two filters in series have frequency response…

  1. H1+H2H_1 + H_2
  2. H1H2H_1 H_2
  3. H1∗H2H_1 * H_2
  4. max⁡(H1,H2)\max(H_1, H_2)

In a digital system, normalized frequency ω=π\omega = \pi corresponds to…

  1. 0 Hz
  2. fsf_s
  3. fs/2f_s / 2
  4. 2fs2 f_s