ELEC6218 · Signal Processing Analog & Digital Filter Design
Signal Processing · Lecture notes Prof. Çelik
ELEC6218 · Signal Processing
Lecture 7

FIR Filter Design

This lecture shows how to design a practical FIR filter with linear phase. We first use symmetry to understand the four FIR types. We then compare two design routes: the window method, which is simple and flexible, and the minimax method, which makes the best use of a chosen filter order.

Quiz
Podcast ↓ MP3
InstructorProf. Abdulkadir Çelik (https://akadircelik.com) ModuleELEC6218 TopicsLinear-phase Types I–IV · minimax & Parks–McClellan · window method · Kaiser window · order estimation
▸ Symmetry, not luck, buys linear phase ▸ Type II/III/IV each forbid one shape ▸ Windowing: truncate, then taper ▸ Minimax spreads the error evenly
Learning outcomes

By the end of this lecture, you will be able to:

  • Identify FIR Types I–IV from the order and coefficient symmetry, and decide which filter responses each type can realize.
  • Explain what minimax and equiripple mean, and describe how the Parks–McClellan algorithm reduces the largest weighted error.
  • Use the window method to turn an ideal sinc response into a finite causal filter, and choose a fixed or Kaiser window for a given attenuation.
  • Convert frequency and ripple specifications into an estimated filter order, construct the coefficients, and verify the result.
Lecture 7

Contents

First, learn how coefficient symmetry creates four linear-phase FIR types. Then compare the equiripple and window methods through complete numerical examples. The final section turns the window method into a reusable design checklist.

iNotation used in this lecture
\(M\)
filter order (Lecture 6 notation); length \(L=M+1\)
\(A(e^{j\omega})\)
real-valued amplitude function left after the linear-phase factor \(e^{-j\omega M/2}\) is pulled out
\(\delta_p,\delta_s\)
passband and stopband ripple (linear); \(A_p,A_s\) their dB equivalents
\(\omega_p,\omega_s\)
passband edge and stopband edge (rad/sample); \(\Delta\omega=\omega_s-\omega_p\)
\(w[n]\)
window function multiplying the ideal (infinite) impulse response
\(\beta\)
Kaiser window shape parameter

Most designs here use Type I or Type II. Their even symmetry suits ordinary low-pass, high-pass, band-pass and band-stop filters. Odd-symmetry Types III and IV are mainly used for differentiators and Hilbert transformers.

7.1  Linear-phase FIR filters: the four types

An important property of FIR filters is that they can be designed to have exact linear phase. The frequency response of an order-\(M\) FIR filter is a weighted sum of its coefficients \(b_k\). Because the coefficients are also the impulse response, \(b_k=h[k]\), and the rest of the lecture uses the \(h[k]\) form:

$$ H(e^{j\omega})=\sum_{k=0}^{M}b_k\,e^{-jk\omega}=\sum_{k=0}^{M}h[k]\,e^{-jk\omega} $$
(7.1)

A filter has generalized linear phase if its frequency response can be written as a real function \(A(e^{j\omega})\) times a phase factor that is a linear function of \(\omega\) plus a constant \(\beta\):

$$ H(e^{j\omega})=A(e^{j\omega})\,e^{-j\alpha\omega+j\beta}, \qquad A(e^{j\omega})\ \text{real} $$
(7.2)

\(A(e^{j\omega})\) is real but may be positive or negative; a sign change adds a jump of \(\pi\) to the phase without changing its slope. The phase slope is \(-\alpha\), so the group delay \(\tau(\omega)=-\mathrm{d}\varphi/\mathrm{d}\omega=\alpha\) is the same at every frequency. All frequency components are delayed by the same amount, so the waveform shape is preserved.

Four types of FIR filter have generalized linear phase. The order \(M\) can be even or odd, and the impulse response can have even or odd symmetry about its midpoint \(n=M/2\):

$$ \text{even symmetry: } h[n]=h[M-n], \qquad \text{odd symmetry: } h[n]=-h[M-n], \qquad 0\le n\le M $$
(7.3)

In every case the group delay is \(\alpha=M/2\). Even symmetry produces cosine terms and \(\beta=0\); odd symmetry produces sine terms and \(\beta=\pi/2\). Some types force the response to be zero at DC or at the Nyquist frequency, whatever the coefficients.

7.1.1  Type I: \(M\) even, even symmetry — the general-purpose case

Type I has \(h[n]=h[M-n]\) for \(0\le n\le M\). Because \(M\) is even, the midpoint \(M/2\) is an integer and falls on a sample, and the impulse response is symmetric about it. To simplify Eq. (7.1), factor out \(e^{-j\omega M/2}\) and group the terms that share a coefficient: \(h[0]\) with \(h[M]\), \(h[1]\) with \(h[M-1]\), and so on, leaving the middle sample \(h[M/2]\) on its own:

$$ \begin{aligned}H(e^{j\omega})&=\sum_{k=0}^{M}h[k]e^{-jk\omega}\\&=e^{-j\frac{M}{2}\omega}\Big(h[0]e^{j\frac{M}{2}\omega}+h[M]e^{-j\frac{M}{2}\omega}+h[1]e^{j(\frac{M}{2}-1)\omega}+h[M-1]e^{-j(\frac{M}{2}-1)\omega}+\cdots+h[\tfrac{M}{2}]e^{j0\omega}\Big)\\&=e^{-j\frac{M}{2}\omega}\Big(2h[0]\cos(\tfrac{M}{2}\omega)+2h[1]\cos\big((\tfrac{M}{2}-1)\omega\big)+\cdots+h[\tfrac{M}{2}]\Big)\end{aligned} $$

Each pair becomes twice a cosine because \(h[k]=h[M-k]\) and \(e^{j\theta}+e^{-j\theta}=2\cos\theta\). Re-indexing gives a weighted sum of harmonically related cosines:

$$ H(e^{j\omega})=e^{-j\omega M/2}\sum_{k=0}^{M/2}a[k]\cos(\omega k), \qquad a[0]=h[\tfrac{M}{2}],\ \ a[\ell]=2h[\tfrac{M}{2}-\ell],\ \ \ell=1,\ldots,\tfrac{M}{2} $$
(7.4)

The coefficients \(a[k]\) are real because \(h[n]\) is real, and the cosines are real, so \(A(e^{j\omega})=\sum_{k=0}^{M/2}a[k]\cos(\omega k)\) is a real function. Comparing with Eq. (7.2), Type I has generalized linear phase with \(\alpha=M/2\) and \(\beta=0\): a group delay of \(M/2\) samples.

h[n]M even (M=6, 7 taps)
Type I
M even · even symmetry
z=1 z=−1

No restriction. LPF, HPF, BPF, BSF all possible.

Why no restriction. \(A(e^{j\omega})=\sum a[k]\cos(\omega k)\). At \(\omega=0\), \(\cos 0=1\); at \(\omega=\pi\), \(\cos(\pi k)=\pm1\). No term is forced to zero at either end, so the gain at DC and Nyquist is set by the coefficients.

Figure 7.1.a. Type I. Left: the impulse response mirrors about the dashed centre line, which falls on the sample \(n=M/2\) because \(M\) is even (here \(M=6\), 7 taps). Right: the \(z\)-plane; no zero is forced at \(z=1\) or \(z=-1\), so any of the four standard shapes is possible.

Type I does not force a zero at either \(\omega=0\) or \(\omega=\pi\). It can therefore realize low-pass, high-pass, band-pass and band-stop responses, making it the most flexible type.

7.1.2  Type II: \(M\) odd, even symmetry — no high-pass

Type II keeps even symmetry, \(h[n]=h[M-n]\), but with \(M\) odd the symmetry axis \(M/2\) falls halfway between two samples. The same algebra pairs each sample with its mirror image on the other side of \(M/2\), which gives half-integer cosine arguments:

$$ H(e^{j\omega})=e^{-j\omega M/2}\sum_{k=1}^{(M+1)/2}b[k]\cos\!\Big(\omega\big(k-\tfrac12\big)\Big), \qquad b[k]=2h\!\Big[\tfrac{M+1}{2}-k\Big],\ \ k=1,\ldots,\tfrac{M+1}{2} $$
(7.5)
h[n]M odd (M=5, 6 taps)
Type II
M odd · even symmetry
z=1 z=−1

Forced zero at \(z=-1\). No HPF.

Why no HPF. At \(\omega=\pi\) every term is \(\cos[\pi(k-\tfrac12)]\), the cosine of an odd multiple of \(\pi/2\), which is \(0\) for every integer \(k\). So \(H(e^{j\pi})=0\) whatever the \(b[k]\), but a high-pass filter needs gain near \(\pi\).

Figure 7.1.b. Type II. Left: still a mirror image, but with \(M\) odd (here \(M=5\), 6 taps) the centre line falls between two samples. Right: the forced zero at \(z=-1\) (red cross) makes \(H(e^{j\pi})=0\), so no high-pass.

The sum is again real and multiplies a linear-phase term, so Type II also has generalized linear phase with group delay \(M/2\), now a non-integer number of samples. At \(\omega=\pi\) each term contains \(\cos[\pi(k-\tfrac12)]\), the cosine of an odd multiple of \(\pi/2\), which is zero for every integer \(k\). So \(H(e^{j\pi})=0\) whatever the coefficients are: every Type II filter has a zero at \(z=-1\). A high-pass filter must pass frequencies near Nyquist, so it cannot be built as Type II. Type II can be used for low-pass, band-pass, or any other response with zero gain at \(\pi\).

7.1.3  Type III: \(M\) even, odd symmetry — no low-pass or high-pass

Type III has \(M\) even and odd symmetry, \(h[n]=-h[M-n]\). At the midpoint this reads \(h[M/2]=-h[M/2]\), so the centre sample must be zero, and the samples on either side form negative pairs. Substituting the symmetry into Eq. (7.1) now collapses the pairs into sines, with an overall factor of \(j\):

$$ H(e^{j\omega})=je^{-j\omega M/2}\sum_{k=1}^{M/2}c[k]\sin(\omega k), \qquad c[k]=2h\!\Big[\tfrac{M}{2}-k\Big] $$
(7.6)
h[n]M even (M=6, 7 taps)
Type III
M even · odd symmetry
z=1 z=−1

Forced zeros at \(z=\pm1\). No LPF or HPF.

Why no LPF or HPF. Every term is \(\sin(\omega k)\), and \(\sin(0\cdot k)=0\), \(\sin(\pi k)=0\) for every integer \(k\). So \(H(e^{j0})=H(e^{j\pi})=0\) whatever the \(c[k]\): a low-pass needs gain at DC and a high-pass needs gain at \(\pi\).

Figure 7.1.c. Type III. Left: the samples flip sign about the centre, and the centre sample itself is forced to zero (hollow marker); \(M\) even (here \(M=6\), 7 taps). Right: forced zeros at both \(z=1\) and \(z=-1\), so neither low-pass nor high-pass is possible.

The sum is real, the exponential gives group delay \(M/2\), and \(j=e^{j\pi/2}\) is the constant phase offset, so \(\beta=\pi/2\). The sine terms restrict the responses Type III can produce: \(\sin(0\cdot k)=0\) and \(\sin(\pi k)=0\) for every integer \(k\), so \(H(e^{j0})=0\) and \(H(e^{j\pi})=0\). Type III therefore has forced zeros at \(z=1\) and \(z=-1\) and cannot realize a low-pass or high-pass response. It can only be used for band-pass filters, or other responses with zero gain at both \(0\) and \(\pi\), such as Hilbert transformers.

7.1.4  Type IV: \(M\) odd, odd symmetry — no low-pass

Type IV has \(M\) odd and odd symmetry, \(h[n]=-h[M-n]\). The symmetry axis \(M/2\) again lies between two samples, and the coefficients above it are the negatives of those below. The algebra gives half-integer sine arguments:

$$ H(e^{j\omega})=je^{-j\omega M/2}\sum_{k=1}^{(M+1)/2}d[k]\sin\!\Big(\omega\big(k-\tfrac12\big)\Big), \qquad d[k]=2h\!\Big[\tfrac{M+1}{2}-k\Big],\ \ k=1,\ldots,\tfrac{M+1}{2} $$
(7.7)

This is again generalized linear phase, with group delay \(M/2\) and constant phase offset \(j=e^{j\pi/2}\). At \(\omega=0\), \(\sin[0\cdot(k-\tfrac12)]=0\) for every \(k\), so \(H(e^{j0})=0\): a zero at \(z=1\). At \(\omega=\pi\), \(\sin[\pi(k-\tfrac12)]=\pm1\), so no zero is forced at Nyquist.

h[n]M odd (M=5, 6 taps)
Type IV
M odd · odd symmetry
z=1 z=−1

Forced zero at \(z=1\). No LPF.

Why no LPF. At \(\omega=0\) every term is \(\sin[0\cdot(k-\tfrac12)]=0\), so \(H(e^{j0})=0\) whatever the \(d[k]\), but a low-pass filter needs gain at DC. At \(\omega=\pi\), \(\sin[\pi(k-\tfrac12)]=\pm1\), so Nyquist is unaffected.

Figure 7.1.d. Type IV. Left: sign flip about a centre that falls between samples; \(M\) odd (here \(M=5\), 6 taps). Right: one forced zero at \(z=1\), so \(H(e^{j0})=0\) and no low-pass.

Type IV always has a zero at DC but does not force a zero at Nyquist. It cannot be a low-pass filter, but it is well suited to a digital differentiator, whose desired response is already zero at DC and increases with frequency.

The four types can be remembered visually, as Figures 7.1.a–7.1.d show: check whether the coefficients mirror or change sign, then check whether the symmetry centre lies on a sample or halfway between samples. Those two observations determine the type and its forced zeros.

None of this is bookkeeping. Given a set of taps you can now read off, in a few seconds and without evaluating a single frequency, whether the filter can possibly do the job it was handed — and if a specification asks for a high-pass from an even-length symmetric filter, you know to stop and change the length rather than to keep tuning coefficients. Example 7.1 walks that reading once, end to end.

EXAMPLE 7.1 · Classifying a filter and predicting its forbidden zero

A 5-tap filter has \(h=[1,\,2,\,0,\,-2,\,-1]\) (\(n=0,\ldots,4\)). Classify its type, predict any forced zero on the unit circle, and confirm it by evaluating \(H(e^{j\omega})\) at that frequency.

1
Order and symmetry

\(M=4\) (even). Check \(h[n]=-h[4-n]\): \(h[0]=1=-h[4]=-(-1)=1\ \checkmark\), \(h[1]=2=-h[3]=-(-2)=2\ \checkmark\), \(h[2]=0=-h[2]\ \checkmark\) (forces the centre tap to zero, as odd symmetry with even \(M\) always must). Odd symmetry, \(M\) even — Type III.

2
Predicted zeros

By Eq. (7.6), Type III forces \(H(e^{j0})=0\) and \(H(e^{j\pi})=0\) — zeros at both \(z=1\) and \(z=-1\), regardless of the coefficient values.

3
Confirm directly

\(H(z)=1+2z^{-1}+0-2z^{-3}-z^{-4}\). At \(z=1\): \(H(1)=1+2+0-2-1=0\ \checkmark\). At \(z=-1\): \(H(-1)=1-2+0+2-1=0\ \checkmark\). Both forced zeros confirmed — this filter can be neither a low-pass nor a high-pass, exactly as Section 7.1.3 predicts.

MATLAB corner for Example 7.1

This script checks Example 7.1's classification numerically: it verifies the antisymmetry, then uses roots() to show \(z=\pm1\) are exact roots of \(H(z)\).

Goal: confirm both forced zeros land exactly on the unit circle at \(z=1\) and \(z=-1\), for this filter and for a second, arbitrary Type III filter.

fir_type_zeros_demo.m
MATLAB
%% fir_type_zeros_demo.m - Example 7.1's Type III forced zeros (Eq. 7.6)
h = [1 2 0 -2 -1]; % M=4, odd (antisymmetric) about n=2
M = numel(h)-1;
 
% Step 1: verify antisymmetry h[n] = -h[M-n]
isAnti = isequal(h, -fliplr(h));
if mod(M,2)==0, ftype = 'III'; else, ftype = 'IV'; end
fprintf('Antisymmetric: %d (Type %s)\n', isAnti, ftype);
 
% Step 2: forced zeros at z=1 and z=-1 (Type III)
r = roots(h);
disp('Roots of H(z):'); disp(r);
fprintf('H(1) = %.4g, H(-1) = %.4g\n', polyval(h,1), polyval(h,-1));
 
figure('Color','w'); zplane(h,1); title('Type III: zeros forced at z=\pm1');
Figure 7.1.e — Type III zeros on the unit circle produced by fir_type_zeros_demo.m
Figure 7.1.e. Checking the Type III FIR zeros. MATLAB places one zero at \(z=1\) and another at \(z=-1\), both exactly on the unit circle. Evaluating the frequency response at these points gives \(H(e^{j0})=0\) and \(H(e^{j\pi})=0\). A Type III filter therefore has zero gain at DC and at the Nyquist frequency. These zeros are forced by odd symmetry; they are not approximate results of the numerical design.

So symmetry settles what a linear-phase FIR filter is allowed to do. It says nothing about how to choose the \(M+1\) coefficients that make it do the job well — and that is a great deal of freedom to spend by hand.

Two schools of thought answer this, and they differ in the one decision that matters: what error do you agree to make small? Everything else — the algebra, the algorithm, the order you end up paying for — follows from that single choice.

 
Section 7.2
Minimax — Parks–McClellan
Sections 7.3–7.4
Windowing — truncate and taper
Minimises
the worst-case weighted error, \(\max_\omega|W(\omega)E(\omega)|\) — the \(L_\infty\) norm.
the mean-squared error over frequency — the \(L_2\) norm.
Answer looks like
equal ripple everywhere: no band edge treated better than any other.
ripple largest at the band edge, dying away from it.
You get it by
solving a linear system and iterating (the Remez exchange) — running an algorithm.
writing down \(h_d[n]\,w[n]\): one formula, no iteration, no solver.
Pays with
no closed form, and an optimiser in the loop.
a handful of extra taps over the minimax optimum.
Buys
the provably lowest order meeting a given \(A_p,A_s,\Delta\omega\).
a design you can do on paper, predict, and re-tune with one parameter.

Neither dominates: they are optimal against different questions, and the \(L_\infty\)/\(L_2\) split is exactly why. Minimax spends its whole error budget uniformly, so nothing is wasted and nothing is spare; windowing lets the error pile up where the ideal response is discontinuous and be negligible elsewhere, which is a worse peak but a much simpler recipe. We take them in order of ambition — first the provably best filter of a given order, then the one you can write down — and Problem 7.3 asks you to argue which you would actually ship.

7.2  Minimax design: the Parks–McClellan algorithm

FIR filters can be designed by optimization, and the most widely used criterion is minimax: make the worst-case error as small as possible. The procedure is developed here for a Type I filter and carries over to Types II–IV. Recall from Eq. (7.4) that a Type I response is a linear-phase factor times a real amplitude function, \(H(e^{j\omega})=e^{-j\omega M/2}A(\omega)\) with \(A(\omega)=\sum_{k=0}^{M/2}a[k]\cos(\omega k)\). The design variables are the coefficients \(a[k]\). Once they are found, the impulse response follows directly from the same equation: \(h[M/2]=a[0]\) and \(h[M/2\pm\ell]=a[\ell]/2\) for \(\ell=1,\ldots,M/2\).

The minimax criterion chooses the \(a[k]\) to minimise the largest weighted error over a set of frequencies \(F\):

$$ \begin{gathered}H(e^{j\omega})=e^{-j\omega M/2}A(\omega),\qquad A(\omega)=\sum_{k=0}^{M/2}a[k]\cos(\omega k)\\[6pt] \min_{a[k]}\ \max_{\omega\in F}\Big\{\underbrace{W(\omega)\,\big|H_d(\omega)-A(\omega)\big|}_{\varepsilon(\omega)}\Big\}\end{gathered} $$
(7.8)
  • \(H_d(\omega)\) is the real-valued desired response, for example 1 in the passband and 0 in the stopband.
  • \(|H_d(\omega)-A(\omega)|\) is the approximation error at frequency \(\omega\).
  • \(W(\omega)\ge0\) is a non-negative weighting function that marks some frequencies as more important than others.
  • \(\varepsilon(\omega)\) is the weighted error. Eq. (7.8) minimises its largest magnitude.

The set \(F\) contains the passband and stopband; the transition band is not constrained. Increasing a band's weight reduces its ripple, usually at the expense of larger ripple elsewhere.

For Types II–IV the amplitude function has the form \(A(\omega)=Q(\omega)P(\omega)\), where \(P(\omega)\) is again a cosine sum and \(Q(\omega)\) is the fixed factor \(\cos(\omega/2)\), \(\sin\omega\) or \(\sin(\omega/2)\) from Section 7.1. Writing \(W|H_d-QP|=WQ\,|H_d/Q-P|\) turns the problem back into the Type I form, with weight \(WQ\) and desired response \(H_d/Q\). This is why one algorithm serves all four types.

Tolerance scheme: hatched bands around 1 plus/minus delta p in the passband and delta s in the stopband, with the transition band between omega p and omega s left free
Figure 7.2.a. The tolerance scheme Eq. (7.8) is written against: the design must stay inside the hatched corridors — \(1\pm\delta_p\) across the passband and \(\pm\delta_s\) across the stopband — while the transition band \(\omega_p<\omega<\omega_s\) is left completely unconstrained.

7.2.1  The Alternation Theorem

Write \(L=M/2\), so \(A(\omega)\) has \(L+1\) coefficients \(a[0],\ldots,a[L]\). Each \(\cos(k\omega)\) can be expanded as a polynomial of degree \(k\) in \(\cos\omega\) (the Chebyshev polynomial \(T_k\)), so \(A(\omega)\) is a polynomial of degree \(L\) in \(\cos\omega\). The Alternation Theorem from polynomial approximation theory therefore applies. It states that the optimum has at least \(L+2\) extremal frequencies \(\omega_k\), \(k=1,\ldots,L+2\), at which

  1. the error alternates between two equal maxima and minima, \(\varepsilon(\omega_k)=-\varepsilon(\omega_{k+1})\) for \(k=1,\ldots,L+1\), and
  2. the error magnitude equals the maximum absolute error over \(F\), denoted \(\delta\).
$$ \varepsilon(\omega_k)=-\varepsilon(\omega_{k+1}), \qquad \delta=|\varepsilon(\omega_k)|=\max_{\omega\in F}|\varepsilon(\omega)|, \qquad k=1,\ldots,L+2 $$
(7.9)

In the passband the response therefore swings between \(1+\delta\) and \(1-\delta\), and in the stopband between \(+\delta\) and \(-\delta\). This is the equiripple pattern. It uses the available error allowance efficiently, so for a fixed order it gives the smallest possible worst-case error. Counting extremal frequencies also gives the order: nine extremal frequencies, for example, means \(L+2=9\), so \(L=7\) and \(M=14\).

This suggests the design approach: find the extremal frequencies \(\omega_k\), then choose \(a[k]\) to minimise the error at those frequencies.

Equiripple magnitude with passband ripple between 1 plus and minus delta and stopband ripple between plus and minus delta, extremal frequencies omega 1 to omega 10
Figure 7.2.b. The Alternation Theorem's signature (Eq. 7.9), read off the response itself: at the optimum the deviation from the ideal touches its bound alternately — \(1+\delta\) then \(1-\delta\) across the passband, \(+\delta\) then \(-\delta\) across the stopband — at the extremal frequencies (at least \(L+2=M/2+2\) of them) \(\omega_1,\ldots,\omega_{10}\), and nowhere exceeds \(\delta\) in between. Equal-height ripples everywhere are what optimality looks like.

7.2.2  The Remez exchange algorithm

The extremal frequencies are not known in advance, so the design is iterative: guess them, compute coefficients whose error alternates at the guesses, check whether the guesses really are the extrema, and repeat. Several algorithms do this. The most commonly used is the Parks–McClellan method, which uses the Remez exchange algorithm. MATLAB implements it in firpm():

1
Guess

Pick an initial set of \(L+2\) extremal frequencies \(\omega_1,\ldots,\omega_{L+2}\) — any reasonable spread across the bands will do.

2
Solve

With those frequencies held fixed, find the coefficients \(a[k]\) and the ripple \(\delta\) that satisfy the alternation criterion \((-1)^k\delta=W(\omega_k)\big[H_d(\omega_k)-A(\omega_k)\big]\). This is the linear system of Eq. (7.11).

3
Locate the real extrema

With those coefficients fixed, search the resulting error curve for its true extremal frequencies \(\omega_k'\).

4
Exchange & repeat

If \(\omega_k'\ne\omega_k\), replace \(\omega_k\) with \(\omega_k'\) and go back to step 2. This swap is the “exchange” in the algorithm’s name.

5
Converged

The frequencies stop moving: every ripple now has the same height, so by Eq. (7.9) the design is optimal.

Step 2 is easier to solve once the unknowns are collected on the left and the known values on the right:

$$ A(\omega_k)+\frac{(-1)^k\,\delta}{W(\omega_k)}=H_d(\omega_k),\qquad k=1,\ldots,L+2 $$
(7.10)

With \(A(\omega_k)=\sum_{n=0}^{L}a[n]\cos(n\omega_k)\), stacking the \(L+2\) equations row by row gives a square linear system:

$$ \begin{bmatrix}1&\cos\omega_1&\cos2\omega_1&\cdots&\cos L\omega_1&\dfrac{-1}{W(\omega_1)}\\[4pt] 1&\cos\omega_2&\cos2\omega_2&\cdots&\cos L\omega_2&\dfrac{1}{W(\omega_2)}\\ \vdots&\vdots&\vdots&&\vdots&\vdots\\ 1&\cos\omega_{L+2}&\cos2\omega_{L+2}&\cdots&\cos L\omega_{L+2}&\dfrac{(-1)^{L+2}}{W(\omega_{L+2})}\end{bmatrix}\begin{bmatrix}a[0]\\a[1]\\\vdots\\a[L]\\\delta\end{bmatrix}=\begin{bmatrix}H_d(\omega_1)\\H_d(\omega_2)\\\vdots\\H_d(\omega_{L+2})\end{bmatrix} $$
(7.11)

Row \(k\) is Eq. (7.10) at frequency \(\omega_k\). There are \(L+2\) unknowns (the \(L+1\) coefficients and \(\delta\)) and \(L+2\) equations, so inverting the matrix gives a candidate set of \(a[k]\) and \(\delta\) whose error alternates at the guessed frequencies. That does not yet make them optimal: the true maxima and minima of the resulting \(A(\omega)\) may lie elsewhere, which is what steps 3 and 4 check. Each iteration exchanges the guessed extremal set for a better one — hence “exchange” — and convergence is fast and guaranteed for this class of problem.

One Remez exchange step: the guessed frequencies used to compute the coefficients, marked with crossed circles, sit slightly off the true extremal frequencies of the resulting error, marked with open circles
Figure 7.2.c. One step of the exchange. The \(\omega_k\) used to solve Eq. (7.11) for \(a[k]\) (crossed markers) do not coincide with the true extremal frequencies \(\omega_k'\) of the error that results (open markers); replacing the former with the latter and re-solving is the whole algorithm, and the iteration stops when the two sets coincide.
MATLAB corner

Steps 2–4 are hard to picture from a list, so it is worth watching them happen. firpm's third output returns the extremal set it settled on (res.fextr); running the design for \(N=4,6,8,\ldots,40\) and plotting that set each time turns the exchange into an animation, written straight out as a GIF.

Goal: watch the extremal frequencies multiply and settle as the order grows, and see the response go from a crude slope to a sharp equiripple edge without any change to the specification.

Animation_Parks_McClellan.m
MATLAB
%% Animation_Parks_McClellan.m - animate the extremal set as the order grows
% Animate extremal frequencies for increasing N and save as animated GIF.
 
clear; close all;
 
% Specs (normalized freq: 0→1 corresponds to 0→π)
F = [0 0.4 0.5 1];
A = [1 1 0 0];
W = [1 1];
 
Nfinal = 40;            % final order
Nstep = 2;              % keep parity
Ns = 4:Nstep:Nfinal;    % start at valid order >= 3
 
filename = 'firpm_extrema_convergence.gif'; % output GIF
delayTime = 0.4;       % seconds per frame
 
fig = figure('Color','w','Position',[200 200 900 600]);
 
iter = 0;
all_extrs = cell(1,length(Ns));
colors = lines(length(Ns));
 
for k = 1:length(Ns)
    N = Ns(k);
    [b,err,res] = firpm(N, F, A, W);   % returns res.fextr (normalized [0,1])
    iter = iter + 1;
    all_extrs{iter} = res.fextr;
 
    % compute freq response
    [H,w] = freqz(b,1,2048);
    f = w/pi;
 
    clf;
    % Top: magnitude + extremals
    ax1 = subplot(2,1,1);
    plot(f, abs(H), 'LineWidth', 1.2); hold on;
    plot(f, double(f<=F(2)), 'k--', 'LineWidth', 1);
    plot(res.fextr, interp1(f, abs(H), res.fextr, 'linear'), 'ro', ...
         'MarkerSize',8,'LineWidth',1.6,'MarkerFaceColor','r');
    text(0.02, 1.08, sprintf('N = %d', N), 'FontWeight','bold');
    xlim([0 1]); ylim([-0.05 1.2]); grid on;
    xlabel('Normalized frequency (\times \pi)');
    ylabel('|H|');
    title('Magnitude |H(e^{j\omega})| and Current Extremal Frequencies');
    legend('Designed |H|','Ideal passband','Extremal freqs','Location','Best');
 
    % Bottom: trace of extremals over iterations
    ax2 = subplot(2,1,2);
    hold on;
    for ii = 1:iter
        y = all_extrs{ii};
        x = repmat(ii, size(y));
        scatter(x, y, 36, colors(mod(ii-1,size(colors,1))+1,:), 'filled');
    end
    xlim([0 length(Ns)+1]); ylim([0 1]);
    xlabel('Iteration index (increasing N)');
    ylabel('Normalized frequency');
    title('Extremal Frequencies vs Iteration');
    grid on;
 
    drawnow;
 
    % capture frame and write to GIF
    frame = getframe(fig);
    im = frame2im(frame);
    [Aind, map] = rgb2ind(im, 256);
    if k == 1
        imwrite(Aind, map, filename, 'gif', 'LoopCount', Inf, 'DelayTime', delayTime);
    else
        imwrite(Aind, map, filename, 'gif', 'WriteMode', 'append', 'DelayTime', delayTime);
    end
end
 
close(fig);
fprintf('Saved animation to %s\n', filename);
Animation: as the filter order grows from 4 to 40, the designed magnitude sharpens toward the ideal passband edge and the number of extremal frequencies grows, each iteration's set plotted as a column of dots
Figure 7.2.d. Following the Parks–McClellan animation. The top panel shows the best equiripple response available at the current order; red markers identify the extremal frequencies where the weighted error reaches alternating positive and negative peaks. At a very low order, the filter has too few degrees of freedom to form a sharp edge. As the order increases, more extrema appear and the transition becomes narrower. The bottom panel keeps the extremal set from each design. The growing number of points agrees with the Alternation Theorem, and their concentration near the band edge shows where the approximation is most difficult. A printed page shows only the first frame; the on-screen animation shows the progression.

Weighting function for a two-band (passband/stopband) design. The passband and stopband tolerances \(\delta_p\) and \(\delta_s\) are usually different; with unit weight in the passband, the stopband is weighted by their ratio:

$$ W(\omega)=\begin{cases}1,&0\le\omega\le\omega_p\\ \delta_p/\delta_s,&\omega_s\le\omega\le\pi\end{cases} $$

This choice makes the weighted ripple identical in both bands: \(W(\omega_p)\delta_p=1\cdot\delta_p\) and \(W(\omega_s)\delta_s=(\delta_p/\delta_s)\delta_s=\delta_p\), so the algorithm's single equiripple level \(\delta\) (Eq. 7.9) enforces \(\delta_p\) in the passband and \(\delta_s\) in the stopband simultaneously. The rule is larger weight on the band with tighter tolerance: if \(\delta_s<\delta_p\), the stopband weight exceeds 1 and the design achieves a smaller stopband error.

The other choice is the order \(M\). It cannot be fixed exactly in advance, but for a low-pass Kaiser's formula gives a good starting value, with \(\Delta\omega=\omega_s-\omega_p\) the transition bandwidth:

$$ M\approx\frac{-10\log_{10}(\delta_p\delta_s)-13}{2.324\,\Delta\omega} $$
(7.12)

Treat Eq. (7.12) as a guideline. Design the filter, check the result against the tolerance scheme, and increase or decrease \(M\) and redesign until the specification is just met. In practice the design iterates over \(M\) as well as over the extremal frequencies.

EXAMPLE 7.2 · Weighting and order of an equiripple low-pass

Design a minimax low-pass with \(A_p=0.5\,\text{dB}\), \(A_s=50\,\text{dB}\), passband edge \(f_p=0.15\), stopband edge \(f_s=0.20\) (normalized, \(f_s^{\text{sample}}=1\)). Choose the weighting function \(W(\omega)\), estimate the order via Eq. (7.12), and state the design in MATLAB's terms.

1
Ripples

The specification is in decibels, but Eq. (7.12) needs the linear tolerances. The passband gain swings between \(1-\delta_p\) and \(1+\delta_p\), so the peak-to-peak ripple is \(A_p=20\log_{10}\frac{1+\delta_p}{1-\delta_p}\); solving for \(\delta_p\) gives the first expression below. The stopband gain must stay below \(\delta_s\), so \(A_s=-20\log_{10}\delta_s\). (Both conversions are collected in Eqs. (7.18) and (7.19), Section 7.5.1.)

\(\delta_p=\dfrac{10^{A_p/20}-1}{10^{A_p/20}+1}=\dfrac{10^{0.025}-1}{10^{0.025}+1}\approx0.0288\), and \(\delta_s=10^{-A_s/20}=10^{-2.5}\approx0.00316\).

2
Weighting function

The stopband tolerance is tighter (\(\delta_s<\delta_p\)), so the stopband gets the larger weight. With unit weight in the passband:

$$ W(f)=\begin{cases}1,&0\le f\le0.15\\ \delta_p/\delta_s=0.0288/0.00316\approx9.1,&0.20\le f\le0.5\end{cases} $$

A stopband error of \(\delta_s\) now counts as much as a passband error of \(\delta_p\), so the single equiripple level \(\delta=\delta_p\) meets both tolerances. Unit weights in both bands would give equal ripple \(\delta\) in each band, and the stopband would then only reach \(-20\log_{10}(0.0288)\approx31\) dB instead of 50 dB.

3
Transition width

\(\Delta f=f_s-f_p=0.05\Rightarrow\Delta\omega=2\pi\Delta f=0.1\pi\).

4
Order estimate

\(-10\log_{10}(\delta_p\delta_s)=-10\log_{10}(9.1\times10^{-5})\approx40.4\). By Eq. (7.12): \(M\approx\dfrac{40.4-13}{2.324(0.1\pi)}\approx\dfrac{27.4}{0.730}\approx37.6\Rightarrow M=38\) (round up).

5
In MATLAB

This is exactly what [M,fo,ao,w]=firpmord([0.15 0.20],[1 0],[0.0288 0.00316]) followed by b=firpm(M,fo,ao,w) automates; w returns the weights of step 2, \([1\;\,9.1]\) — the Remez exchange (Section 7.2.2) then refines the guess to the true equiripple optimum, typically within a tap or two of this estimate.

MATLAB corner for Example 7.2

This script runs two firpm() designs at the same passband edge \(f_p=0.4\) but different stopband edges (\(f_s=0.6\) and \(0.8\)), so the order needed for a narrow transition can be read directly against a wide one. It plots the designed magnitudes against the ideal \(H_d\), zooms the passband to mark the extremal frequencies, and shows the impulse responses.

Goal: see the Alternation Theorem's equiripple signature in a real firpm() design (Figure 7.2.b, now for real), and confirm that halving the transition width roughly doubles the order Eq. (7.12) demands.

FIR_minimax.m
MATLAB
%% FIR_minimax.m - Remez/firpm designs at two transition widths
clear; close all; clc;
 
%% 1) Filter specs (normalized frequency, 1 ↔ π rad/sample)
fp  = 0.4;            % fixed passband edge
fs_list = [0.6 0.8];  % two stopband edges
 
Rp = 0.01;            % passband ripple
Rs = 0.01;            % stopband ripple
 
Wp = 1;
Ws = Rp / Rs;         % weight ratio
 
%% Containers
b_cell   = cell(1, numel(fs_list));
M_list   = zeros(1, numel(fs_list));
H_cell   = cell(1, numel(fs_list));
f_cell   = cell(1, numel(fs_list));
Hd_cell  = cell(1, numel(fs_list));
ext_f_p  = cell(1, numel(fs_list));
ext_H_p  = cell(1, numel(fs_list));
 
%% 2) Loop over stopband edges
for k = 1:numel(fs_list)
    fs = fs_list(k);
    Delta_w = fs - fp;
    M_est = (-10*log10(Rp*Rs) - 13) / (2.324 * Delta_w);
    M = ceil(M_est);
    if mod(M,2) ~= 0, M = M + 1; end
    M_list(k) = M;
    fprintf('Design %d: f_p = %.2f, f_s = %.2f, used M = %d\n', k, fp, fs, M);
 
    F = [0 fp fs 1];
    A = [1 1 0 0];
    W = [Wp Ws];
 
    b = firpm(M, F, A, W);
    b_cell{k} = b;
 
    [H, w] = freqz(b, 1, 4096);
    f = w / pi;
    H_cell{k} = H;
    f_cell{k} = f;
    Hd_cell{k} = double(f <= fp);
 
    % extremals in passband (illustrative)
    E = Hd_cell{k}.' - abs(H);
    idx_p = find(f <= fp);
    E_p = E(idx_p);
    [~, locs_p] = findpeaks(abs(E_p));
    ext_f_p{k} = f(idx_p(locs_p));
    ext_H_p{k} = abs(H(idx_p(locs_p)));
end
 
%% 3) Figure 1 – Desired vs Designed Magnitude Responses
figure;
hold on;
 
f_plot = f_cell{1};
Hd_plot = double(f_plot <= fp);
 
colors = lines(numel(fs_list));
% plot designed responses with DisplayName
figure(1); clf; hold on;
colors = lines(numel(fs_list));
for k = 1:numel(fs_list)
    plot(f_cell{k}, abs(H_cell{k}), 'Color', colors(k,:), 'LineWidth', 1.5, ...
         'DisplayName', sprintf('Designed |H|, f_s=%.2f, M=%d', fs_list(k), M_list(k)));
end
plot(f_plot, Hd_plot, 'k--', 'LineWidth', 1.5, 'DisplayName', 'Desired H_d(\omega)');
 
% add vertical lines but exclude them from legend
h_fp = xline(fp, '--', 'f_p', 'HandleVisibility','off');
for k = 1:numel(fs_list)
    xline(fs_list(k), '--', sprintf('f_s^{(%d)}', k), 'HandleVisibility','off');
end
 
grid on;
xlabel('Normalized Frequency (\times \pi rad/sample)');
ylabel('Magnitude');
title('Desired vs Designed Magnitude Responses (Two Transition Bands)');
legend('Location','Best');  % will include only objects with DisplayName
 
 
%% 4) Figure 2 – Zoomed Passband Ripples with Extremal Frequencies (add legend)
figure;
for k = 1:numel(fs_list)
    ax = subplot(numel(fs_list),1,k);
    f = f_cell{k};
    H = H_cell{k};
    idx_p = f <= fp;
 
    hLine = plot(f(idx_p), abs(H(idx_p)), 'LineWidth', 1.5); hold on;
    hIdeal = yline(1, 'k--', 'LineWidth', 1.0);
    hExt = plot(ext_f_p{k}, ext_H_p{k}, 'ro', 'MarkerSize', 6, 'LineWidth', 1.2);
 
    grid on;
    xlabel('Normalized Frequency (\times \pi rad/sample)');
    ylabel('Magnitude');
    title(sprintf('Passband Ripples & Extremal Freqs (f_p=%.2f, f_s=%.2f, M=%d)', ...
                  fp, fs_list(k), M_list(k)));
    xlim([0 fp]);
    ylim([1 - 3*Rp, 1 + 3*Rp]);
 
    % Add legend to this subplot (figure 2) referencing the plotted objects
    legend([hLine, hExt, hIdeal], {'Designed |H|','Extremal freqs','Ideal 1'}, 'Location','Best');
    hold off;
end
 
%% 5) Figure 3 – Impulse Responses
figure;
for k = 1:numel(fs_list)
    subplot(numel(fs_list),1,k);
    b = b_cell{k};
    n = 0:length(b)-1;
    stem(n, b, 'filled'); grid on;
    xlabel('n');
    ylabel('h[n]');
    title(sprintf('Impulse Response h[n] (f_p=%.2f, f_s=%.2f, M=%d)', ...
                  fp, fs_list(k), M_list(k)));
end
 
%% 6) Figure 4 – DTFT Magnitude of h[n]
figure;
for k = 1:numel(fs_list)
    subplot(numel(fs_list),1,k);
    f = f_cell{k};
    H = H_cell{k};
    plot(f, abs(H), 'LineWidth', 1.5); hold on;
    plot(f, Hd_cell{k}, 'k--', 'LineWidth', 1.0);
    grid on;
    xlabel('Normalized Frequency (\times \pi rad/sample)');
    ylabel('|H(e^{j\omega})|');
    title(sprintf('DTFT Magnitude (f_p=%.2f, f_s=%.2f, M=%d)', fp, fs_list(k), M_list(k)));
    legend('Designed |H|', 'Desired H_d', 'Location', 'Best');
end
Designed magnitude responses for stopband edges 0.6 and 0.8 against the ideal brick wall, showing the narrower transition needs the higher order
Figure 7.2.e. Effect of transition width on FIR order. Both firpm() designs use the same passband edge, \(f_p=0.4\), and the same error limits, \(\delta_p=\delta_s=0.01\). The design with \(f_s=0.8\) has a wide transition band and needs order \(M=30\). Moving the stopband edge to \(f_s=0.6\) halves the transition width, so the required order rises to about \(M=60\). The plots therefore confirm the inverse relationship in Eq. (7.12): a sharper transition needs a longer filter.
Zoomed passband ripple for both designs, with the extremal frequencies marked by red circles, 13 for the order-60 design and 8 for the order-30 design
Figure 7.2.f. The same two designs with the passband magnified to \(1\pm0.03\). The ripple is invisible at this scale because \(\delta=0.01\) was met with room to spare, but the extremal frequencies (red) are what matter: the Alternation Theorem requires at least \(M/2+2\) of them, and the order-60 design shows more than the order-30 one. Higher order buys more alternations, and more alternations are what allow a smaller \(\delta\).
Impulse responses of both designs: symmetric about their centre samples at n=30 and n=15
Figure 7.2.g. The coefficients themselves. Both are symmetric about their centre sample (\(n=30\) and \(n=15\)) with \(M\) even — i.e. Type I filters, exactly as Section 7.1 requires for a low-pass, and the group delay is the \(M/2\) samples visible as the position of the peak. Note also how much of the longer filter is nearly zero: order bought for a narrow transition is spent on a longer sinc tail, not on a different shape.

The minimax design gives tightly controlled ripple in both bands, and \(W(\omega)\) sets the balance between them. For fixed order and band edges, Parks–McClellan gives the linear-phase FIR filter with the smallest worst-case weighted error. Its disadvantage is that it requires an iterative numerical solver. The window method is more direct and easier to calculate by hand, but it usually needs more taps for the same specification.

7.3  The window method

The window method starts from the ideal infinite, non-causal impulse response and keeps only a finite section. By Parseval's theorem, minimizing mean-squared error in frequency is equivalent to minimizing the squared error between the desired and actual impulse-response coefficients:

$$ \min_{h[n]}\ \frac{1}{2\pi}\int_{-\pi}^{\pi}\big|H_d(e^{j\omega})-H(e^{j\omega})\big|^2d\omega \ \overset{\text{Parseval}}{\Longleftrightarrow}\ \min_{h[n]}\ \sum_{n=-\infty}^{\infty}\big|h_d[n]-h[n]\big|^2 $$
(7.13)

If the practical filter must be zero outside \(0\le n\le M\), the minimum-error choice is to copy the ideal coefficients inside that interval and discard the rest. This is multiplication by a rectangular window. Replacing the abrupt rectangular cutoff with a smoother taper gives the general window method:

$$ h[n]=h_d[n]\,w[n] \qquad\Longleftrightarrow\qquad A(e^{j\omega})=A_d(e^{j\omega})*W(e^{j\omega}) $$
(7.14)

Multiplying by a window in time convolves the ideal response with the window spectrum \(W(e^{j\omega})\). The main-lobe width controls the filter's transition width, while the side-lobe level controls ripple and stopband attenuation. Reducing side lobes usually widens the main lobe, so every window makes a trade-off.

7.3.1  Why plain truncation is the MMSE solution

Take as the target the ideal low-pass \(A_d(\omega)\): 1 for \(|\omega|\le\omega_c\), 0 elsewhere in \([-\pi,\pi]\), and periodic in \(2\pi\) (the grey box in Figure 7.3.c). Its impulse response follows from the inverse DTFT, and it is a sinc: infinite in both directions, and decaying only as \(1/n\).

$$ h_d[n]=\frac{1}{2\pi}\int_{-\pi}^{\pi}A_d(\omega)e^{j\omega n}\,d\omega=\frac{1}{2\pi}\int_{-\omega_c}^{\omega_c}e^{j\omega n}\,d\omega=\frac{\sin(\omega_c n)}{\pi n} $$

This sinc is centred on \(n=0\) and extends to negative \(n\), so it is non-causal. A causal FIR filter may only keep \(0\le n\le M\). Truncating the sinc as it stands would keep only its right half, giving an \(h[n]\) with no symmetry and therefore no linear phase. The target is therefore first delayed by \(M/2\) samples, \(H_d(e^{j\omega})=A_d(\omega)\,e^{-j\omega M/2}\), which shifts the sinc so that its peak sits at the centre of the window:

$$ h_d[n]=\frac{\sin\big(\omega_c(n-M/2)\big)}{\pi\,(n-M/2)},\qquad h_d[M/2]=\frac{\omega_c}{\pi} $$

The delay changes only the phase, so the amplitude target \(A_d(\omega)\) is unchanged. The kept coefficients now satisfy \(h[n]=h[M-n]\), which for even \(M\) is the Type I filter of Section 7.1.1. From here on, \(h_d[n]\) denotes this shifted sinc.

Now write the mean-squared error of Eq. (7.13) with the causal-FIR constraint \(h[n]=0\) for \(n\notin[0,M]\) made explicit, splitting the sum at the window boundary:

$$ \varepsilon^2=\sum_{n=-\infty}^{\infty}\big|h_d[n]-h[n]\big|^2=\underbrace{\sum_{n=0}^{M}\big|h_d[n]-h[n]\big|^2}_{\text{we control this}}\;+\;\underbrace{\sum_{n\notin[0,M]}\big|h_d[n]\big|^2}_{\text{fixed by }M\text{ alone}} $$

The second sum contains no design variable at all — it is the energy in the tails we are not allowed to keep. The first sum is a sum of independent non-negative terms, so it is minimised term by term, and its minimum is exactly zero, attained by \(h[n]=h_d[n]\) on \(0\le n\le M\). Hence:

$$ h_{\text{MMSE}}[n]=h_d[n]\,w_R[n],\qquad w_R[n]=\begin{cases}1,&0\le n\le M\\0,&\text{otherwise}\end{cases},\qquad \varepsilon^2_{\min}=\!\!\sum_{n\notin[0,M]}\!\!\big|h_d[n]\big|^2 $$

So rectangular truncation is the optimal design in the mean-squared sense — no window, no cleverness, can do better on this criterion, and the residual error is just the discarded tail energy, which falls as \(M\) grows because the sinc tails decay.

Every window other than the rectangular one therefore has a worse mean-squared error. Windows are not there to reduce \(\varepsilon^2\); they are there to redistribute it.

Figure 7.3.a. Truncation as multiplication by \(w_R[n]\), for \(\omega_c=0.3\pi\). Top: the ideal sinc \(h_d[n]\); the shaded band is \(0\le n\le M\). Middle: the rectangular window. Bottom: their product \(h_{\text{MMSE}}[n]\), with the discarded tail in grey; its energy is \(\varepsilon^2_{\min}\), which falls as \(M\) grows. With Shifted by \(M/2\) the sinc peak sits at the window centre and the result is symmetric. With No shift the window keeps only the right half of the sinc: more energy is discarded and the symmetry needed for linear phase is lost.

7.3.2  Why the MMSE answer is still a bad filter

The catch is what the criterion measures. Squared error is an average over frequency, and the average is happy to hide a tall, narrow error at the band edge. Writing Eq. (7.14) out as the convolution integral,

$$ A(\omega)=\frac{1}{2\pi}\int_{-\pi}^{\pi}A_d(\theta)\,W\big(e^{j(\omega-\theta)}\big)\,d\theta \;=\; \frac{1}{2\pi}\int_{-\omega_c}^{\omega_c} W\big(e^{j(\omega-\theta)}\big)\,d\theta, $$

the response at a chosen frequency depends on how much of the shifted window spectrum overlaps the ideal passband, as shown in Figure 7.3.c. For a rectangular window, increasing \(M\) narrows the oscillations but does not reduce the maximum overshoot near the discontinuity, which remains about 9%. This is the Gibbs phenomenon.

Windowing accepts a slightly larger \(\varepsilon^2\) in exchange for a much smaller peak error. Replacing the hard edges of \(w_R[n]\) with a smooth taper \(w[n]\) changes \(W\) in two coupled ways, and Section 7.4 is the catalog of that trade:

Side lobes → ripple

A taper that is continuous at the ends makes \(W\)'s side lobes decay faster, so less out-of-band area leaks in: passband and stopband ripple both fall. Gibbs is defeated.

Main lobe → transition

The same taper shortens the effective window length, widening \(W\)'s main lobe from \(4\pi/M\) to \(8\pi/M\) or \(12\pi/M\): the transition band widens for the same order.

Figure 7.3.b. The window trade, rectangular against Hamming. Top: the two windows in time, shifted to \(0\le n\le M\). The rectangular window keeps every coefficient at full weight and then jumps to zero at both ends. Hamming, \(w[n]=0.54-0.46\cos(2\pi n/M)\), is a raised cosine: full weight at the centre, falling smoothly to 0.08 at the edges. That smooth fall is what tapering means, and it removes the abrupt jump that produces large side lobes. Bottom left: the window's own transform \(W(e^{j\omega})\). Bottom right: the low-pass each window produces through Eq. (7.14). The brackets show main lobe → transition: Hamming's main lobe is twice as wide (about \(8\pi/M\) against \(4\pi/M\)), and its transition band is correspondingly wider. The dashed lines show side lobes → ripple: Hamming's highest side lobe is about \(-43\) dB against \(-13\) dB, so far less out-of-band area leaks into the integral and the stopband ripple falls from about \(-21\) dB to about \(-53\) dB. Raising \(M\) narrows both main lobes and both transitions, but leaves the side-lobe and ripple levels where they are: only the window shape sets those.

Figure 7.3.c evaluates this convolution at every frequency. As \(\omega\) moves from the passband, through the cutoff and into the stopband, the output is determined by how much of the shifted window spectrum overlaps the ideal passband.

Figure 7.3.c. Eq. (7.14) as a sliding overlap, for an ideal low-pass with \(\omega_c=\pi/2\). Top: the window spectrum \(W(e^{j(\omega-\theta)})\) (blue) is centred at \(\theta=\omega\); the orange area is the part lying over the ideal band \(A_d(\theta)\), and that area is \(A(\omega)\), traced below. Deep in the passband the whole main lobe is inside the band and \(A(\omega)\approx1\); the small wobble is what the side lobes outside the band contribute. At \(\omega=\omega_c\) the main lobe straddles the edge, so about half of it is enclosed and \(A(\omega_c)\approx0.5\): the response falls over the span it takes the main lobe to cross the edge, so the main-lobe width is the transition width. Past the edge only side lobes overlap the band, and what they leak is the stopband ripple. With the rectangular window, raising \(M\) narrows the transition but the overshoot stays near 9% (Gibbs); switching to Hamming cuts the ripple at the cost of a main lobe twice as wide. Drag either panel, or press Play sweep.

The main design choice is therefore the taper. Stronger tapering lowers side lobes and improves stopband attenuation, but widens the main lobe and requires more taps for the same transition width.

7.4  Window catalog and order estimates

The next sections compare four fixed windows and the adjustable Kaiser window. Each is shown in time and frequency because the taper shape controls implementation, while its spectrum controls transition width and ripple.

Hann, Hamming and Blackman windows are sums of cosine terms. In frequency, each cosine creates shifted copies of the rectangular-window spectrum. Their weights are selected so that side lobes cancel. The same combination also merges several main lobes into a wider one, which explains the basic trade-off.

MATLAB corner

One loop builds all five windows at \(M=51\) and plots each one twice: the taper \(w[n]\) itself, and \(20\log_{10}|W(e^{j\omega})|\) normalised to its peak. A second block sweeps \(\beta\) for the Kaiser family. Every figure in the rest of this section is an output of this script.

Goal: measure the main-lobe width and side-lobe floor of each window in the catalog, and confirm the two move in opposite directions exactly as Section 7.3.2 predicts.

FIR_windows.m
MATLAB
%% FIR_windows.m - separate window plots: time vs frequency
clear; close all; clc;
 
% Window length
M = 51;  
Nfft = 2048;  
f = linspace(-pi, pi, Nfft);
 
% Define windows and labels
windows = {
    rectwin(M), ...
    hamming(M), ...
    hanning(M), ...
    blackman(M), ...
    kaiser(M, 5)  % Kaiser with beta=5
};
 
labels  = {'Rectangular','Hamming','Hanning','Blackman','Kaiser (\beta=5)'};
 
for i = 1:length(windows)
    figure;
    % Time domain (left)
    subplot(1,2,1);
    plot(0:M-1, windows{i}, 'LineWidth', 1.5);
    %title([labels{i} ' Window (Time Domain)']);
    xlabel('Sample index n');
    ylabel('Amplitude');
    grid on; axis tight;
    set(gca,'fontsize',25)
 
    % Frequency domain (right)
    subplot(1,2,2);
    W = fftshift(fft(windows{i}, Nfft));
    plot(f/pi, 20*log10(abs(W)/max(abs(W))), 'LineWidth', 1.5);
    %title([labels{i} ' Window (Frequency Domain)']);
    xlabel('Normalized Frequency (\times\pi rad/sample)');
    ylabel('Magnitude (dB)');
    ylim([-100 5]); grid on;
    % Main title
    sgtitle([labels{i} ' Window: Time vs Frequency'],'fontsize',25);
    set(gca,'fontsize',25)
end
 
 
%% Kaiser Window: Effect of Beta
% Parameters
M = 51;                 % Window length
Nfft = 2048;            % FFT points
f = linspace(-pi, pi, Nfft);
 
% Different beta values
beta_vals = [0, 3, 5, 8, 12];
labels = {'\beta=0 (Rectangular)', '\beta=3', '\beta=5', '\beta=8', '\beta=12'};
colors = lines(length(beta_vals));
 
figure;
 
% ---- Time Domain ----
subplot(1,2,1);
hold on;
for i = 1:length(beta_vals)
    w = kaiser(M, beta_vals(i));
    plot(0:M-1, w, 'LineWidth', 1.5, 'Color', colors(i,:));
end
title('Kaiser Window (Time Domain)');
xlabel('Sample index n'); ylabel('Amplitude');
legend(labels, 'Location','best');
grid on; axis tight;
    set(gca,'fontsize',20)
 
 
% ---- Frequency Domain ----
subplot(1,2,2);
hold on;
for i = 1:length(beta_vals)
    w = kaiser(M, beta_vals(i));
    W = fftshift(fft(w, Nfft));
    plot(f/pi, 20*log10(abs(W)/max(abs(W))), 'LineWidth', 1.5, 'Color', colors(i,:));
end
title('Kaiser Window (Frequency Domain)');
xlabel('Normalized Frequency (\times\pi rad/sample)');
ylabel('Magnitude (dB)');
legend(labels, 'Location','best');
ylim([-100 5]); grid on;
 
sgtitle('Effect of \beta on Kaiser Window');
    set(gca,'fontsize',20)
Rectangular · plain truncation
Time domain
$$ w_R[n]=1,\qquad 0\le n\le M $$
Frequency domain
$$ W_R(e^{j\omega})=e^{-j\omega M/2}\,\frac{\sin\!\big((M+1)\omega/2\big)}{\sin(\omega/2)} $$

The Dirichlet kernel, and the parent of every entry below. Its main lobe is the narrowest achievable for \(M+1\) taps, but the side lobes fall off only as \(1/\omega\) — the abrupt end of the window is a step, and a step has a slowly decaying spectrum.

main lobe \(4\pi/M\)first side lobe \(-13\,\text{dB}\)decay \(1/\omega\)\(K=4\)
Rectangular window: flat in time, with the highest side lobes at about minus 13 dB
Figure 7.4.a. The rectangular window — plain truncation, in time (left) and dB (right). It has the narrowest main lobe of any window, hence the sharpest transition for a given order, and the worst side lobes: the first sits at \(-13\,\text{dB}\) and the floor barely falls with frequency, so no amount of extra taps buys stopband depth.
Hann · raised cosine
Time domain
$$ w_{\text{Hann}}[n]=\tfrac{1}{2}\Big[1-\cos\!\Big(\tfrac{2\pi n}{M}\Big)\Big] $$
Frequency domain
$$ W_{\text{Hann}}(e^{j\omega})=\tfrac{1}{2}W_R(e^{j\omega})-\tfrac{1}{4}\Big[W_R\big(e^{j(\omega-\frac{2\pi}{M})}\big)+W_R\big(e^{j(\omega+\frac{2\pi}{M})}\big)\Big] $$

Three Dirichlet kernels, the outer two shifted by exactly one main-lobe half-width and inverted. Where the centre kernel's first side lobe is positive the shifted ones are negative, so they cancel — and the window now reaches zero with zero slope, so the decay steepens to \(1/\omega^3\). The price is that the three main lobes merge into one twice as wide.

main lobe \(8\pi/M\)first side lobe \(-31\,\text{dB}\)decay \(1/\omega^3\)\(K=8\)
Hann window: a raised cosine taper in time, with side lobes falling away steeply
Figure 7.4.b. The Hann raised cosine goes smoothly to zero at both ends. That single change doubles the main-lobe width but drops the first side lobe to \(-31\,\text{dB}\) and makes the rest decay steeply — the Eq. (7.14) trade in its simplest form.
Hamming · raised cosine on a pedestal
Time domain
$$ w_{\text{Hamm}}[n]=0.54-0.46\cos\!\Big(\tfrac{2\pi n}{M}\Big) $$
Frequency domain
$$ W_{\text{Hamm}}(e^{j\omega})=0.54\,W_R(e^{j\omega})-0.23\Big[W_R\big(e^{j(\omega-\frac{2\pi}{M})}\big)+W_R\big(e^{j(\omega+\frac{2\pi}{M})}\big)\Big] $$

The same three-kernel sum with the weights re-tuned: \(0.54/0.46\) instead of \(0.5/0.5\) is chosen so the cancellation lands on the largest remaining side lobe rather than being spread evenly. The floor flattens near \(-41\,\text{dB}\) instead of decaying, and the main lobe is unchanged from Hann — 10 dB for free.

main lobe \(8\pi/M\)first side lobe \(-41\,\text{dB}\)flat floor\(K=8\)
Hamming window: a raised cosine with a pedestal, with a flat side-lobe floor near minus 43 dB
Figure 7.4.c. Hamming keeps Hann's main-lobe width but adds a small pedestal, which cancels the largest side lobe and flattens the floor to about \(-41\,\text{dB}\). It is the usual default when 40–50 dB of stopband is enough.
Blackman · three-term cosine
Time domain
$$ w_B[n]=0.42-0.5\cos\!\Big(\tfrac{2\pi n}{M}\Big)+0.08\cos\!\Big(\tfrac{4\pi n}{M}\Big) $$
Frequency domain
$$ W_B(e^{j\omega})=0.42\,W_R-0.25\sum_{\pm}W_R\big(e^{j(\omega\pm\frac{2\pi}{M})}\big)+0.04\sum_{\pm}W_R\big(e^{j(\omega\pm\frac{4\pi}{M})}\big) $$

A second harmonic adds two more shifted kernels, at \(\pm4\pi/M\), giving five terms to cancel with instead of three: the floor drops to \(-57\,\text{dB}\). Five merging main lobes is a \(12\pi/M\) main lobe — three times the rectangular width, i.e. three times the taps for the same transition.

main lobe \(12\pi/M\)first side lobe \(-57\,\text{dB}\)5 kernels\(K=12\)
Blackman window: a three-term cosine taper, with side lobes below minus 58 dB
Figure 7.4.d. Blackman adds a third cosine term, reaching about \(-57\,\text{dB}\) with a main lobe three times the rectangular width — i.e. three times the taps for the same transition. This is the window behind Example 7.7's 60 dB design.

Fixed windows offer only a few attenuation choices. For example, a 47 dB requirement is too demanding for Hamming at about 41 dB, while Blackman at about 57 dB provides more attenuation—and usually more taps—than required. A tunable window can match the target more closely.

Kaiser · one parameter, the whole family
Time domain
$$ w_K[n]=\frac{I_0\!\Big(\beta\sqrt{1-(2n/M-1)^2}\Big)}{I_0(\beta)} $$
Frequency domain
$$ W_K(e^{j\omega})\approx\frac{M}{I_0(\beta)}\cdot\frac{\sinh\!\sqrt{\beta^2-(M\omega/2)^2}}{\sqrt{\beta^2-(M\omega/2)^2}} $$

Not a cosine sum at all: \(I_0\) is the zeroth-order modified Bessel function, and the transform is the \(\sinh\) form above inside the main lobe — past \(|\omega|=2\beta/M\) the radicand turns negative and the \(\sinh\) becomes an ordinary \(\sin\), i.e. side lobes. It nearly maximises main-lobe energy for a given side-lobe level, and \(\beta\) moves along that optimum continuously: \(\beta=0\) returns \(w_R[n]\), \(\beta\approx5\) sits near Hamming, \(\beta\approx8.5\) near Blackman. Eqs. (7.16)–(7.17) invert it for design.

main lobe \(\approx 4\sqrt{\pi^2+\beta^2}/M\)side lobe set by \(\beta\)tunablesee Eq. (7.17)
Kaiser window for beta equal 0, 3, 5, 8 and 12, in time and in dB: larger beta narrows the time taper and lowers the side lobes while widening the main lobe
Figure 7.4.e. Why Kaiser replaces the table: \(\beta\) sweeps the same trade continuously. \(\beta=0\) is exactly the rectangular window of Figure 7.4.a; raising \(\beta\) tapers harder and drops the side-lobe floor (roughly \(-35,-46,-60,-90\,\text{dB}\) for \(\beta=0,3,5,8\)) while widening the main lobe. Eq. (7.15) is this family solved backwards: state the \(A_s\) you need and it returns \(\beta\) and the order.
Window
Sidelobe
Mainlobe
\(K\)
\(A_p\) (dB)
\(A_s\) (dB)
Use
Rectangular
−13 dB
\(4\pi/L\)
4
0.75
21
Max resolution, leaky
Hann
−31 dB
\(8\pi/L\)
8
0.055
44
Lower ripple than rect.
Hamming
−41 dB
\(8\pi/L\)
8
0.019
53
Popular default
Blackman
−57 dB
\(12\pi/L\)
12
0.0017
74
Strong stopband
Kaiser (\(\beta\))
tunable
tunable
—
tunable
tunable
Best all-round

The fixed-window order estimate reads the transition width straight off the table. The main-lobe width is \(K\pi/L\), where \(L=M+1\) is the number of taps, so setting it equal to \(\Delta\omega\) gives the length, rounded up to an integer:

$$ L\approx\frac{K\pi}{\Delta\omega},\qquad M=L-1 $$
(7.15)

Kaiser's window replaces the fixed catalog with one continuously tunable shape, letting a single parameter \(\beta\) buy exactly the stopband attenuation needed without over-paying in order:

$$ w_K[n]=\frac{I_0\!\Big(\beta\sqrt{1-(2n/M-1)^2}\Big)}{I_0(\beta)},\qquad 0\le n\le M $$
(7.16)

The shape parameter itself follows from the required stopband attenuation \(A_s\) in dB:

$$ \beta\approx\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\le50\\0,&A_s<21\end{cases} $$
(7.17)

with order estimate \(M\approx\dfrac{A_s-8}{2.285\,\Delta\omega}\), consistently a bit lower than Eq. (7.15) would give the corresponding fixed window for the same attenuation, because Kaiser's taper is tuned exactly to the target instead of over- or under-shooting it.

7.5  The window design recipe

A practical design starts with passband ripple and stopband attenuation in decibels, together with frequency edges. The following steps convert those requirements into a window, filter length, cutoff and coefficient sequence.

|H(f)| f 1 + δp 1 1 − δp δs 0 fp fs fc 0.5 Ap As dB passband transition band stopband Δf passband ripple control 1 − δp ≤ |H(f)| ≤ 1 + δp,  0 ≤ |f| ≤ fp stopband ripple control |H(f)| ≤ δs,  fs ≤ |f| ≤ 0.5
Figure 7.5.a. The specification, drawn. Everything Eqs. (7.18)–(7.22) manipulate is visible here: the passband corridor \(1-\delta_p\le|H(f)|\le1+\delta_p\) out to \(f_p\), the stopband ceiling \(|H(f)|\le\delta_s\) from \(f_s\) to Nyquist, the transition band \(\Delta f=f_s-f_p\) that the window's main lobe has to fit inside, and the ideal cutoff \(f_c=\tfrac12(f_p+f_s)\) placed at its centre. The two dB brackets on the left are the same two constraints as the designer states them, \(A_p\) peak-to-peak across the passband corridor and \(A_s\) down to the stopband ceiling.

7.5.1  Reading the specification

Window formulas use linear ripple tolerances, so first convert the passband ripple \(A_p\) and stopband attenuation \(A_s\) from decibels into \(\delta_p\) and \(\delta_s\):

$$ \delta_p=\frac{\gamma-1}{\gamma+1},\ \ \gamma=10^{A_p/20},\qquad \delta_s=10^{-A_s/20} $$
(7.18)

and, in the other direction,

$$ A_p=20\log_{10}\!\Big(\frac{1+\delta_p}{1-\delta_p}\Big),\qquad A_s=20\log_{10}\!\Big(\frac{1+\delta_p}{\delta_s}\Big) $$
(7.19)

The frequency specs are the two band edges. The window smears the ideal brick wall symmetrically about its own centre (Figure 7.3.c), so the ideal cutoff is placed at the middle of the transition band, and the width of that band is what sets the order:

$$ f_c=\tfrac{1}{2}(f_p+f_s),\qquad \Delta f=f_s-f_p $$
(7.20)

or, in radians per sample,

$$ \omega_c=2\pi f_c,\qquad \Delta\omega=2\pi\Delta f $$
(7.21)

Unlike minimax design, a window does not independently control passband and stopband ripple. The same window spectrum affects both bands, so the design must satisfy the tighter of \(\delta_p\) and \(\delta_s\). The other band will usually perform better than required.

$$ \delta=\min(\delta_p,\delta_s),\qquad A=-20\log_{10}\delta,\qquad \Delta\omega=\min(\Delta\omega_1,\Delta\omega_2,\dots) $$
(7.22)

The same rule applies to the transition bands. A band-pass or band-stop filter has two transitions, but one window, and so one main-lobe width, has to serve both. The window must therefore be long enough for the narrowest transition, which is why Eq. (7.22) also takes \(\Delta\omega\) as the minimum over all transition widths. The wider transition will then be sharper than required.

Two numbers come out of the specification and nothing else matters: \(A\) picks the window shape, \(\Delta\omega\) picks the window length. They are independent knobs, which is exactly why the method needs no iteration.

7.5.2  The recipe, with a fixed window

For a fixed window, use the required attenuation to choose the window and its constant \(K\). Use the narrowest transition width in Eq. (7.15) to estimate \(M\), place \(\omega_c\) at the transition centre, calculate the ideal sinc and multiply by the window.

Amplitude specs
1\(A_p\quad A_s\)
\(\delta_p\quad \delta_s\)
see Figure 7.5.a
\(\delta=\min(\delta_p,\delta_s)\)
\(A=-20\log_{10}\delta\)
Window shape
2from Table 7.4
gives \(K\)
Compute impulse response
6\(h[n]=w[n]\dfrac{\sin\big(\omega_c(n-M/2)\big)}{\pi(n-M/2)}\)
Compute window
5\(w[n]\)
\(\omega_c\)
adjust length:
I, II, III, IV
Frequency specs
3\(f_p\quad f_s\)
\(f_c\quad \Delta f\)
\(\Delta f=\min(\Delta f_1,\Delta f_2,\dots)\)
see Figure 7.5.a
\(L=\dfrac{K\pi}{\Delta\omega}\)
Window length
4\(L\)
order \(M=L-1\)
Figure 7.5.b. The window design recipe with a fixed window, in six numbered steps — the same six as the checklist at the end of this section, with steps 1 and 3 reading their inputs straight off Figure 7.5.a. Amplitude specs set the shape through the worst-case ripple \(A\) of Eq. (7.22); frequency specs set the length through Eq. (7.15), using the \(K\) belonging to the shape already chosen. The two meet in \(w[n]\), which multiplies the ideal sinc evaluated at the transition-centre cutoff \(\omega_c\). Nothing feeds back: the only correction is rounding \(L\) so the resulting type can realise the response wanted.

7.5.3  The same recipe with a Kaiser window

For a Kaiser design, use the required attenuation to calculate the shape parameter \(\beta\) and use the Kaiser order estimate with the narrowest transition width. The remaining steps—ideal sinc, delay, multiplication and verification—are unchanged.

Amplitude specs
1\(A_p\quad A_s\)
\(\delta_p\quad \delta_s\)
see Figure 7.5.a
\(\delta=\min(\delta_p,\delta_s)\)
\(A=-20\log_{10}\delta\)
Shape parameter
2\(\beta\) from Eq. (7.17)
continuous in \(A\)
\(\beta\)
Compute impulse response
6\(h[n]=w[n]\dfrac{\sin\big(\omega_c(n-M/2)\big)}{\pi(n-M/2)}\)
Compute window
5\(w_K[n]\), Eq. (7.16)
\(\omega_c\)
adjust length:
I, II, III, IV
Frequency specs
3\(f_p\quad f_s\)
\(f_c\quad \Delta f\)
\(\Delta f=\min(\Delta f_1,\Delta f_2,\dots)\)
see Figure 7.5.a
\(M\approx\dfrac{A-8}{2.285\,\Delta\omega}\)
Window length
4\(L\)
order \(M=L-1\)
Figure 7.5.c. The Kaiser variant, numbered the same way. Only steps 2 and 4 change: the table lookup is replaced by Eq. (7.17), which turns the required attenuation \(A\) straight into \(\beta\), and the order estimate becomes Kaiser's own — both continuous in \(A\), which is why the design pays for exactly the attenuation asked for and no more (Examples 7.8 and 7.5).

Examples 7.3–7.5 apply both recipes to a low-pass, a filter with two non-zero gains and a band-pass; Example 7.6 adds a filter after a fixed one, where the two ripples add. The window is chosen from the \(A_s\) column of the window table, and the length from its mainlobe column.

EXAMPLE 7.3 · A 10 kHz low-pass, Blackman and Kaiser

A system samples at \(F_s=40\) kHz. Design a linear-phase FIR low-pass filter with \(A_p=0.1\) dB passband ripple up to 8 kHz and \(A_s=60\) dB stopband attenuation from 12 kHz to the Nyquist frequency of 20 kHz. Use the fixed-window recipe, then a Kaiser window.

1
Amplitude specs

By Eq. (7.18): \(\gamma=10^{A_p/20}=10^{0.1/20}\approx1.0116\), so \(\delta_p=\dfrac{\gamma-1}{\gamma+1}\approx0.0058\); and \(\delta_s=10^{-A_s/20}=10^{-60/20}=0.001\).

passbandAp  = 0.1 dB, δp  ≈ 0.00581 + δp 1 − δp stopbandAs  = 60 dB, δs  = 0.001fc  = 0.25 (10 kHz)f|H(f)|100 kHz0.28 kHz0.312 kHz0.520 kHzΔf = 0.1 (4 kHz)

Calculated specification in normalized frequency \(f=F/F_s\), with the corresponding frequencies in kHz in grey. Tolerance bands are drawn wider than scale.

2
Window shape

\(\delta=\min(0.0058,\;0.001)=0.001\), so \(A=60\) dB. Hamming reaches only 53 dB; Blackman is the first window to clear 60 dB.

WindowSide lobe (dB)Mainlobe\(A_p\) (dB)\(A_s\) (dB)
Rectangular−13\(4\pi/L\)0.7521
Bartlett−25\(8\pi/L\)0.4526
Hann−31\(8\pi/L\)0.05544
Hamming−41\(8\pi/L\)0.01953
Blackman ← selected−57\(12\pi/L\)0.001774

Windows whose \(A_s\) falls short of \(A=60\) dB are greyed out; the selected window is the first that reaches it, since every later row costs a longer filter. Its mainlobe width \(\Delta\omega=K\pi/L\) gives the length.

3
Frequency specs

Normalize by \(F_s=40\) kHz: \(f_p=8/40=0.2\) and \(f_s=12/40=0.3\). Then, by Eqs. (7.20)–(7.21),

$$ f_c=\tfrac12(0.2+0.3)=0.25,\qquad \Delta f=0.3-0.2=0.1,\qquad \Delta\omega=2\pi(0.1)=0.2\pi $$

In hertz, the cutoff is 10 kHz and the transition is 4 kHz wide. In radians per sample the edges are \(\omega_p=0.4\pi\) and \(\omega_s=0.6\pi\), with \(\omega_c=0.5\pi\). MATLAB's fir1 and firpm normalize to Nyquist \(=1\), so there the edges are entered as 0.4 and 0.6.

4
Window length and type
$$ L=\frac{12\pi}{\Delta\omega}=\frac{12\pi}{0.2\pi}=60,\qquad M=L-1=59 $$

\(M\) is odd, so this is a Type II filter. Its forced zero at \(z=-1\) (20 kHz) lies in the stopband, where it does no harm.

5
Impulse response
$$ h_d[n]=\int_{-0.25}^{0.25}e^{j2\pi fn}\,df=\frac{\sin(0.5\pi n)}{\pi n} $$

Shift by \(M/2=29.5\) and window: \(h[n]=w_{\text{Blackman}}[n]\,\dfrac{\sin\big(0.5\pi(n-29.5)\big)}{\pi(n-29.5)}\), \(0\le n\le59\). Because \(M/2\) is not an integer, no sample falls on the sinc peak.

6
Kaiser alternative

With \(A=60>50\) dB, the top case of Eq. (7.17) applies:

$$ \beta=0.1102(60-8.7)\approx5.6533 $$
$$ M=\frac{60-8}{2.285(0.2\pi)}\approx36.22\;\rightarrow\;37,\qquad L=M+1=38 $$

\(M=37\) is odd, so the Kaiser design is Type II; its forced zero at \(z=-1\) (20 kHz) lies in the stopband. It needs 38 taps against Blackman's 60, because \(\beta\) is tuned to the 60 dB required rather than the 74 dB Blackman delivers.

EXAMPLE 7.4 · A bass-boost filter with gain 4 below 1 kHz

A signal sampled at \(F_s=20\) kHz is to be filtered with gain 4 for \(0\le F\le1\) kHz and gain 1 for \(3\le F\le10\) kHz, each within \(\pm0.01\). Design a linear-phase FIR filter with a fixed window, then with a Kaiser window.

1
Amplitude specs

Normalize by \(F_s=20\) kHz: \(f_1=1/20=0.05\) and \(f_2=3/20=0.15\). Both bands are passbands, one with gain 4 and one with gain 1, and each must stay within \(\pm0.01\) of its gain.

gain 4±0.014.013.99gain 1±0.011.010.99fc  = 0.1 (2 kHz)f|H(f)|4100 kHz0.051 kHz0.153 kHz0.510 kHzΔf = 0.1 (2 kHz)

Calculated specification in normalized frequency \(f=F/F_s\), with the corresponding frequencies in kHz in grey. Tolerance bands are drawn wider than scale. The step at \(f_c\) is 3 high, three times the unit step that the window table assumes.

To see what the tolerance means for the window, split the target into two filters that share the same window and cutoff: a gain-4 low-pass and a gain-1 high-pass, \(H=4H_{LP}+H_{HP}\). Let \(\delta\) be the ripple the window leaves on a unit step.

  • The gain-4 low-pass ripples by \(4\delta\).
  • The gain-1 high-pass is \(h_{HP}[n]=\delta[n-\alpha]-h_{LP}[n]\), so its ripple is the low-pass ripple with the opposite sign: \(-\delta\).
  • Together: \(4\delta-\delta=3\delta\), not \(5\delta\).

The responses themselves show where each ripple sits:

full scalezoom: 0–1 kHzzoom: 3–10 kHz4·HLP 0144+0.01−0.014δ0+0.01−0.014δHHP  = 1 − HLP 0140+0.01−0.01δ1+0.01−0.01δH = 4HLP  + HHP 01401310 kHz4+0.01−0.013δ01 kHz1+0.01−0.013δ310 kHz

Computed amplitude responses of the Hamming design (\(M=40\)). Left: full scale, where the ripple is too small to see. Middle and right: each band magnified to \(\pm0.012\) about its target level, with the \(\pm0.01\) limits dashed in red. The gain-4 low-pass ripples about 4 and about 0; the high-pass ripples about 0 and about 1, with each ripple the mirror image of the low-pass ripple at a quarter of its size; the total ripples about 4 and about 1, inside the limits. The black brackets mark the largest ripple peak in each band: \(4\delta\), \(\delta\) and \(3\delta\). The size of \(\delta\) varies from band to band and peak to peak, but at every frequency the three deviations keep the ratio 4 : 1 : 3. The largest \(\delta\), right at the band edges, is about 0.0026.

Subtracting each band's target level leaves only the errors, which can then be compared directly:

transition−0.015−0.010−0.0050+0.005+0.010+0.015spec ±0.0100.050.10.150.30.5f+4δ: gain-4 low-pass−δ: gain-1 high-passtotal: +3δ

Ripple of the two parts for the final design (Hamming window, \(M=40\), step 4), outside the transition band. Wherever the low-pass error is \(+4\delta\), the high-pass error is \(-\delta\), so the sum is \(3\delta\), here peaking at 0.0077, inside the \(\pm0.01\) limits. Adding magnitudes, \(4\delta+\delta=5\delta\), would overestimate it.

The two parts are never built separately. Their sum is one filter, \(H=4H_{LP}+(1-H_{LP})=3H_{LP}+1\): a single impulse response, a low-pass of height 3 plus a delayed impulse (step 5). The requirement is therefore

$$ 3\delta\le0.01\quad\Longrightarrow\quad \delta=\frac{0.01}{3}\approx0.0033 $$
2
Window shape

With \(\delta=0.01/3\) from step 1:

$$ A=-20\log_{10}\delta=40+20\log_{10}3\approx49.5\text{ dB} $$

Hann (44 dB) is no longer enough; Hamming is the first window to clear 49.5 dB.

WindowSide lobe (dB)Mainlobe\(A_p\) (dB)\(A_s\) (dB)
Rectangular−13\(4\pi/L\)0.7521
Bartlett−25\(8\pi/L\)0.4526
Hann−31\(8\pi/L\)0.05544
Hamming ← selected−41\(8\pi/L\)0.01953
Blackman−57\(12\pi/L\)0.001774

Windows whose \(A_s\) falls short of \(A=49.5\) dB are greyed out; the selected window is the first that reaches it, since every later row costs a longer filter. Its mainlobe width \(\Delta\omega=K\pi/L\) gives the length.

3
Frequency specs
$$ f_c=\tfrac12(0.05+0.15)=0.1,\qquad \Delta f=0.15-0.05=0.1,\qquad \Delta\omega=2\pi(0.1)=0.2\pi $$

In hertz, the cutoff is 2 kHz and the transition is 2 kHz wide; in radians per sample, \(\omega_c=0.2\pi\).

4
Window length and type
$$ L=\frac{8\pi}{\Delta\omega}=\frac{8\pi}{0.2\pi}=40,\qquad M=39\;\rightarrow\;40,\qquad L=41 $$

\(L=40\) gives an odd \(M=39\). Step 5 requires an even \(M\), so the order is raised to \(M=40\) (Type I) and \(L=41\).

5
Impulse response

Write the desired response as a scaled low-pass plus a constant:

$$ H(f)=\begin{cases}4,&|f|\le0.1\\1,&0.1\le|f|\le0.5\end{cases}=\begin{cases}3,&|f|\le0.1\\0,&0.1\le|f|\le0.5\end{cases}+1 $$

The constant 1 transforms to \(\delta[n]\), so

$$ h_d[n]=3\,\frac{\sin(0.2\pi n)}{\pi n}+\delta[n],\qquad h_d[n-\alpha]=3\,\frac{\sin\big(0.2\pi(n-\alpha)\big)}{\pi(n-\alpha)}+\delta[n-\alpha] $$

The delayed impulse \(\delta[n-\alpha]\) only exists if \(\alpha=M/2\) is an integer, so \(M\) must be even: a Type I filter. With \(M=40\), \(\alpha=20\) and \(h[n]=w_{\text{Hamming}}[n]\,h_d[n-20]\). Since \(w[20]=1\), the impulse passes through the window unchanged, and all the ripple comes from the low-pass term of height 3, the \(3\delta\) of step 1.

6
Kaiser alternative

With \(A=49.5\) dB, the middle case of Eq. (7.17) applies:

$$ \beta=0.5842(49.5-21)^{0.4}+0.07886(49.5-21)\approx4.48 $$
$$ M=\frac{49.5-8}{2.285(0.2\pi)}\approx28.9\;\rightarrow\;29\;\rightarrow\;30,\qquad L=31 $$

\(M\) is raised from 29 to the even value 30 for the same reason as in step 4.

EXAMPLE 7.5 · A band-pass filter, Hann and Kaiser

Design a linear-phase FIR band-pass filter with lower stopband \(0\le|f|\le0.125\), passband \(0.175\le|f|\le0.3\) and upper stopband \(0.4\le|f|\le0.5\) (normalized, \(f=F/F_s\)), with \(\delta_p=0.05\) and \(\delta_s=0.01\). Follow the fixed-window recipe of Figure 7.5.b, then repeat with a Kaiser window (Figure 7.5.c).

1
Amplitude specs

Convert the tolerances with Eq. (7.19): \(A_p=20\log_{10}\dfrac{1+\delta_p}{1-\delta_p}=20\log_{10}\dfrac{1.05}{0.95}\approx0.8693\) dB, and \(A_s=-20\log_{10}\delta_s=-20\log_{10}0.01=40\) dB in both stopbands.

stopbandδs  = 0.01, As  = 40 dBpassbandδp  = 0.05, Ap  ≈ 0.87 dB1.050.95stopbandδs  = 0.01, As  = 40 dBfc1  = 0.15fc2  = 0.35f|H(f)|100.1250.1750.30.40.5Δf = 0.05 (binding)

Calculated specification. Tolerance bands are drawn wider than scale; the solid line is the ideal response with its cutoffs at the transition centres.

2
Window shape

By Eq. (7.22), \(\delta=\min(\delta_p,\delta_s)=\min(0.05,0.01)=0.01\), so \(A=-20\log_{10}0.01=40\) dB.

WindowSide lobe (dB)Mainlobe\(A_p\) (dB)\(A_s\) (dB)
Rectangular−13\(4\pi/L\)0.7521
Bartlett−25\(8\pi/L\)0.4526
Hann ← selected−31\(8\pi/L\)0.05544
Hamming−41\(8\pi/L\)0.01953
Blackman−57\(12\pi/L\)0.001774

Windows whose \(A_s\) falls short of \(A=40\) dB are greyed out; the selected window is the first that reaches it, since every later row costs a longer filter. Its mainlobe width \(\Delta\omega=K\pi/L\) gives the length.

3
Frequency specs

There are two transitions, \(0.175-0.125=0.05\) and \(0.4-0.3=0.1\). One main lobe must fit through both, so the narrower one sets the order:

$$ \Delta f=\min(0.05,\;0.1)=0.05,\qquad \Delta\omega=2\pi(0.05)=0.1\pi $$

The cutoffs sit at the transition centres (Eq. 7.20): \(f_{c1}=\tfrac12(0.125+0.175)=0.15\) and \(f_{c2}=\tfrac12(0.3+0.4)=0.35\).

4
Window length and type
$$ L=\frac{8\pi}{\Delta\omega}=\frac{8\pi}{2\pi(0.05)}=80,\qquad M=L-1=79 $$

\(M\) is odd, so this is a Type II filter. Its forced zero at \(z=-1\) (\(\omega=\pi\)) lies in the upper stopband, where it does no harm.

5
Impulse response

The ideal band-pass is the passband integral over both \(\pm\) bands, which is the difference of two ideal low-passes:

$$ h_d[n]=\int_{-0.35}^{-0.15}e^{j2\pi fn}\,df+\int_{0.15}^{0.35}e^{j2\pi fn}\,df=\frac{\sin(0.7\pi n)}{\pi n}-\frac{\sin(0.3\pi n)}{\pi n} $$

Shift by \(M/2=39.5\) and window: \(h[n]=w_{\text{Hann}}[n]\,h_d[n-M/2]\), \(0\le n\le79\).

6
Kaiser alternative

With \(A=40\) dB, the middle case of Eq. (7.17) applies:

$$ \beta=0.5842(40-21)^{0.4}+0.07886(40-21)\approx3.3953 $$
$$ M=\frac{A-8}{2.285\,\Delta\omega}=\frac{40-8}{2.285(0.1\pi)}\approx44.58\;\rightarrow\;45,\qquad L=46 $$

\(M=45\) is odd, so the Kaiser design is also Type II, with 34 fewer taps than Hann.

EXAMPLE 7.6 · Adding a filter after a fixed codec: ripples add

A signal is digitised at \(F_s=20\) kHz by an audio codec whose built-in digital low-pass filter cannot be changed. Its datasheet gives a passband of 0–6 kHz with ripple \(\pm0.004\) and at least 40 dB attenuation above 8 kHz. The application must also remove rumble below 1 kHz with \(A_s=40\) dB, while keeping 2–6 kHz within an overall passband ripple of \(\pm0.01\). Design the high-pass filter that follows the codec, with a fixed window and with a Kaiser window.

1
Amplitude and frequency specs

Normalize by \(F_s=20\) kHz: 1, 2, 6 and 8 kHz become 0.05, 0.1, 0.3 and 0.4. The overall passband tolerance is \(\pm0.01\), and \(A_s=40\) dB below 1 kHz gives \(\delta_s=10^{-40/20}=0.01\).

codec low-pass (fixed)stopbandδs  = 0.01overall passband±0.01 (codec uses ±0.004)1.010.99new high-passfc  = 0.075f|H(f)|100 kHz0.051 kHz0.12 kHz0.36 kHz0.48 kHz0.510 kHzΔf = 0.05

Calculated specification in normalized frequency, kHz in grey. The grey region belongs to the codec and cannot be changed; only the high-pass (solid line, cutoff \(f_c\)) is designed. Tolerance bands are drawn wider than scale.

2
Ripple budget

The signal passes through the codec filter and then the new high-pass, so the responses multiply. In the passband both are close to 1:

$$ H=(1+\varepsilon_{\text{codec}})(1+\varepsilon_{HP})\approx1+\varepsilon_{\text{codec}}+\varepsilon_{HP} $$

The two filters are unrelated, so their errors can peak at the same frequency with the same sign. The worst case is the sum, and the codec has already used 0.004 of the 0.01 allowed:

$$ 0.004+\delta_{HP}\le0.01\quad\Longrightarrow\quad\delta_{HP}\le0.006 $$

The stopband does not add. Below 1 kHz, \(|H|=|H_{HP}|\,|H_{\text{codec}}|\approx\delta_s\cdot1\), so the high-pass needs \(\delta_s=0.01\) there; above 8 kHz the codec does the work.

3
Window shape

\(\delta=\min(\delta_{HP},\delta_s)=\min(0.006,\;0.01)=0.006\), so \(A=-20\log_{10}0.006\approx44.4\) dB. Hann reaches 44 dB, just short; Hamming is the first window that clears it.

WindowSide lobe (dB)Mainlobe\(A_p\) (dB)\(A_s\) (dB)
Rectangular−13\(4\pi/L\)0.7521
Bartlett−25\(8\pi/L\)0.4526
Hann−31\(8\pi/L\)0.05544
Hamming ← selected−41\(8\pi/L\)0.01953
Blackman−57\(12\pi/L\)0.001774

Windows whose \(A_s\) falls short of \(A=44.4\) dB are greyed out; the selected window is the first that reaches it, since every later row costs a longer filter. Its mainlobe width \(\Delta\omega=K\pi/L\) gives the length.

Ignoring the codec would give \(\delta=0.01\), \(A=40\) dB and the Hann window. Its ripple of about 0.0063 plus the codec's 0.004 can reach 0.0103, outside the specification.

4
Frequency specs
$$ f_c=\tfrac12(0.05+0.1)=0.075,\qquad \Delta f=0.1-0.05=0.05,\qquad \Delta\omega=2\pi(0.05)=0.1\pi $$

Only the lower transition belongs to the high-pass; the upper edge is the codec's.

5
Length, type and impulse response
$$ L=\frac{8\pi}{0.1\pi}=80,\qquad M=79\;\rightarrow\;80,\qquad L=81 $$

A high-pass must pass \(\omega=\pi\), where a Type II filter has a forced zero (Section 7.5.4), so \(M\) is raised to 80: Type I. The ideal high-pass is an impulse minus a low-pass:

$$ h[n]=w_{\text{Hamming}}[n]\Big(\delta[n-40]-\frac{\sin\big(0.15\pi(n-40)\big)}{\pi(n-40)}\Big),\qquad 0\le n\le80 $$
6
Kaiser alternative

With \(A=44.4\) dB, the middle case of Eq. (7.17) applies:

$$ \beta=0.5842(44.4-21)^{0.4}+0.07886(44.4-21)\approx3.91 $$
$$ M=\frac{44.4-8}{2.285(0.1\pi)}\approx50.8\;\rightarrow\;51\;\rightarrow\;52,\qquad L=53 $$

\(M\) is raised from 51 to 52 for the same Type I reason as in step 5.

7.5.4  Adjusting the length for the type

The order estimate must be rounded up to an integer. Its parity determines the FIR type and therefore any forced zeros. Choose an even or odd order that is compatible with the required response.

Low-pass

Type I or II. Either parity works — the forced zero at \(z=-1\) sits deep in the stopband.

High-pass

Type I only: \(M\) must be even, or the \(z=-1\) zero kills the passband at \(\omega=\pi\).

Band-pass

Type I or II (Example 7.9 uses both). Order set by the narrower of the two transitions.

Band-stop

Type I only: it must pass both DC and \(\omega=\pi\), so no forced zero is tolerable.

EXAMPLE 7.7 · A narrow-transition low-pass with a fixed window

Design a low-pass filter with \(A_p=0.1\,\text{dB}\), \(A_s=60\,\text{dB}\), passband \(0\le|f|\le0.24\), stopband \(0.26\le|f|\le0.5\) (normalized). Pick the best fixed window from Table 7.4's catalog and state the filter's order, type, and group delay.

1
Transition width

\(\Delta f=0.26-0.24=0.02\Rightarrow\Delta\omega=2\pi\Delta f=0.04\pi\).

2
Window choice

Need at least 60 dB attenuation; Table 7.4 gives Hann 44 dB, Hamming ~53 dB, Blackman ~74 dB — only Blackman clears 60 dB.

3
Order

By Eq. (7.15), \(K=12\): \(M\approx\dfrac{12\pi}{0.04\pi}-1=299\). \(M\) odd ⇒ Type II (its forced zero at \(z=-1\) sits in the stopband, so it is harmless), length \(L=300\), group delay \(\tau=M/2=149.5\).

4
Ideal response

Cutoff at the transition centre: \(f_c=\tfrac{0.24+0.26}{2}=0.25\), \(\omega_c=0.5\pi\), so \(h_d[n]=\dfrac{\sin(\omega_c(n-M/2))}{\pi(n-M/2)}\) (with \(h_d[M/2]=\omega_c/\pi=0.5\)), and the final filter is \(h[n]=h_d[n]\,w_{\text{Blackman}}[n]\).

EXAMPLE 7.8 · The same low-pass, redesigned with a Kaiser window

Repeat Example 7.7's specification (\(A_s=60\,\text{dB}\), \(\Delta\omega=0.04\pi\)) using the Kaiser window instead, and compare the resulting order to Blackman's \(M=299\).

1
Order

\(M\approx\dfrac{A_s-8}{2.285\,\Delta\omega}=\dfrac{60-8}{2.285(0.04\pi)}\approx181\). Round up to an even order for Type I: \(\boxed{M=182}\), \(L=183\), \(\tau=91\).

2
Shape parameter

Since \(A_s=60>50\), Eq. (7.17)'s top case applies: \(\beta\approx0.1102(60-8.7)=0.1102(51.3)\approx\boxed{5.65}\).

3
Comparison

Kaiser reaches the same 60 dB, 0.02-wide transition in \(M=182\) versus Blackman's \(M=299\) — 39% fewer taps, because Blackman's fixed \(-57\,\text{dB}\) design over-delivers stopband depth it was not asked for, while Kaiser's \(\beta\) is tuned to exactly 60 dB and no more.

MATLAB corner for Example 7.8

This script designs Example 7.7's specification three ways at once — Blackman, Kaiser, and Parks–McClellan — from the same ideal sinc, and prints a table of order, length and group delay for each. It is the whole lecture in one file: the same target, reached by both methods of the comparison table above.

Goal: confirm the Kaiser design (\(M=182,\beta=5.65\)) meets the same 60 dB target as the Blackman design (\(M=299\)) with far fewer taps.

FIR_exmp_1.m
MATLAB
%% FIR_exmp_1.m - FIR lowpass filter comparison
% Blackman vs Kaiser vs Equiripple (Parks–McClellan)
clear; close all; clc;
 
%% --------------------------------------------------------
% Specifications
%% --------------------------------------------------------
Ap_dB = 0.1;      % passband ripple max (dB)
As_dB = 60;       % stopband attenuation min (dB)
fp = 0.24;        % passband edge (normalized)
fs = 0.26;        % stopband edge (normalized)
fc = (fp+fs)/2;   % center of transition band
wc = 2*pi*fc;
 
% Convert to linear ripple tolerances
delta_p = (10^(Ap_dB/20)-1)/(10^(Ap_dB/20)+1);
delta_s = 10^(-As_dB/20);
delta = min(delta_p,delta_s);
 
fprintf("Passband ripple (linear): %g\n", delta_p);
fprintf("Stopband ripple (linear):  %g\n", delta_s);
 
%% ========================================================
% 1) Ideal LPF impulse response (long, centered)
%% ========================================================
Lmax = 801;                % make it odd so there is a clear center
n    = 0:Lmax-1;
Mmid = (Lmax-1)/2;         % exact center index
 
h_ideal = sin(wc*(n-Mmid))./(pi*(n-Mmid));
h_ideal(Mmid+1) = wc/pi;   % handle n = Mmid
 
%% ========================================================
% 2) Window method #1: Blackman
%% ========================================================
Delta_w   = 0.04*pi;                    % 0.26 - 0.24
M_black   = ceil(12*pi/Delta_w);        % ~300
L_black   = M_black + 1;                % filter length
 
w_black = blackman(L_black).';
 
% center an L_black-long slice of h_ideal
start_b = Mmid - floor((L_black-1)/2);
stop_b  = start_b + L_black - 1;
h_black = h_ideal(start_b:stop_b) .* w_black;
 
fprintf("Blackman:  Order = %d, Length = %d\n", M_black, L_black);
 
%% ========================================================
% 3) Window method #2: Kaiser
%% ========================================================
A        = -20*log10(delta_s);          % required attenuation (≈60 dB)
Delta_w  = 0.04*pi;
M_kaiser = ceil((A - 8)/(2.285*Delta_w));
L_kaiser = M_kaiser + 1;
 
% Kaiser beta
if A > 50
    beta = 0.1102*(A - 8.7);
elseif A >= 21
    beta = 0.5842*(A-21)^0.4 + 0.07886*(A-21);
else
    beta = 0;
end
 
w_kaiser = kaiser(L_kaiser, beta).';
 
start_k = Mmid - floor((L_kaiser-1)/2);
stop_k  = start_k + L_kaiser - 1;
h_kaiser = h_ideal(start_k:stop_k) .* w_kaiser;
 
fprintf("Kaiser:    Order = %d, Length = %d, Beta = %.3f\n", ...
        M_kaiser, L_kaiser, beta);
 
%% ========================================================
% 4) Equiripple (Parks–McClellan)
%% ========================================================
Fedges = [fp fs];
Amps   = [1 0];
Devs   = [delta_p delta_s];
 
[N_est, Fo, Ao, W] = firpmord(Fedges, Amps, Devs, 1);
 
% Make the filter Type-I (even order -> odd length)
if mod(N_est,2)==1
    N_eq = N_est + 1;
else
    N_eq = N_est;
end
 
h_eq = firpm(N_eq, Fo, Ao, W);
 
fprintf("Equiripple: Order = %d, Length = %d\n", N_eq, N_eq+1);
 
%% ========================================================
% 5) Frequency responses
%% ========================================================
Nfft = 4096;
[H_black, w]  = freqz(h_black,  1, Nfft);
[H_kaiser,~]  = freqz(h_kaiser, 1, Nfft);
[H_eq,~]      = freqz(h_eq,     1, Nfft);
 
f = w/(2*pi); % normalize 0..0.5
 
figure;
subplot(2,1,1);
plot(f, abs(H_black),  'LineWidth',1.2); hold on;
plot(f, abs(H_kaiser), 'LineWidth',1.2);
plot(f, abs(H_eq),     'LineWidth',1.5);
grid on; xlim([0 0.5]);
legend('Blackman','Kaiser','Equiripple','Location','best');
title('Magnitude Response (Linear)');
xlabel('Normalized frequency f'); ylabel('|H(f)|');
 
subplot(2,1,2);
plot(f, 20*log10(abs(H_black)+eps)); hold on;
plot(f, 20*log10(abs(H_kaiser)+eps));
plot(f, 20*log10(abs(H_eq)+eps),'LineWidth',1.5);
yline(-As_dB,'--k');
yline(-Ap_dB,'--r');
grid on; xlim([0 0.5]); ylim([-140 5]);
legend('Blackman','Kaiser','Equiripple','Location','best');
title('Magnitude Response (dB)');
xlabel('Normalized frequency f'); ylabel('Magnitude (dB)');
 
%% ========================================================
% 6) Impulse responses
%% ========================================================
figure;
subplot(3,1,1);
stem(0:L_black-1, h_black,'filled'); grid on;
title(sprintf("Blackman FIR (L = %d)", L_black));
 
subplot(3,1,2);
stem(0:L_kaiser-1, h_kaiser,'filled'); grid on;
title(sprintf("Kaiser FIR (L = %d)", L_kaiser));
 
subplot(3,1,3);
stem(0:N_eq, h_eq,'filled'); grid on;
title(sprintf("Equiripple FIR (L = %d)", N_eq+1));
 
%% ========================================================
% 7) Summary
%% ========================================================
fprintf("\n================ Summary ================\n");
fprintf("Method       Length   Order   GroupDelay\n");
fprintf("Blackman     %6d   %6d   %10.2f\n", L_black,  M_black,  M_black/2);
fprintf("Kaiser       %6d   %6d   %10.2f\n", L_kaiser, M_kaiser, M_kaiser/2);
fprintf("Equiripple   %6d   %6d   %10.2f\n", N_eq+1,   N_eq,     N_eq/2);
fprintf("=========================================\n");
Magnitude response of the Blackman, Kaiser and equiripple low-pass designs, linear on top and dB below against the 60 dB stopband line
Figure 7.5.d. Three methods for the same low-pass specification. On the linear-scale plot, the equiripple, Kaiser and Blackman responses are almost indistinguishable because all three meet the passband requirement and use the same band edge at \(f=0.25\). The dB plot reveals how they use the stopband tolerance. The equiripple design keeps its largest errors close to \(-60\,\text{dB}\) throughout the stopband, using the allowed error evenly. The Kaiser and Blackman side lobes fall below \(-80\,\text{dB}\) away from the edge. That extra attenuation was not required and generally costs additional taps.
Impulse responses of the three low-pass designs: Blackman length 301, Kaiser length 183, equiripple length 137
Figure 7.5.e. Coefficient count and computational cost. The Blackman design uses 301 taps, the Kaiser design uses 183, and the Parks–McClellan design uses 137. All three meet the same specification, so the shorter minimax filter requires fewer multiplications per output sample and has less delay. Each impulse response is symmetric about its centre sample, confirming an exact-linear-phase Type I filter. The methods differ in length, not in the linear-phase property.

An ideal band-pass impulse response is the difference between two ideal low-pass responses. The same windowing procedure therefore applies. The important extra step is to calculate both transition widths; the narrower transition determines the required order.

EXAMPLE 7.9 · A band-pass design, Hann against Kaiser

Design a band-pass filter with stopband edges \(f_{1s}=0.125\), \(f_{2s}=0.40\) and passband \(0.175\le f\le0.30\) (normalized, Nyquist \(=0.5\)), with \(\delta_p=0.05\) and \(\delta_s=0.01\). Give the order and type using the Hann window, then again using Kaiser, and say which transition band decides the answer.

1
Specifications in dB

\(A_p=20\log_{10}\dfrac{1+\delta_p}{1-\delta_p}\approx0.87\,\text{dB}\) and \(A_s=-20\log_{10}\delta_s=40\,\text{dB}\).

2
The binding transition

The lower transition is \(0.175-0.125=0.05\), the upper is \(0.40-0.30=0.10\). The window smears both edges by the same main-lobe width, so the narrower one governs: \(\Delta f=0.05\Rightarrow\Delta\omega=0.1\pi\).

3
Hann

Hann gives \(\approx44\,\text{dB}\), clearing the 40 dB target. With \(K=8\) from the catalog, Eq. (7.15) gives \(M\approx8\pi/0.1\pi-1=79\) — odd, so a Type II filter (even symmetry, \(M\) odd), group delay \(M/2=39.5\) samples. A Type II forced zero sits at \(z=-1\), which is harmless here: \(\omega=\pi\) is deep in the stopband.

4
Kaiser

\(M\approx\dfrac{A_s-8}{2.285\,\Delta\omega}=\dfrac{40-8}{2.285(0.1\pi)}\approx45\), rounded up to an even order for Type I, with \(\beta\) from Eq. (7.17)'s middle case: \(\beta=0.5842(19)^{0.4}+0.07886(19)\approx3.40\). Group delay \(\approx23\) samples.

Kaiser reaches the same 40 dB with roughly 40% fewer taps (\(M=46\) against \(79\)), because Hann over-delivers (44 dB where 40 was asked) while \(\beta\) is tuned to the target exactly — the same over-payment Example 7.8 found at 60 dB, and the reason Kaiser is the default.

MATLAB corner

This script builds Example 7.9 both ways: it forms the ideal band-pass as a difference of two low-pass sincs, applies the Hann and Kaiser windows of the same centred slice, and prints the order, group delay and \(\beta\) for each.

Goal: confirm both designs clear the 40 dB stopband and 0.87 dB passband specs, and that Kaiser does it with roughly 40% fewer taps than Hann.

FIR_exmp_2.m
MATLAB
%% FIR_exmp_2.m - FIR bandpass filter comparison
% Hann vs Kaiser (using ideal BPF prototype)
clear; close all; clc;
 
%% --------------------------------------------------------
% Specifications (normalized frequency, Nyq = 0.5)
%% --------------------------------------------------------
f1s = 0.125;     % stopband edge 1
f1p = 0.175;     % passband start
f2p = 0.30;      % passband end
f2s = 0.40;      % stopband start
 
delta_p = 0.05;     % passband ripple
delta_s = 0.01;     % stopband ripple
delta = min(delta_p, delta_s);
 
Ap_dB = 20*log10((1+delta_p)/(1-delta_p));   % ≈ 0.87 dB
As_dB = -20*log10(delta_s);                  % = 40 dB
 
fprintf("delta_p = %.4f  (%.2f dB)\n", delta_p, Ap_dB);
fprintf("delta_s = %.4f  (%.2f dB)\n", delta_s, As_dB);
 
%% --------------------------------------------------------
% Ideal BPF setup
%% --------------------------------------------------------
fc1 = (f1p + f1s)/2;    % lower transition midpoint
fc2 = (f2p + f2s)/2;    % upper transition midpoint
wc1 = 2*pi*fc1;
wc2 = 2*pi*fc2;
 
% Wide reference grid for ideal response
Lmax = 801;
n    = 0:Lmax-1;
Mmid = (Lmax-1)/2;
 
% Ideal lowpass helper
h_lp = @(wc,n) sin(wc*(n-Mmid)) ./ (pi*(n-Mmid));
h_lp_vec = @(wc) (h_lp(wc,n));
 
% Avoid n=Mmid divide-by-zero
h_lp1 = h_lp_vec(wc2);
h_lp1(Mmid+1) = wc2/pi;
 
h_lp2 = h_lp_vec(wc1);
h_lp2(Mmid+1) = wc1/pi;
 
% Ideal bandpass = LP(fc2) - LP(fc1)
h_ideal = h_lp1 - h_lp2;
 
%% ========================================================
% 1) Hann Window Method
%% ========================================================
Delta_f = min(f1p - f1s, f2s - f2p);   % = 0.05
Delta_w = 2*pi*Delta_f;                % = 0.1π
 
% Hann: K = 8 (from table)
M_hann = ceil((8*pi)/Delta_w) - 1;        % ≈ 79
L_hann = M_hann + 1;
 
w_hann = hann(L_hann).';
 
% center slice of ideal response
start_h = Mmid - floor((L_hann-1)/2);
stop_h  = start_h + L_hann - 1;
 
h_hann = h_ideal(start_h:stop_h) .* w_hann;
 
fprintf("Hann:   Order = %d, Length = %d, Type-II, τ=%.2f\n", ...
        M_hann, L_hann, M_hann/2);
 
%% ========================================================
% 2) Kaiser Window Method
%% ========================================================
A = As_dB;                % = 40 dB
M_kaiser = ceil((A-8)/(2.285*Delta_w));
% Make order even for Type-I
if mod(M_kaiser,2)==1
    M_kaiser = M_kaiser + 1;
end
 
L_kaiser = M_kaiser + 1;
 
% Kaiser beta from table
if A > 50
    beta = 0.1102*(A - 8.7);
elseif A >= 21
    beta = 0.5842*(A-21)^0.4 + 0.07886*(A-21);
else
    beta = 0;
end
 
w_kaiser = kaiser(L_kaiser, beta).';
 
start_k = Mmid - floor((L_kaiser-1)/2);
stop_k  = start_k + L_kaiser - 1;
 
h_kaiser = h_ideal(start_k:stop_k) .* w_kaiser;
 
fprintf("Kaiser: Order = %d, Length = %d, Beta=%.3f, Type-I, τ=%.2f\n", ...
        M_kaiser, L_kaiser, beta, M_kaiser/2);
 
%% ========================================================
% 3) Frequency Response Plots
%% ========================================================
Nfft = 4096;
[H_hann,  w] = freqz(h_hann, 1, Nfft);
[H_kaiser,~] = freqz(h_kaiser,1, Nfft);
 
f = w/(2*pi);
 
figure;
subplot(2,1,1);
plot(f, abs(H_hann),'LineWidth',1.2); hold on;
plot(f, abs(H_kaiser),'LineWidth',1.2);
xlabel('Normalized frequency f');
ylabel('|H(f)|');
title('Magnitude Response (Linear)');
legend('Hann','Kaiser'); grid on; xlim([0 0.5]);
 
subplot(2,1,2);
plot(f, 20*log10(abs(H_hann)+eps)); hold on;
plot(f, 20*log10(abs(H_kaiser)+eps));
yline(-As_dB,'--k','Stopband Spec');
yline(-Ap_dB,'--r','Passband Ripple');
xlabel('Normalized frequency f');
ylabel('Magnitude (dB)');
title('Magnitude Response (dB)');
legend('Hann','Kaiser'); grid on; xlim([0 0.5]); ylim([-100 5]);
 
%% ========================================================
% 4) Impulse responses
%% ========================================================
figure;
subplot(2,1,1);
stem(h_hann,'filled'); grid on;
title(sprintf('Hann BPF (L=%d)',L_hann));
 
subplot(2,1,2);
stem(h_kaiser,'filled'); grid on;
title(sprintf('Kaiser BPF (L=%d)',L_kaiser));
 
%% ========================================================
% 5) Summary
%% ========================================================
fprintf("\n================ Summary ================\n");
fprintf("Method       Length   Order   GroupDelay     Beta\n");
fprintf("Hann         %6d   %6d   %10.2f        --\n", L_hann,  M_hann,  M_hann/2);
fprintf("Kaiser       %6d   %6d   %10.2f       %.2f\n", L_kaiser, M_kaiser, M_kaiser/2, beta);
fprintf("=========================================\n");
Band-pass magnitude for the Hann and Kaiser designs, linear on top and dB below against the 40 dB stopband and 0.87 dB passband lines
Figure 7.5.f. Hann and Kaiser band-pass designs compared. Both responses remain inside the \(0.87\,\text{dB}\) passband limit and below the \(-40\,\text{dB}\) stopband limit. The lower transition is narrower than the upper one, so it determines the required order and produces the sharper edge. The windows differ mainly in the stopband shape. The Hann side lobes decrease with distance from the passband and fall below \(-80\,\text{dB}\) near DC. The Kaiser side lobes remain near \(-55\,\text{dB}\). That floor is higher, but it still satisfies the specification; the adjustable Kaiser parameter provides direct control over this trade-off.
Impulse responses of the Hann and Kaiser band-pass designs, lengths 81 and 47
Figure 7.5.g. Why the Kaiser design is shorter. The Hann design needs 81 taps, while the adjustable Kaiser window meets the same limits with 47 taps, a reduction of about 40%. Both coefficient sequences contain the oscillating ideal band-pass impulse response multiplied by a smooth taper. Both are symmetric, so both have exact linear phase. The plotted length also identifies the linear-phase type: an odd number of taps means even order and Type I; an even number of taps means odd order and Type II.

Figures 7.5.b and 7.5.c summarise the window method. (1) Convert \(A_p\) and \(A_s\) to the linear tolerances \(\delta_p\) and \(\delta_s\). (2) Use the stricter tolerance to choose a fixed window or the Kaiser parameter \(\beta\). (3) Place \(\omega_c\) at the centre of the transition and find the narrowest transition width \(\Delta\omega\). (4) Estimate the required length and adjust its parity for the FIR type. (5) calculate the window \(w[n]\). (6) multiply it by the shifted ideal sinc to obtain \(h[n]\), then verify the result. The length formulas are estimates, so add two taps and check again if a limit is missed slightly.

Example
Spec
\(A\)
Shape
\(\Delta\omega\)
\(M\)
7.7
LPF, 0.24/0.26
60 dB
Blackman
\(0.04\pi\)
299
7.8
same spec
60 dB
Kaiser \(\beta=5.65\)
\(0.04\pi\)
182
7.9
BPF, 0.125–0.40
40 dB
Hann / Kaiser \(\beta=3.40\)
\(0.1\pi\)
79 / 46

Three specifications, one procedure, and the only judgement anywhere in it is step 2 — which is precisely the judgement Section 7.4's catalog exists to remove.

?Problems with solutions

Work each one before reading the solution.

PROBLEM 7.1

A digital differentiator needs \(H(e^{j\omega})\approx j\omega\) over most of the band. Which of the four types (Section 7.1) is the natural choice, and why do the other three fail?

1
Match the symmetry

\(H_d(\omega)=j\omega\) is purely imaginary and odd in \(\omega\): the sine-sum, odd-symmetry structure of Types III/IV (Eqs. 7.6–7.7), never the real cosine sums of Types I/II. Types I and II are ruled out.

2
Compare the forced zeros

Type III forces \(H(e^{j0})=0\) and \(H(e^{j\pi})=0\). Type IV forces only \(H(e^{j0})=0\).

3
Decide

A differentiator already wants \(H(0)=0\), so that zero costs nothing. But it must stay large near \(\omega=\pi\). Type III's extra zero at \(\pi\) would suppress exactly the content a differentiator should amplify.

Result

Type IV.

PROBLEM 7.2

Design a band-pass filter: stopbands \(|f|\le0.125\) and \(|f|\ge0.40\), passband \(0.175\le|f|\le0.30\), with \(\delta_s=0.01\) (\(A_s\approx40\,\text{dB}\)). Which fixed window is the best choice, and what order does it need?

1
Find the governing transition band

\(\Delta f_1=0.175-0.125=0.05\) and \(\Delta f_2=0.40-0.30=0.10\). The narrower one governs: \(\Delta f=0.05\Rightarrow\Delta\omega=0.1\pi\).

2
Choose the window

From Table 7.4, 40 dB falls between Bartlett's 25 dB and Hann's 44 dB, so Hann is the tightest window that clears the spec.

3
Find the order

Eq. (7.15) with \(K=8\):

$$M\approx\frac{8\pi}{0.1\pi}-1=79$$
Result

Hann, \(M=79\) (\(L=80\), Type II), group delay \(\tau=39.5\).

A Type II design is fine for a band-pass; Section 7.1.2's restriction applies only to high-pass.

PROBLEM 7.3

Two students design the same low-pass to the same \(A_p,A_s,\Delta\omega\): one with a fixed Hamming window, one with Parks–McClellan (minimax). Both meet spec. Whose filter has the lower order, and why does that not make the fixed-window design pointless?

1
Which order is lower

Parks–McClellan has the lower (or at worst equal) order. The Alternation Theorem (Eq. 7.9) makes it the sharpest filter for its order, with every ripple at the same minimal height (Figure 7.2.b). A fixed window's ripple tapers away from the band edge, over-delivering as Example 7.8 showed against Kaiser.

2
Why windowing still matters

It needs no iterative solver: it is a closed-form recipe (Eq. 7.14, table lookup, Eq. 7.15) usable by hand or on a microcontroller with no optimisation library, at the cost of a few extra taps.

Result

Parks–McClellan gives the lower order; windowing buys simplicity and predictability.

This is the same efficiency-versus-effort trade Lecture 5 drew between Butterworth and Chebyshev.

Summary and key formulas

The reference sheet: the four linear-phase types and their forbidden shapes, then the two design methods' key equations.

Type I

No restriction

Type II

No HPF

Type III

No LPF/HPF

Type IV

No LPF

Type I amplitude · Eq. (7.4)
$$H=e^{-j\omega M/2}\textstyle\sum a[k]\cos(\omega k)$$
Minimax criterion · Eq. (7.8)
$$\min_{a[k]}\max_{\omega\in F} W(\omega)\,|H_d(\omega)-A(\omega)|$$

\(H_d(\omega)\): real-valued desired response (1 in the passband, 0 in the stopband). \(A(\omega)=\sum_{k=0}^{M/2}a[k]\cos(\omega k)\): the filter's real amplitude response, with \(H(e^{j\omega})=e^{-j\omega M/2}A(\omega)\).

Alternation theorem · Eq. (7.9)
$$\varepsilon(\omega_k)=-\varepsilon(\omega_{k+1})=\pm\delta$$
Minimax order · Eq. (7.12)
$$M\approx\dfrac{-10\log_{10}(\delta_p\delta_s)-13}{2.324\,\Delta\omega}$$
Windowing · Eq. (7.14)
$$h[n]=h_d[n]w[n]$$
Fixed-window order · Eq. (7.15)
$$M\approx K\pi/\Delta\omega-1$$
  • Exact linear phase requires symmetric or antisymmetric \(h[n]\); four combinations of \(M\)-parity and symmetry give Types I–IV, each with its own forced zeros on the unit circle.
  • Type I is unrestricted and is the type used in essentially every general-purpose design (both examples in this lecture).
  • Minimax (Parks–McClellan) spreads the error into an equiripple pattern — provably the sharpest transition a given order can deliver — via the iterative Remez exchange.
  • The window method truncates the ideal impulse response; every window trades mainlobe width (transition sharpness) against sidelobe level (stopband depth), with no free improvement of both.
  • Kaiser's tunable window reaches a given attenuation target with fewer taps than the nearest fixed window, because its taper is tuned exactly to the spec instead of over-delivering.
  • The design recipe (Figures 7.5.a–7.5.b) is fixed and feedback-free: \(A=-20\log_{10}\min(\delta_p,\delta_s)\) picks the shape, \(\Delta\omega\) of the narrowest transition picks the length, parity is rounded to suit the filter kind, and the sinc at \(\omega_c=\pi(f_p+f_s)\) is multiplied by the taper.
  • Next: Lecture 8 builds IIR filters systematically, transforming Lecture 5's analog prototypes into digital filters via impulse invariance and the bilinear transform.