Chapter 8Part I: Foundations

Digital Filter Design

Digital filters are the workhorses of modern signal processing, enabling precise manipulation of frequency content in discrete-time systems. This chapter covers both FIR and IIR filter design techniques, from classical windowing methods to the bilinear transform, along with practical implementation structures and classic analog prototypes.

8.1 FIR vs IIR Filters

Digital filters fall into two broad categories based on the duration of their impulse response. A Finite Impulse Response (FIR) filter has an impulse response that settles to zero in finite time, while an Infinite Impulse Response (IIR) filter has an impulse response that continues indefinitely (though it decays for stable filters).

Definition 8.1 --- FIR Filter

An FIR filter of order $M$ is defined by:

$$y[n] = \sum_{k=0}^{M} b_k \, x[n-k]$$

The transfer function is a polynomial in $z^{-1}$:

$$H(z) = \sum_{k=0}^{M} b_k z^{-k}$$

All poles are at the origin ($z = 0$), so FIR filters are always stable.

Definition 8.2 --- IIR Filter

An IIR filter is defined by a recursive difference equation:

$$y[n] = \sum_{k=0}^{M} b_k \, x[n-k] - \sum_{k=1}^{N} a_k \, y[n-k]$$

The transfer function is a rational function:

$$H(z) = \frac{\sum_{k=0}^{M} b_k z^{-k}}{1 + \sum_{k=1}^{N} a_k z^{-k}}$$

Stability requires all poles to lie strictly inside the unit circle: $|p_i| < 1$ for all poles $p_i$.

PropertyFIRIIR
StabilityAlways stable (no feedback)May be unstable; must check pole locations
Linear PhaseEasily achieved with symmetric coefficientsCannot achieve (except in special cases)
Filter OrderTypically high (20--200+ taps)Low order (2--10) achieves sharp cutoffs
Computation$M+1$ multiplies per sample$M + N + 1$ multiplies per sample
Design from AnalogNo direct analog counterpartDirect mapping via bilinear transform
Typical UseAudio, communications, imagingControl systems, audio equalization

When to choose FIR: When linear phase is essential (e.g., data communications, medical imaging), when guaranteed stability is critical, or when the filter will be implemented on an FPGA/ASIC where fixed-point arithmetic requires predictable behavior.

When to choose IIR: When computational efficiency matters and a sharp transition band is needed with few coefficients, when mimicking analog filter behavior, or in real-time control systems where low group delay is more important than linear phase.

8.2 FIR Design by Windowing

The windowing method is the most intuitive approach to FIR filter design. We start from the ideal (but unrealizable) frequency response and truncate its impulse response to a finite length, applying a window function to control spectral leakage.

Theorem 8.1 --- Ideal Low-Pass Impulse Response

The ideal low-pass filter with cutoff frequency $\omega_c$ has the impulse response:

$$h_d[n] = \frac{\sin(\omega_c n)}{\pi n}, \quad -\infty < n < \infty$$

This is the sinc function, which extends infinitely in both directions and is therefore not directly realizable. The windowing method truncates and shifts this to produce a causal, finite-length filter.

Design steps:

  1. Specify the desired frequency response $H_d(e^{j\omega})$
  2. Compute the ideal impulse response $h_d[n]$ via the inverse DTFT
  3. Truncate to length $M+1$ and apply a delay of $M/2$ samples for causality
  4. Multiply by a window function $w[n]$ to reduce sidelobe effects
  5. The resulting filter is $h[n] = h_d[n - M/2] \cdot w[n]$ for $0 \le n \le M$

Definition 8.3 --- Common Window Functions

For a filter of length $N = M + 1$:

Rectangular: $w[n] = 1$

Hann: $w[n] = 0.5 - 0.5\cos\!\left(\frac{2\pi n}{M}\right)$

Hamming: $w[n] = 0.54 - 0.46\cos\!\left(\frac{2\pi n}{M}\right)$

Blackman: $w[n] = 0.42 - 0.5\cos\!\left(\frac{2\pi n}{M}\right) + 0.08\cos\!\left(\frac{4\pi n}{M}\right)$

Theorem 8.2 --- Kaiser Window

The Kaiser window provides a continuous trade-off between main-lobe width and sidelobe level through the parameter $\beta$:

$$w[n] = \frac{I_0\!\left(\beta\sqrt{1 - \left(\frac{2n}{M} - 1\right)^2}\right)}{I_0(\beta)}$$

where $I_0$ is the zeroth-order modified Bessel function. The parameter $\beta$ is chosen from the desired stopband attenuation $A_s$ (in dB):

$$\beta = \begin{cases} 0.1102(A_s - 8.7) & A_s > 50 \\ 0.5842(A_s - 21)^{0.4} + 0.07886(A_s - 21) & 21 \le A_s \le 50 \\ 0 & A_s < 21 \end{cases}$$

The required filter order is approximately:

$$M \approx \frac{A_s - 7.95}{2.285 \cdot \Delta\omega}$$

where $\Delta\omega$ is the transition width in radians.

Example 8.1 --- FIR Low-Pass Filter Design (Window Method)

We design a low-pass FIR filter with normalized cutoff $\omega_c = 0.2\pi$ and order $M = 50$, comparing the frequency response for rectangular, Hann, Hamming, and Blackman windows. Notice how the sidelobe level decreases at the expense of a wider transition band.

FIR Low-Pass Filter Design (Window Method)

Click Run to execute the Python code

First run will download Python environment (~15MB)

8.3 FIR Design by Frequency Sampling

An alternative to the windowing method is to specify the desired frequency response at$N$ equally-spaced frequency points and obtain the filter coefficients via the inverse DFT.

Theorem 8.3 --- Frequency Sampling Method

Given $N$ desired frequency samples $H_d[k]$ at frequencies$\omega_k = 2\pi k / N$ for $k = 0, 1, \ldots, N-1$, the FIR filter coefficients are:

$$h[n] = \frac{1}{N} \sum_{k=0}^{N-1} H_d[k] \, e^{j 2\pi k n / N}, \quad 0 \le n \le N-1$$

The resulting filter interpolates exactly through the specified frequency samples. Between sample points, the response is determined by the DFT interpolation kernel.

Limitations: The frequency sampling method guarantees the response only at the $N$ sampled points. Between these points, the response may exhibit significant ripple, especially in the transition band. This can be mitigated by optimizing transition-band samples (choosing values between 0 and 1) rather than using abrupt jumps. The method is most useful when the filter length matches a convenient FFT size.

8.4 IIR Design: Bilinear Transform

The bilinear transform is the most widely used technique for designing IIR digital filters. It maps an analog prototype filter $H_a(s)$ to a digital filter $H(z)$by the substitution:

Theorem 8.4 --- Bilinear Transform

The bilinear transform maps the $s$-plane to the $z$-plane via:

$$s = \frac{2}{T} \cdot \frac{1 - z^{-1}}{1 + z^{-1}}$$

Equivalently, $z = \frac{1 + sT/2}{1 - sT/2}$. Key properties:

  • The entire $j\Omega$-axis maps to the unit circle (no aliasing)
  • The left half-plane maps to the interior of the unit circle (stability preserved)
  • The right half-plane maps to the exterior of the unit circle

Definition 8.4 --- Frequency Warping

The bilinear transform introduces a nonlinear mapping between analog frequency $\Omega$ and digital frequency $\omega$:

$$\Omega = \frac{2}{T} \tan\!\left(\frac{\omega}{2}\right)$$

This warping compresses the entire analog frequency axis $(-\infty, +\infty)$ into the digital range $(-\pi, +\pi)$. The relationship is approximately linear for low frequencies ($\omega \ll \pi$) but becomes increasingly nonlinear near Nyquist.

Definition 8.5 --- Pre-Warping

To ensure that the critical frequencies of the digital filter match the desired specifications, we pre-warp the analog prototype frequencies:

$$\Omega_c = \frac{2}{T} \tan\!\left(\frac{\omega_c}{2}\right)$$

where $\omega_c$ is the desired digital cutoff and $\Omega_c$ is the analog cutoff used in the prototype design. This guarantees the magnitude response at the critical frequency is preserved exactly.

Example 8.2 --- Bilinear Transform Design Procedure

To design a digital low-pass Butterworth filter with cutoff $\omega_c = 0.4\pi$ at sampling rate $f_s = 1000$ Hz:

  1. Pre-warp: $\Omega_c = \frac{2}{T}\tan(\omega_c / 2) = 2f_s \tan(0.2\pi) \approx 1453.1$ rad/s
  2. Design analog Butterworth with cutoff $\Omega_c$
  3. Apply the substitution $s \to \frac{2}{T}\frac{1 - z^{-1}}{1 + z^{-1}}$
  4. Simplify to obtain $H(z) = \frac{b_0 + b_1 z^{-1} + b_2 z^{-2}}{1 + a_1 z^{-1} + a_2 z^{-2}}$

8.5 Classic Analog Prototypes

IIR digital filter design leverages well-studied families of analog filters, each offering a different trade-off between passband flatness, stopband attenuation, transition width, and phase response.

Definition 8.6 --- Butterworth (Maximally Flat)

The Butterworth filter of order $N$ has the squared magnitude response:

$$|H_a(j\Omega)|^2 = \frac{1}{1 + \left(\Omega / \Omega_c\right)^{2N}}$$

This is maximally flat at $\Omega = 0$: the first $2N - 1$ derivatives of the magnitude response are zero at DC. All Butterworth filters pass through$|H| = 1/\sqrt{2}$ (i.e., $-3$ dB) at $\Omega = \Omega_c$.

Definition 8.7 --- Chebyshev Type I (Equiripple Passband)

The Chebyshev Type I filter distributes the approximation error uniformly across the passband:

$$|H_a(j\Omega)|^2 = \frac{1}{1 + \varepsilon^2 T_N^2(\Omega / \Omega_c)}$$

where $T_N$ is the Chebyshev polynomial of degree $N$ and $\varepsilon$ controls the passband ripple. For a given order, it provides a sharper transition than Butterworth at the cost of equiripple variations in the passband.

Definition 8.8 --- Chebyshev Type II (Equiripple Stopband)

The Type II Chebyshev (inverse Chebyshev) filter is monotonic in the passband with equiripple in the stopband:

$$|H_a(j\Omega)|^2 = \frac{1}{1 + \left[\varepsilon^2 T_N^2(\Omega_c / \Omega)\right]^{-1}}$$

This provides a flat passband (like Butterworth) while achieving better stopband attenuation for a given order.

Definition 8.9 --- Elliptic (Cauer) Filter

The elliptic filter has equiripple behavior in both the passband and stopband:

$$|H_a(j\Omega)|^2 = \frac{1}{1 + \varepsilon^2 R_N^2(\Omega / \Omega_c)}$$

where $R_N$ is the Chebyshev rational function. Elliptic filters achieve the narrowest transition band for a given order, passband ripple, and stopband attenuation, making them optimal in the min-max sense.

Filter TypePassbandStopbandTransitionPhase
ButterworthMaximally flatMonotonicWidestMost linear
Chebyshev IEquirippleMonotonicNarrowerLess linear
Chebyshev IIMonotonicEquirippleNarrowerLess linear
EllipticEquirippleEquirippleNarrowestLeast linear

8.6 Butterworth Filter Design

The Butterworth filter is the most commonly used analog prototype due to its maximally flat magnitude response. We derive the complete design procedure, including order selection and pole placement.

Theorem 8.5 --- Butterworth Magnitude Response

Starting from the design requirement that $|H(j\Omega)|^2$ be maximally flat at$\Omega = 0$, we seek a polynomial approximation of the form:

$$|H_a(j\Omega)|^2 = \frac{1}{1 + \left(\frac{\Omega}{\Omega_c}\right)^{2N}}$$

At the cutoff frequency $\Omega = \Omega_c$:

$$|H_a(j\Omega_c)|^2 = \frac{1}{2} \implies |H_a(j\Omega_c)| = \frac{1}{\sqrt{2}} \approx -3 \text{ dB}$$

Theorem 8.6 --- Butterworth Order Calculation

Given passband specifications (attenuation $A_p$ dB at frequency $\Omega_p$) and stopband specifications (attenuation $A_s$ dB at frequency $\Omega_s$), the minimum filter order is:

$$N = \left\lceil \frac{\log\!\left(\frac{10^{A_s/10} - 1}{10^{A_p/10} - 1}\right)}{2\log(\Omega_s / \Omega_p)} \right\rceil$$

Theorem 8.7 --- Butterworth Pole Placement

The poles of the normalized ($\Omega_c = 1$) Butterworth filter of order $N$are located at:

$$s_k = e^{j\pi(2k + N + 1)/(2N)}, \quad k = 0, 1, \ldots, 2N-1$$

The $N$ left-half-plane poles (those with $\text{Re}(s_k) < 0$) are used to form the stable transfer function. These poles are equally spaced on the left half of the unit circle in the $s$-plane.

The transfer function is:

$$H_a(s) = \frac{\Omega_c^N}{\prod_{k} (s - s_k)}, \quad \text{Re}(s_k) < 0$$

Example 8.3 --- Butterworth Filter: Order vs Response

We visualize how increasing the filter order $N$ sharpens the transition from passband to stopband while maintaining the maximally flat characteristic. All curves pass through$-3$ dB at the cutoff frequency $\Omega_c$.

Butterworth Filter: Order vs Response

Click Run to execute the Python code

First run will download Python environment (~15MB)

8.7 Direct-Form II Transposed Implementation

The choice of implementation structure significantly affects numerical precision, especially in fixed-point or limited-precision arithmetic. The Direct-Form II Transposed (DF2T) structure is preferred for floating-point implementations due to its superior numerical properties.

Definition 8.10 --- Direct-Form II Transposed

For a second-order section with transfer function:

$$H(z) = \frac{b_0 + b_1 z^{-1} + b_2 z^{-2}}{1 + a_1 z^{-1} + a_2 z^{-2}}$$

The DF2T state equations are:

$$y[n] = b_0 \, x[n] + w_1[n-1]$$

$$w_1[n] = b_1 \, x[n] - a_1 \, y[n] + w_2[n-1]$$

$$w_2[n] = b_2 \, x[n] - a_2 \, y[n]$$

This requires only 2 state variables (delay elements) regardless of the section order, compared to 4 for Direct-Form I.

Advantages of DF2T over Direct-Form I:

  • Half the number of delay elements (memory savings)
  • Better numerical accuracy in floating-point arithmetic
  • Smaller internal signal range (less overflow risk)
  • The output is computed first, then fed back to update states, which reduces round-off error accumulation

Practical note: Higher-order IIR filters should be implemented as a cascade of second-order sections (biquads) rather than a single high-order structure, to avoid severe coefficient sensitivity problems.

Example 8.4 --- IIR Filter Applied to a Noisy Signal

We implement a 2nd-order Butterworth low-pass filter using the Direct-Form II Transposed structure. The filter coefficients are derived from the bilinear transform with pre-warping for a cutoff of 20 Hz at $f_s = 1000$ Hz.

Apply IIR Filter to Noisy Signal

Click Run to execute the Python code

First run will download Python environment (~15MB)

8.8 Linear Phase FIR Filters

A filter has linear phase if its phase response is of the form $\angle H(e^{j\omega}) = -\alpha\omega + \beta$, where $\alpha$ is the group delay (constant) and $\beta \in \{0, \pi/2\}$. Linear phase ensures that all frequency components experience the same delay, preventing waveform distortion.

Theorem 8.8 --- Conditions for Linear Phase

An FIR filter $h[n]$ of length $N = M + 1$ has a linear (or generalized linear) phase response if and only if it has symmetric or antisymmetric coefficients:

$$h[n] = \pm\, h[M - n], \quad 0 \le n \le M$$

The group delay is $\alpha = M/2$ samples for all four types.

Definition 8.11 --- Four Types of Linear Phase FIR Filters

Type I: Symmetric, odd length ($M$ even)

$h[n] = h[M - n]$. Can implement any filter type (LP, HP, BP, BS).

Type II: Symmetric, even length ($M$ odd)

$h[n] = h[M - n]$. Has a zero at $\omega = \pi$ (Nyquist). Cannot implement high-pass or band-stop filters.

Type III: Antisymmetric, odd length ($M$ even)

$h[n] = -h[M - n]$. Has zeros at both $\omega = 0$ and $\omega = \pi$. Used for differentiators and Hilbert transforms.

Type IV: Antisymmetric, even length ($M$ odd)

$h[n] = -h[M - n]$. Has a zero at $\omega = 0$. Used for differentiators and Hilbert transforms.

TypeSymmetryLengthZeros atSuitable For
IEven ($h[n] = h[M-n]$)OddNone requiredLP, HP, BP, BS
IIEven ($h[n] = h[M-n]$)Even$\omega = \pi$LP, BP
IIIOdd ($h[n] = -h[M-n]$)Odd$\omega = 0, \pi$Differentiator, Hilbert
IVOdd ($h[n] = -h[M-n]$)Even$\omega = 0$Differentiator, Hilbert

Example 8.5 --- FIR vs IIR Phase Response

We compare the phase response of a symmetric FIR filter (linear phase) with an IIR Butterworth filter of comparable magnitude response. The FIR filter exhibits perfectly linear phase across all frequencies, while the IIR filter shows significant phase nonlinearity, especially near the cutoff.

FIR vs IIR: Phase Response Comparison

Click Run to execute the Python code

First run will download Python environment (~15MB)

8.9 Filter Specifications

Practical filter design begins with a set of specifications that quantify the acceptable deviations from ideal behavior. These specifications form a tolerance scheme that any acceptable filter must satisfy.

Definition 8.12 --- Passband Ripple

The passband ripple $\delta_p$ (or equivalently $R_p$ in dB) specifies the maximum deviation of the magnitude response from unity in the passband:

$$1 - \delta_p \le |H(e^{j\omega})| \le 1 + \delta_p, \quad 0 \le \omega \le \omega_p$$

In decibels: $R_p = -20\log_{10}(1 - \delta_p)$ dB. Common values: 0.1 dB, 0.5 dB, 1 dB.

Definition 8.13 --- Stopband Attenuation

The stopband attenuation $\delta_s$ (or $A_s$ in dB) specifies the maximum magnitude allowed in the stopband:

$$|H(e^{j\omega})| \le \delta_s, \quad \omega_s \le \omega \le \pi$$

In decibels: $A_s = -20\log_{10}(\delta_s)$ dB. Common values: 40 dB, 60 dB, 80 dB.

Definition 8.14 --- Transition Width

The transition band is the frequency interval between the passband edge $\omega_p$ and the stopband edge $\omega_s$:

$$\Delta\omega = \omega_s - \omega_p$$

A narrower transition band requires a higher filter order. The relationship is approximately inverse: halving the transition width roughly doubles the required order.

Theorem 8.9 --- Specification Trade-offs

For any filter of a given order $N$, the following trade-offs apply:

  • Sharper cutoff (narrower transition band) requires higher order or more passband/stopband ripple
  • Lower passband ripple requires wider transition band or reduced stopband attenuation
  • Greater stopband attenuation requires wider transition band or increased passband ripple

For FIR filters, the approximate relationship (Bellanger's formula) is:

$$N \approx \frac{-10\log_{10}(\delta_p \cdot \delta_s) - 13}{2.324 \cdot \Delta f}$$

where $\Delta f$ is the normalized transition width $(\omega_s - \omega_p) / (2\pi)$.

Example 8.6 --- Typical Filter Specification

A common audio low-pass filter specification:

  • Sampling rate: $f_s = 44100$ Hz
  • Passband edge: $f_p = 4000$ Hz (passband ripple $R_p = 0.5$ dB)
  • Stopband edge: $f_s = 5000$ Hz (stopband attenuation $A_s = 60$ dB)
  • Transition width: $\Delta f = 1000$ Hz

Normalized: $\omega_p = 2\pi \cdot 4000/44100 \approx 0.57$ rad,$\omega_s = 2\pi \cdot 5000/44100 \approx 0.71$ rad. Using Bellanger's formula with $\delta_p \approx 0.057$ and$\delta_s = 10^{-3}$, the estimated FIR order is approximately 72.

8.10 Chapter Summary

  • 1.FIR filters offer guaranteed stability and linear phase but require higher orders. IIR filters achieve sharp cutoffs with low order but cannot provide linear phase and require stability checks.
  • 2.The windowing method designs FIR filters by truncating the ideal impulse response and applying a window function (Hann, Hamming, Blackman, Kaiser) to control sidelobe levels.
  • 3.The frequency sampling method specifies the desired response at DFT grid points and uses the IDFT to compute filter coefficients.
  • 4.The bilinear transform maps analog prototypes to digital filters while preserving stability. Frequency warping must be compensated through pre-warping of critical frequencies.
  • 5.Classic analog prototypes --- Butterworth (maximally flat), Chebyshev I/II (equiripple in passband/stopband), and Elliptic (equiripple in both) --- offer different trade-offs between transition width, ripple, and phase linearity.
  • 6.Butterworth filter design involves computing the minimum order from passband/stopband specs, then placing poles equally spaced on the left half of the unit circle in the $s$-plane.
  • 7.The Direct-Form II Transposed structure is preferred for floating-point IIR implementation, using half the delay elements of Direct-Form I with better numerical properties.
  • 8.Linear phase FIR filters come in four types depending on symmetry (even/odd) and length (odd/even), each imposing constraints on which filter types (LP, HP, BP, BS, differentiator) can be realized.
  • 9.Filter specifications --- passband ripple ($R_p$), stopband attenuation ($A_s$), and transition width ($\Delta\omega$) --- form a tolerance scheme. Tightening any one specification increases the required filter order.