Filter design starts not from a transfer function but from a specification(規格): how much the passband may ripple, how much the stopband must be attenuated, and how wide the transition band may be. The designer's job is to find a realizable, stable, causal rational system function $H(z)$ whose frequency response stays inside the allowed tolerance region with the lowest possible cost (filter order).
An ideal lowpass response — unity gain up to a cutoff, zero beyond — is unrealizable: it is noncausal and has infinite-length impulse response with no rational $H(z)$. Practical specifications therefore relax the ideal into a tolerance scheme (容忍度規格圖) with three regions:
Specifications are usually quoted logarithmically. The passband ripple $R_p$ and the minimum stopband attenuation $A_s$ (both positive dB numbers) relate to the linear tolerances as:
Typical values: $R_p = 1$ dB means $1-\delta_p = 10^{-1/20} = 0.8913$; $A_s = 40$ dB means $\delta_s = 10^{-40/20} = 0.01$. A useful intermediate quantity is the discrimination ratio built from $\varepsilon_p^2 = 10^{R_p/10}-1$ (passband) and $10^{A_s/10}-1$ (stopband); it appears in every order formula in this chapter.
buttord/cheby1 use $R_p$ measured from a peak of 0 dB —
state your convention before computing $N$, or your order can be off by one.
Before designing, choose the filter class. The lecture's comparison:
| Property | FIR(有限脈衝響應) | IIR(無限脈衝響應) |
|---|---|---|
| Phase | Exactly linear phase possible (symmetric $h[n]$) | Nonlinear phase; only approximately linear in passband |
| Stability | Always stable (no feedback poles) | Must keep all poles inside $|z|=1$ |
| Order for a sharp spec | High (often 10× the IIR order) | Low — sharp cutoffs with few coefficients |
| Computational cost | Higher per sample (long taps), but FFT block convolution helps | Low per sample (recursive) |
| Coefficient sensitivity | Robust to quantization | Sensitive; poles near $|z|=1$ may go unstable |
| Design route | Direct digital (windows, Parks–McClellan) | Usually via an analog prototype |
All classical analog lowpass prototypes share the squared-magnitude template $|H_c(j\Omega)|^2 = \dfrac{1}{1+V_N^2(\Omega)}$ where $V_N$ is a polynomial or rational function of order $N$ that is small in the passband and large in the stopband. The four families differ in where they spend their approximation error:
| Family | Passband | Stopband | Roll-off / order needed | Phase linearity |
|---|---|---|---|---|
| Butterworth(巴特沃斯) | Maximally flat, monotonic | Monotonic | Slowest → highest $N$ | Best of the four |
| Chebyshev I(柴比雪夫一型) | Equiripple | Monotonic | Faster → moderate $N$ | Worse |
| Chebyshev II(柴比雪夫二型) | Monotonic (flat) | Equiripple | Same $N$ as Type I | Moderate |
| Elliptic / Cauer(橢圓) | Equiripple | Equiripple | Fastest → minimum $N$ | Worst (very nonlinear) |
The Butterworth lowpass of order $N$ with 3-dB cutoff $\Omega_c$ is defined by its squared magnitude:
Its defining property is maximal flatness(最大平坦): the first $2N-1$ derivatives of $|H_c(j\Omega)|^2$ are zero at $\Omega = 0$. Consequences visible in Fig. 13-2:
Substituting $\Omega = s/j$ gives $H_c(s)H_c(-s) = \dfrac{1}{1+(s/j\Omega_c)^{2N}}$, whose $2N$ poles are equally spaced on a circle of radius $\Omega_c$:
The poles come in pairs $\pm s_k$, none on the $j\Omega$ axis, separated by angle $\pi/N$. To build the stable, causal $H_c(s)$ we assign the $N$ left-half-plane poles to $H_c(s)$ and the mirror images to $H_c(-s)$.
A first-order Butterworth filter is just the RC circuit on slide 14: with $R = 100\,\text{k}\Omega$ and $C = 0.001\,\mu\text{F}$,
Requiring $|H_c(j\Omega_p)|^2 \ge (1-\delta_p)^2 = 10^{-R_p/10}$ and $|H_c(j\Omega_s)|^2 \le \delta_s^2 = 10^{-A_s/10}$ and solving the two equations of $(\Omega/\Omega_c)^{2N}$ gives:
With the integer $N$, $\Omega_c$ can be placed anywhere between the value that meets the passband exactly, $\Omega_c = \Omega_p\,(10^{R_p/10}-1)^{-1/2N}$, and the value that meets the stopband exactly, $\Omega_c = \Omega_s\,(10^{A_s/10}-1)^{-1/2N}$. The slack exists because $N$ was rounded up.
Spec: passband edge $\Omega_p = 1$ rad/s with $R_p = 1$ dB; stopband edge $\Omega_s = 2$ rad/s with $A_s = 40$ dB. Find $N$ and $\Omega_c$.
The Chebyshev Type I filter trades passband flatness for a sharper knee: it is equiripple in the passband(通帶等漣波) and monotonic in the stopband.
$T_N$ is the order-$N$ Chebyshev polynomial: it oscillates between $\pm1$ for $|x|\le 1$ (hence equal ripple between $1$ and $1/\sqrt{1+\varepsilon^2}$ in the passband) and grows like $\cosh$ — much faster than $x^N$ — outside, giving rapid attenuation. Properties:
Chebyshev Type II (inverse Chebyshev) flips the trade: monotonic, maximally-flat-like passband and equiripple stopband(阻帶等漣波), achieved by placing transmission zeros on the $j\Omega$ axis in the stopband:
It needs the same order as Type I for a given spec, but has no passband ripple — useful when the passband carries a signal whose amplitude must not be distorted. Cost: a rational (not polynomial) transfer function with finite zeros, and the response no longer decays monotonically to zero at high frequency (it returns to the ripple ceiling $\delta_s$).
Elliptic filters are equiripple in both bands, replacing $T_N$ with the Jacobi elliptic rational function $R_N$:
By the Chebyshev approximation theorem, distributing the error equally over both bands is optimal: for given $(\delta_p,\delta_s,\Omega_p,\Omega_s)$ the elliptic filter achieves the spec with the minimum possible order(最小階數) of any rational filter. The price is the most nonlinear phase and strong group-delay peaking near the band edge.
All formulas above are for a lowpass prototype. Other shapes come from algebraic substitutions on $s$ (here the prototype has cutoff 1 rad/s):
| Target | Substitution $s \to$ | Effect |
|---|---|---|
| Lowpass, cutoff $\Omega_c$ | $s/\Omega_c$ | Scales the cutoff |
| Highpass, cutoff $\Omega_c$ | $\Omega_c/s$ | Swaps $\Omega=0$ and $\Omega=\infty$ |
| Bandpass, edges $\Omega_1,\Omega_2$ | $\dfrac{s^2+\Omega_1\Omega_2}{s(\Omega_2-\Omega_1)}$ | Order doubles ($N \to 2N$) |
| Bandstop, edges $\Omega_1,\Omega_2$ | $\dfrac{s(\Omega_2-\Omega_1)}{s^2+\Omega_1\Omega_2}$ | Order doubles |
In digital IIR design the same idea can be applied either in the analog domain (before
the $s\to z$ map) or directly in the $z$-domain with all-pass substitutions; MATLAB's
butter(N, Wn, 'high') etc. handle this automatically (§13.4).
We have a good $H_c(s)$; we need $H(z)$. Any useful transformation from the $s$-plane to the $z$-plane must satisfy two requirements:
Two classical mappings satisfy both: impulse invariance and the bilinear transformation.
The impulse invariance method(脈衝響應不變法) defines the digital filter by sampling the analog impulse response:
This is exactly the sampling theorem applied to $h_c(t)$ (the factor $T$ normalizes the gain so that $H(e^{j0}) \approx H_c(j0)$). Two consequences:
In practice nobody samples $h_c(t)$ literally; the pole mapping is done algebraically. Expand the (simple-pole) prototype and map each term:
Each analog pole $s_k$ becomes a digital pole at $z_k = e^{s_k T}$. Since $\operatorname{Re}\{s_k\}<0 \Rightarrow |z_k| = e^{\operatorname{Re}\{s_k\}T} < 1$, stability is preserved. Note that zeros do not map this way — only poles.
The bilinear transformation(雙線性轉換) avoids aliasing entirely by using an algebraic, one-to-one map between the $s$-plane and the $z$-plane:
(It derives from the trapezoidal-rule discretization of the integrator $1/s$.) Mapping properties — check them by substituting $s = \sigma + j\Omega$:
Setting $z = e^{j\omega}$ in the bilinear map gives $s = \frac{2}{T}\,\frac{1-e^{-j\omega}}{1+e^{-j\omega}} = j\frac{2}{T}\tan(\omega/2)$, i.e. the frequency axes are related nonlinearly:
For small $\omega$, $\Omega \approx \omega/T$ (the map is locally linear), but band edges at higher frequencies are warped. The fix is prewarping(預翹曲): translate every critical digital frequency into the analog domain using the exact warping formula before designing the prototype:
Then after the bilinear map the digital filter hits $\omega_p,\omega_s$ exactly. Note $T$ cancels out of the final $H(z)$ — the spec is prewarped by $T$ and warped back by $1/T$ — so one conventionally sets $T=1$ (or $T=2$) for convenience.
For the impulse-invariance route, replace steps 2 and 5 by the linear translation $\Omega_{p,s} = \omega_{p,s}/T$ and the pole-by-pole map of Eq. (13.3.2) — and over-design the stopband slightly to absorb aliasing.
Digital spec: $\omega_p = 0.2\pi$ with $R_p = 1$ dB ($|H|\ge 0.8913$), $\omega_s = 0.3\pi$ with $A_s = 15$ dB ($|H|\le 0.1778$). Take $T=1$.
MATLAB (Signal Processing Toolbox) wraps this whole chapter in two calls per family: an order-selection function and a design function. Digital frequencies are normalized so that $1.0$ means the Nyquist frequency $\pi$ rad/sample:
| Family | Order selection | Design call | Notes |
|---|---|---|---|
| Butterworth | [N,Wn] = buttord(wp,ws,Rp,As) | [b,a] = butter(N,Wn) | maximally flat |
| Chebyshev I | [N,Wp] = cheb1ord(wp,ws,Rp,As) | [b,a] = cheby1(N,Rp,Wp) | passband ripple $R_p$ |
| Chebyshev II | [N,Ws] = cheb2ord(wp,ws,Rp,As) | [b,a] = cheby2(N,As,Ws) | stopband ripple $A_s$ |
| Elliptic | [N,Wp] = ellipord(wp,ws,Rp,As) | [b,a] = ellip(N,Rp,As,Wp) | minimum order |
| Manual s→z | — | [bz,az] = bilinear(b,a,fs), impinvar(b,a,fs) | map your own $H_c(s)$ |
Other shapes ("Other Filter Shapes", slide 31): pass 'high',
'stop', or a two-element Wn = [w1 w2] for bandpass — MATLAB applies the
frequency transformations of §13.2.7 to the lowpass prototype internally, then the bilinear
transform with built-in prewarping:
% lowpass meeting wp=0.4pi, ws=0.6pi, Rp=1 dB, As=40 dB [N, Wn] = buttord(0.4, 0.6, 1, 40); % -> N = 9, Wn = 0.4230 [b, a] = butter(N, Wn); % digital LPF via bilinear (prewarped) [b, a] = butter(6, 0.7, 'high'); % highpass, cutoff 0.7*pi [b, a] = ellip(4, 0.5, 50, [0.25 0.45]);% bandpass (order doubles to 8) [b, a] = cheby2(5, 40, [0.3 0.5], 'stop'); % bandstop freqz(b, a, 2048) % always verify against the mask
buttord/butter digital design
($N=9$, $\omega_c = 0.423\pi$) verified against the spec mask $\omega_p=0.4\pi$, $\omega_s=0.6\pi$,
$R_p=1$ dB, $A_s=40$ dB. The curve threads the unshaded corridor.(設計結果疊上規格遮罩驗證。)butter/cheby1/ellip already do
prewarping + bilinear internally — never prewarp the arguments yourself.[b,a] is numerically
fragile; use [z,p,k] = butter(...) with zp2sos and filter with
second-order sections(二階節).impinvar exists but refuses improper $H_c(s)$; remember it is only
sensible for lowpass/bandpass prototypes.Problem: A digital lowpass filter must satisfy $0.9441 \le |H(e^{j\omega})| \le 1$ for $0 \le \omega \le 0.35\pi$ and $|H(e^{j\omega})| \le 0.0032$ for $0.5\pi \le \omega \le \pi$. (a) Identify $\omega_p,\omega_s,\delta_p,\delta_s$ and convert the ripples to $R_p$ and $A_s$ in dB. (b) If this filter is to be designed by the bilinear transformation with $T = 1$, compute the prewarped analog band edges. (c) Which analog families could meet this spec with monotonic passband response?
(a) $\omega_p = 0.35\pi$, $\omega_s = 0.5\pi$, $\delta_p = 1-0.9441 = 0.0559$, $\delta_s = 0.0032$.
$$R_p = -20\log_{10}(0.9441) = 0.5\ \text{dB},\qquad A_s = -20\log_{10}(0.0032) \approx 50\ \text{dB}.$$(b) Prewarping with $\Omega = 2\tan(\omega/2)$:
$$\Omega_p = 2\tan(0.175\pi) = 2\tan(31.5^\circ) = 1.226\ \text{rad/s},\qquad \Omega_s = 2\tan(0.25\pi) = 2\ \text{rad/s}.$$Note the warped edge ratio $\Omega_s/\Omega_p = 1.632$ is larger than $\omega_s/\omega_p = 1.429$ — the warping has slightly relaxed the transition ratio, which lowers the required order. This is typical for edges below $\pi/2$.
(c) Monotonic passband → Butterworth or Chebyshev Type II. (Chebyshev I and elliptic are equiripple in the passband.) Chebyshev II would need a far lower order; Butterworth additionally gives a monotonic stopband and the best phase.
Problem: Design the analog Butterworth prototype (find $N$, the range of valid $\Omega_c$, and for $N = 3$, $\Omega_c = 1$ list the poles and $H_c(s)$) for the spec: at most 1 dB attenuation at $\Omega_p = 1$ rad/s and at least 40 dB at $\Omega_s = 2$ rad/s.
Order. With $10^{R_p/10}-1 = 10^{0.1}-1 = 0.2589$ and $10^{A_s/10}-1 = 9999$:
$$N \ge \frac{\log_{10}(9999/0.2589)}{2\log_{10}(2/1)} = \frac{4.587}{0.602} = 7.62 \;\Rightarrow\; \boxed{N = 8}.$$Cutoff range. Passband met exactly: $\Omega_c = 1\cdot(0.2589)^{-1/16} = 1.088$. Stopband met exactly: $\Omega_c = 2\cdot(9999)^{-1/16} = 1.126$. Any $\Omega_c \in [1.088,\,1.126]$ satisfies both; choosing the lower end gives maximum stopband margin, the upper end maximum passband margin.
Pole geometry for $N=3$, $\Omega_c=1$ (illustration). The 6 poles of $H_c(s)H_c(-s)$ sit at angles $\pi(2k+4)/6$, i.e. every $60^\circ$ on the unit circle, none on the $j\Omega$ axis. The three LHP poles are
$$s = -1,\qquad s = -\tfrac12 \pm j\tfrac{\sqrt3}{2},$$so
$$H_c(s) = \frac{1}{(s+1)\left(s^2+s+1\right)} = \frac{1}{s^3+2s^2+2s+1}.$$Check: $|H_c(j1)|^2 = 1/(1+1^{6}) = 1/2$ — exactly $-3$ dB at $\Omega_c$, as required.
Problem: For the spec of Exercise 2 ($\Omega_p=1$, $\Omega_s=2$, $R_p = 1$ dB, $A_s = 40$ dB), compute the required order of a Chebyshev Type I filter and compare it with the Butterworth result. What is the passband ripple parameter $\varepsilon$, and what is $|H_c(j0)|$ if the resulting $N$ is odd?
Ripple parameter. $\varepsilon = \sqrt{10^{R_p/10}-1} = \sqrt{0.2589} = 0.5088$.
Order.
$$N \;\ge\; \frac{\cosh^{-1}\sqrt{\dfrac{10^{4}-1}{10^{0.1}-1}}}{\cosh^{-1}(2)} = \frac{\cosh^{-1}(196.5)}{\cosh^{-1}(2)} = \frac{5.974}{1.317} = 4.54 \;\Rightarrow\; \boxed{N = 5}.$$Versus $N = 8$ for Butterworth: the equiripple passband buys a 37% order reduction on the same spec. (An elliptic design would need $N = 4$.)
DC gain. $T_N(0) = 0$ for odd $N$, so $|H_c(j0)| = 1/\sqrt{1+\varepsilon^2 T_5^2(0)} = 1$. The passband magnitude oscillates $N$ times between $1$ and $1/\sqrt{1+\varepsilon^2} = 0.8913$, ending at the band edge $\Omega_p$ at the ripple minimum.
Problem: Apply impulse invariance with sampling interval $T$ to
$$H_c(s) = \frac{2}{(s+1)(s+2)}.$$(a) Find $h_c(t)$, $h[n]$, and $H(z)$. (b) Where are the digital poles, and why is $H(z)$ guaranteed stable for every $T > 0$? (c) Explain why the digital zero locations are not $e^{s_0T}$ images of the analog zeros.
(a) Partial fractions:
$$H_c(s) = \frac{2}{s+1} - \frac{2}{s+2} \;\Rightarrow\; h_c(t) = \left(2e^{-t} - 2e^{-2t}\right)u(t).$$Sampling, $h[n] = T\,h_c(nT) = 2T\left(e^{-nT} - e^{-2nT}\right)u[n]$, and term-by-term z-transform:
$$H(z) = \frac{2T}{1-e^{-T}z^{-1}} - \frac{2T}{1-e^{-2T}z^{-1}} = \frac{2T\left(e^{-T}-e^{-2T}\right)z^{-1}} {\left(1-e^{-T}z^{-1}\right)\left(1-e^{-2T}z^{-1}\right)}.$$(b) Poles at $z = e^{-T}$ and $z = e^{-2T}$. For any $T>0$ these are positive reals strictly inside the unit circle, since the analog poles $s=-1,-2$ have negative real parts and $|e^{s_kT}| = e^{\operatorname{Re}(s_k)T} < 1$. The mapping $s_k \to e^{s_kT}$ always carries the LHP into the unit disc.
(c) Impulse invariance maps only the poles exponentially; the numerator of $H(z)$ comes out of recombining the mapped partial-fraction terms. Here $H_c(s)$ has both zeros at $s=\infty$, yet $H(z)$ has a finite zero at $z=0$ (and one at infinity). Zeros are not invariant because sampling $h_c(t)$ is a time-domain operation — only the modal (pole) structure $e^{s_kt}$ survives sampling as $e^{s_kT n}$.
Problem: Using the bilinear transformation with $T=1$, design a first-order digital lowpass filter whose $-3$ dB frequency is exactly $\omega_c = 0.25\pi$, starting from the analog prototype $H_c(s) = \Omega_c/(s+\Omega_c)$. Give the difference equation and verify the gain at $\omega_c$. What $-3$ dB frequency would you have gotten without prewarping (i.e. naively setting $\Omega_c = 0.25\pi$)?
Prewarp. $\Omega_c = 2\tan(\omega_c/2) = 2\tan(0.125\pi) = 0.8284$ rad/s.
Transform. Substitute $s = 2\frac{1-z^{-1}}{1+z^{-1}}$:
$$H(z) = \frac{\Omega_c}{2\frac{1-z^{-1}}{1+z^{-1}}+\Omega_c} = \frac{\Omega_c\left(1+z^{-1}\right)}{(2+\Omega_c) - (2-\Omega_c)z^{-1}} = \frac{0.2929\,(1+z^{-1})}{1 - 0.4142\,z^{-1}}.$$Difference equation:
$$y[n] = 0.4142\,y[n-1] + 0.2929\,x[n] + 0.2929\,x[n-1].$$Note the zero at $z=-1$: the analog zero at $\Omega=\infty$ landed at $\omega=\pi$, so the digital filter has a true null at Nyquist.
Verification. At $\omega = 0.25\pi$: $|H(e^{j0.25\pi})| = 0.7071 = 1/\sqrt2$ exactly ($-3.01$ dB) — the prewarped edge maps back to precisely $0.25\pi$.
Without prewarping, $\Omega_c = 0.25\pi = 0.7854$ and the realized $-3$ dB point lands at
$$\omega = 2\arctan(\Omega_c/2) = 2\arctan(0.3927) = 0.7468\ \text{rad} = 0.2377\pi,$$about 5% low — the warping error, which would grow rapidly for edges nearer $\pi$.
Problem: A digital lowpass filter must meet $\omega_p = 0.3\pi$, $\omega_s = 0.4\pi$, $R_p = 0.5$ dB, $A_s = 50$ dB. (a) Write MATLAB code that finds the minimum order for Butterworth, Chebyshev I and elliptic designs and realizes the elliptic one. (b) State the three orders and explain the ranking. (c) Sketch/verify the elliptic response against the spec mask.
(a) MATLAB (frequencies normalized to Nyquist = 1):
wp = 0.3; ws = 0.4; % band edges / pi
Rp = 0.5; As = 50; % dB
[Nb, ~ ] = buttord (wp, ws, Rp, As); % Nb = 20
[Nc, ~ ] = cheb1ord(wp, ws, Rp, As); % Nc = 9
[Ne, Wn] = ellipord(wp, ws, Rp, As); % Ne = 6
[b, a] = ellip(Ne, Rp, As, Wn); % minimum-order realization
[H, w] = freqz(b, a, 2048);
plot(w/pi, 20*log10(abs(H))); grid on
xlabel('\omega/\pi'); ylabel('|H| (dB)'); axis([0 1 -100 5])
hold on % spec mask
plot([0 wp],[-Rp -Rp],'r--', [ws 1],[-As -As],'r--')
(b) Orders: Butterworth $N=20$, Chebyshev I $N=9$, elliptic $N=6$ (Chebyshev II also gives 9). The transition band is narrow ($0.1\pi$) with a deep stopband, so the monotonic Butterworth pays heavily; allowing ripple in one band (Chebyshev) roughly halves the order; allowing it in both bands (elliptic) is optimal — at the cost of the most nonlinear phase.
(c) Regenerated result (scipy ellipord/ellip,
identical algorithm):