ELEC6218 · Signal ProcessingAnalog & Digital Filter Design
Signal Processing · Lecture notesProf. Ç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.
InstructorProf. Abdulkadir Çelik (https://akadircelik.com)ModuleELEC6218TopicsLinear-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:
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\):
\(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\):
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:
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:
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.
Type I
M even · even symmetry
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:
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\):
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:
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.
Type IV
M odd · odd symmetry
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 = [120 -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
figure('Color','w'); zplane(h,1); title('Type III: zeros forced at z=\pm1');
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\):
\(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.
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
the error alternates between two equal maxima and minima, \(\varepsilon(\omega_k)=-\varepsilon(\omega_{k+1})\) for \(k=1,\ldots,L+1\), and
the error magnitude equals the maximum absolute error over \(F\), denoted \(\delta\).
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.
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:
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.
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.
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:
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:
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:
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.
\(-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
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.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\).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:
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:
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\).
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:
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:
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,
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
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\)
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.
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\)
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.
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\)
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.
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\)
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.
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)
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:
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:
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.
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\):
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:
$$ \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.
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.
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.
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\).
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.
Window
Side lobe (dB)
Mainlobe
\(A_p\) (dB)
\(A_s\) (dB)
Rectangular
−13
\(4\pi/L\)
0.75
21
Bartlett
−25
\(8\pi/L\)
0.45
26
Hann
−31
\(8\pi/L\)
0.055
44
Hamming
−41
\(8\pi/L\)
0.019
53
Blackman ← selected
−57
\(12\pi/L\)
0.0017
74
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),
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.
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:
\(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.
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:
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:
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
Hann (44 dB) is no longer enough; Hamming is the first window to clear 49.5 dB.
Window
Side lobe (dB)
Mainlobe
\(A_p\) (dB)
\(A_s\) (dB)
Rectangular
−13
\(4\pi/L\)
0.75
21
Bartlett
−25
\(8\pi/L\)
0.45
26
Hann
−31
\(8\pi/L\)
0.055
44
Hamming ← selected
−41
\(8\pi/L\)
0.019
53
Blackman
−57
\(12\pi/L\)
0.0017
74
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.
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:
\(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.
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.
Window
Side lobe (dB)
Mainlobe
\(A_p\) (dB)
\(A_s\) (dB)
Rectangular
−13
\(4\pi/L\)
0.75
21
Bartlett
−25
\(8\pi/L\)
0.45
26
Hann ← selected
−31
\(8\pi/L\)
0.055
44
Hamming
−41
\(8\pi/L\)
0.019
53
Blackman
−57
\(12\pi/L\)
0.0017
74
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:
\(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\).
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:
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:
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.
Window
Side lobe (dB)
Mainlobe
\(A_p\) (dB)
\(A_s\) (dB)
Rectangular
−13
\(4\pi/L\)
0.75
21
Bartlett
−25
\(8\pi/L\)
0.45
26
Hann
−31
\(8\pi/L\)
0.055
44
Hamming ← selected
−41
\(8\pi/L\)
0.019
53
Blackman
−57
\(12\pi/L\)
0.0017
74
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.
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:
\(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.
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)
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.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.
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.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.
\(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)\).
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.