Outline
11.1 Filters & Decibels
11.2 Simple FIR Filters
11.3 Simple IIR Filters
11.4 Cascading Filters
11.5 Ideal Filters & Specs
11.6 Linear-Phase FIR
11.7 Summary
Exercises
DSP Study Guide · Chapter 11

Filters: Introduction

Simple FIR and IIR filters, the decibel scale, ideal filters and why they are unrealizable, practical tolerance specifications, and the four linear-phase FIR types.

11.1 Filters and the Decibel Scale

11.1.1 What Is a Filter? FIR vs IIR

A digital filter(數位濾波器)is an LTI system designed to pass certain frequency components of a signal and attenuate(衰減)others. Because an LTI system simply multiplies each frequency component by its frequency response, the whole story of filtering is contained in

Filtering in time and frequency $$y[n] = h[n] * x[n] \qquad\Longleftrightarrow\qquad Y(e^{j\omega}) = H(e^{j\omega})\,X(e^{j\omega})$$

Frequencies where $|H(e^{j\omega})| \approx 1$ form the passband(通帶); frequencies where $|H(e^{j\omega})| \approx 0$ form the stopband(阻帶). This chapter introduces the simplest members of the two great families of realizable filters:

FIR (Finite Impulse Response, 有限脈衝響應)IIR (Infinite Impulse Response, 無限脈衝響應)
Difference equation$y[n]=\sum_{k=0}^{M} b_k\,x[n-k]$ (no feedback)$y[n]=\sum_{k=0}^{M} b_k x[n-k]-\sum_{k=1}^{N} a_k y[n-k]$ (feedback)
Impulse responsefinite lengthinfinite length
Polesonly at $z=0$ — always stableanywhere; stable iff poles inside unit circle
Exact linear phasepossible (Section 11.6)not possible (only approximately)
Order needed for sharp cutoffhighlow
Concept — Why study "toy" filters first?
The lecture builds intuition with first- and second-order filters whose behavior you can compute by hand: where the zeros sit on the unit circle tells you which frequencies are killed; where the poles sit tells you which frequencies are boosted. Every sophisticated design method (windowing, Parks–McClellan, bilinear transform — later chapters) refines this same picture.

11.1.2 Decibels(分貝)

Filter gains span many orders of magnitude, so magnitude responses are usually plotted on a logarithmic decibel scale:

Gain in dB $$G(\omega)\;=\;20\log_{10}\bigl|H(e^{j\omega})\bigr|\ \text{dB}, \qquad \text{attenuation(衰減量)} \;=\; -\,G(\omega)\ \text{dB}$$
$|H|$$|H|^2$ (power)gain in dBread as
$1$$1$$0$ dBunity gain
$1/\sqrt{2}\approx 0.707$$1/2$$-3$ dBhalf-power point(半功率點)
$1/2$$1/4$$-6$ dBhalving the amplitude
$0.1$$0.01$$-20$ dBone decade down
$0.01$$10^{-4}$$-40$ dBtwo decades down
Key — The 3-dB cutoff frequency
The 3-dB cutoff frequency(3-dB 截止頻率) $\omega_c$ is where $|H(e^{j\omega_c})|^2 = \tfrac12 |H|^2_{\max}$, i.e. $|H(e^{j\omega_c})| = 1/\sqrt{2}$ for a unity-gain filter. It is the conventional boundary between "passed" and "attenuated". Also remember: cascading filters multiplies magnitudes, hence dB gains simply add.
直觀解釋(點擊展開)
為什麼用分貝?因為濾波器的增益範圍可能從 1 到 0.00001,用線性座標畫圖時阻帶細節全部擠在 0 附近看不見。取對數之後,「每衰減 10 倍」變成固定的 −20 dB 間距,阻帶的漣波結構一目了然。另外串接濾波器時增益相乘,在 dB 尺度上變成相加,計算非常方便。−3 dB 對應功率剩一半,所以叫「半功率點」,習慣上把它當作通帶的邊界。

11.2 Simple FIR Filters

11.2.1 The Two-Point Average: a Simple FIR Lowpass

The simplest lowpass filter(低通濾波器)averages the current and previous samples:

Simple FIR lowpass $$y[n]=\tfrac12\bigl(x[n]+x[n-1]\bigr) \qquad H_0(z)=\tfrac12\bigl(1+z^{-1}\bigr)$$

Its frequency response factors into a real amplitude and a linear phase:

Frequency response $$H_0(e^{j\omega}) = \tfrac12\bigl(1+e^{-j\omega}\bigr) = e^{-j\omega/2}\cos\!\bigl(\tfrac{\omega}{2}\bigr) \qquad\Rightarrow\qquad \bigl|H_0(e^{j\omega})\bigr| = \cos\!\bigl(\tfrac{\omega}{2}\bigr)$$
Worked Example 11-A — Properties of the two-point average
Zero location: $H_0(z)=0$ at $z=-1$, i.e. at $\omega=\pi$. The highest frequency $(-1)^n$ is annihilated: averaging two adjacent samples of $(-1)^n$ gives exactly zero.
DC gain: $H_0(e^{j0})=1$. A constant passes unchanged.
3-dB cutoff: solve $\cos(\omega_c/2)=1/\sqrt2 \Rightarrow \omega_c/2=\pi/4 \Rightarrow \boxed{\omega_c=\pi/2}$.
Phase: $\angle H_0 = -\omega/2$, perfectly linear — a delay of half a sample.

11.2.2 The M-Point Moving-Average Lowpass

Generalizing to an average of $M$ samples gives the moving-average filter(移動平均濾波器), the workhorse of noise smoothing:

Moving-average filter $$y[n]=\frac1M\sum_{k=0}^{M-1}x[n-k] \qquad H(e^{j\omega})=\frac1M\,\frac{\sin(M\omega/2)}{\sin(\omega/2)}\;e^{-j\omega(M-1)/2}$$

The magnitude is a periodic-sinc (Dirichlet) shape with nulls at $\omega = 2\pi k/M$, $k=1,\dots,M-1$: any sinusoid completing a whole number of cycles inside the averaging window averages to zero. Increasing $M$ narrows the passband and increases the smoothing, at the cost of a longer delay $(M-1)/2$ samples.

2026-06-12T22:38:05.450493 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0 π/4 π/2 3π/4 π ω 0.0 0.2 0.4 0.6 0.8 1.0 |H(e^jω)| M-point moving-average filter: longer M means narrower passband M = 2 M = 5 M = 10
Fig. 11-5 — Magnitude response of the $M$-point moving average for $M=2,5,10$. Longer windows give a narrower passband and deeper smoothing, with nulls at multiples of $2\pi/M$(窗長越長,通帶越窄、平滑越強,且在 2π/M 的整數倍處有零點).
Tip — Moving average in MATLAB
b = ones(1,M)/M; y = filter(b,1,x); implements the causal moving average. Use freqz(b,1) to inspect its magnitude/phase. It is a fine smoother but a poor lowpass filter: its first sidelobe is only about 13 dB down, so stopband rejection is weak.

11.2.3 The First Difference: a Simple FIR Highpass

Flipping the sign of the second tap turns the averager into a differencer — the simplest highpass filter(高通濾波器):

Simple FIR highpass $$y[n]=\tfrac12\bigl(x[n]-x[n-1]\bigr) \qquad H_1(z)=\tfrac12\bigl(1-z^{-1}\bigr) \qquad \bigl|H_1(e^{j\omega})\bigr|=\sin\!\bigl(\tfrac{\omega}{2}\bigr)$$

Now the zero sits at $z=+1$ ($\omega=0$): DC is annihilated, while the fastest alternation $(-1)^n$ passes with gain 1. Its 3-dB cutoff is again $\omega_c = \pi/2$. In fact $h_1[n]=(-1)^n h_0[n]$ — replacing $z$ by $-z$ shifts a frequency response by $\pi$, converting lowpass to highpass(把 $z\to-z$,頻率響應平移 π,低通變高通).

2026-06-12T22:38:05.117785 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0 π/4 π/2 3π/4 π ω 0.0 0.2 0.4 0.6 0.8 1.0 magnitude 1/√2 (−3 dB) Two-point average (lowpass) and first difference (highpass) |H0(e^jω)| = cos(ω/2) (lowpass) |H1(e^jω)| = sin(ω/2) (highpass)
Fig. 11-4 — The two simplest FIR filters: $|H_0|=\cos(\omega/2)$ (lowpass, zero at $\omega=\pi$) and $|H_1|=\sin(\omega/2)$ (highpass, zero at DC). Both cross the −3 dB level $1/\sqrt2$ at $\omega=\pi/2$(兩者皆在 π/2 處達 −3 dB).
Key — Power complementary pair
$\cos^2(\omega/2)+\sin^2(\omega/2)=1$, so $|H_0|^2+|H_1|^2=1$ at every frequency: whatever power the lowpass removes, the highpass keeps. Such a pair is called power-complementary(功率互補).

11.3 Simple IIR Filters

Adding one feedback coefficient buys far more selectivity per multiply. All four classical responses — LP, HP, BP, BS — have standard first/second-order IIR prototypes, parameterized so that the gain is exactly 1 at the center of the passband and exactly 0 at the center of the stopband.

11.3.1 First-Order IIR Lowpass

First-order IIR lowpass $$H_{LP}(z)=\frac{1-\alpha}{2}\cdot\frac{1+z^{-1}}{1-\alpha z^{-1}}, \qquad |\alpha|<1 \text{ (stability)}$$

The zero at $z=-1$ forces $H_{LP}(e^{j\pi})=0$; the normalizing constant forces $H_{LP}(e^{j0})=1$. The pole at $z=\alpha$ (real, $0<\alpha<1$ in practice) boosts low frequencies — the closer $\alpha$ is to 1, the narrower the passband. The 3-dB cutoff is controlled directly by $\alpha$:

3-dB cutoff ↔ pole location $$\cos\omega_c=\frac{2\alpha}{1+\alpha^2} \qquad\Longleftrightarrow\qquad \alpha=\frac{1-\sin\omega_c}{\cos\omega_c}$$
Worked Example 11-B — Place the cutoff at $\omega_c = 0.25\pi$
Step 1: $\sin(0.25\pi)=\cos(0.25\pi)=0.7071$.
Step 2: $\alpha=\dfrac{1-0.7071}{0.7071}=0.4142$.
Step 3: $H_{LP}(z)=0.2929\,\dfrac{1+z^{-1}}{1-0.4142\,z^{-1}}$, i.e. the difference equation $y[n]=0.4142\,y[n-1]+0.2929\,x[n]+0.2929\,x[n-1]$.
Check: $|H_{LP}(e^{j0.25\pi})| = 0.7071 = 1/\sqrt2$. Exactly −3 dB.

11.3.2 First-Order IIR Highpass

First-order IIR highpass $$H_{HP}(z)=\frac{1+\alpha}{2}\cdot\frac{1-z^{-1}}{1-\alpha z^{-1}}$$

Same pole, but the zero moves to $z=+1$: now DC is blocked and $\omega=\pi$ has unit gain. The same $\alpha \leftrightarrow \omega_c$ relation holds, so one design formula serves both filters.

Key — A doubly complementary pair
With the same $\alpha$, the lowpass/highpass pair satisfies both $$H_{LP}(z)+H_{HP}(z)=1 \qquad\text{and}\qquad \bigl|H_{LP}(e^{j\omega})\bigr|^2+\bigl|H_{HP}(e^{j\omega})\bigr|^2=1 .$$ They are delay-complementary and power-complementary(雙重互補): implement one filter, subtract its output from the input, and you get the other for free.
2026-06-12T22:38:05.719225 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0 π/2 π ω 0.0 0.2 0.4 0.6 0.8 1.0 magnitude First-order IIR lowpass α = 0.5 α = 0.8 0 π/2 π ω First-order IIR highpass α = 0.5 α = 0.8
Fig. 11-6 — First-order IIR lowpass and highpass magnitudes for $\alpha=0.5$ and $\alpha=0.8$. Pushing the pole toward the unit circle ($\alpha\to1$) narrows the passband of the LP and widens the stop region of the HP(α 越接近 1,極點越靠近單位圓,截止頻率越低). Dashed line: $1/\sqrt2$.

11.3.3 Second-Order IIR Bandpass

A bandpass filter(帶通濾波器)needs zeros at both $\omega=0$ and $\omega=\pi$ and a resonant pole pair near the center frequency $\omega_0$:

Second-order IIR bandpass $$H_{BP}(z)=\frac{1-\alpha}{2}\cdot \frac{1-z^{-2}}{1-\beta(1+\alpha)z^{-1}+\alpha z^{-2}}$$
Design knobs $$\text{center: } \omega_0=\cos^{-1}\beta \qquad\quad \text{3-dB bandwidth } B_w:\ \ \cos B_w=\frac{2\alpha}{1+\alpha^2}$$

The two parameters decouple beautifully: $\beta$ sets where the peak is ($|H_{BP}(e^{j\omega_0})|=1$ exactly), while $\alpha$ sets how narrow it is. Stability requires $|\alpha|<1$ and $|\beta|<1$.

11.3.4 Second-Order IIR Bandstop (Notch)

Second-order IIR bandstop $$H_{BS}(z)=\frac{1+\alpha}{2}\cdot \frac{1-2\beta z^{-1}+z^{-2}}{1-\beta(1+\alpha)z^{-1}+\alpha z^{-2}}$$

Now the zeros sit on the unit circle at $e^{\pm j\omega_0}$ with $\omega_0=\cos^{-1}\beta$, so the gain is exactly zero at the notch frequency(陷波頻率)— the classic tool for removing power-line hum(去除電源雜訊). The same $\alpha$ formula gives the 3-dB notch width, and with matching parameters $H_{BP}(z)+H_{BS}(z)=1$: another doubly complementary pair.

2026-06-12T22:38:05.966320 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0 ω₀ π ω 0.0 0.2 0.4 0.6 0.8 1.0 magnitude Second-order IIR bandpass α = 0.5 α = 0.8 0 ω₀ π ω Second-order IIR bandstop (notch) α = 0.5 α = 0.8
Fig. 11-7 — Second-order IIR bandpass and bandstop (notch) magnitudes, center $\omega_0=0.4\pi$ ($\beta=\cos\omega_0$), for $\alpha=0.5,\,0.8$. Larger $\alpha$ pulls the pole pair toward the unit circle, sharpening the peak/notch(α 越大,峰值/陷波越尖銳).
Worked Example 11-C — A 60 Hz notch at $f_s=400$ Hz
Step 1: notch frequency $\omega_0=2\pi\,(60/400)=0.3\pi \Rightarrow \beta=\cos(0.3\pi)=0.5878$.
Step 2: choose a 3-dB width $B_w=0.05\pi$: $\cos B_w = 0.98769 = \dfrac{2\alpha}{1+\alpha^2} \Rightarrow \alpha^2-2.02492\,\alpha+1=0 \Rightarrow \alpha=0.85408$ (the root inside the unit circle).
Step 3: $H_{BS}(z)=0.92704\,\dfrac{1-1.17557\,z^{-1}+z^{-2}}{1-1.08980\,z^{-1}+0.85408\,z^{-2}}$. Gain is exactly 0 at 60 Hz and ≈1 elsewhere.
Warning — Stability is on you
For FIR filters stability is automatic. For these IIR prototypes you must keep $|\alpha|<1$ (and $|\beta|<1$ for the second-order filters). A pole on or outside the unit circle makes the filter useless: the exam trap is to solve the quadratic for $\alpha$ in the bandwidth formula and pick the root larger than 1 — always take the root with $|\alpha|<1$.

11.4 Cascading Filters

A single first-order section rolls off slowly. The cheapest way to sharpen it is to cascade(串接)identical copies: overall $H(z)=G_1(z)G_2(z)\cdots G_K(z)$, magnitudes multiply, dB curves add.

x[n] G₁(z) G₂(z) G₃(z) y[n] H(z) = G₁(z)·G₂(z)·G₃(z)
Cascade connection: transfer functions multiply, dB gains add(串接:轉移函數相乘,dB 增益相加).

Cascading $K$ copies of the two-point average gives $H(z)=\bigl[\tfrac12(1+z^{-1})\bigr]^K$ with magnitude $\cos^K(\omega/2)$. The stopband improves dramatically — at $\omega=3\pi/4$ one section gives −8.3 dB but four sections give −33 dB — yet there is a price: the passband shrinks too.

3-dB cutoff of a K-section cascade $$\cos^K\!\bigl(\tfrac{\omega_c}{2}\bigr)=\tfrac{1}{\sqrt2} \qquad\Rightarrow\qquad \omega_c = 2\cos^{-1}\!\bigl(2^{-1/(2K)}\bigr) \quad\text{e.g. } K{=}1:\ 0.5\pi,\ \ K{=}2:\ 0.364\pi,\ \ K{=}4:\ 0.259\pi$$
2026-06-12T22:38:06.155450 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0 π/4 π/2 3π/4 π ω −60 −50 −40 −30 −20 −10 0 gain (dB) −3 dB Cascade of K identical FIR lowpass sections [cos(ω/2)]^K K = 1 section(s) K = 2 section(s) K = 4 section(s)
Fig. 11-8 — Cascading $K$ identical FIR lowpass sections: gain $\cos^K(\omega/2)$ in dB. Stopband attenuation improves with each section, but the −3 dB point slides toward DC(串接可加深阻帶衰減,但通帶也跟著變窄).
Concept — The big picture (interlude)
Simple filters teach the moves — zeros kill, poles boost, cascades sharpen — but they cannot independently control cutoff frequency, transition width, passband flatness, and stopband depth. That is exactly what real filter design delivers, and it needs two things developed next: a precise specification language (Section 11.5) and structural results about linear phase (Section 11.6). Later chapters then fill in the design algorithms.

11.5 Ideal Filters and Practical Specifications

11.5.1 The Four Ideal Filter Types

An ideal filter(理想濾波器)has unit gain in the passband, zero gain in the stopband, and an instantaneous transition between them — a "brick wall"(磚牆式)response. The four classical types, on $0\le\omega\le\pi$ (responses are even in $\omega$ and $2\pi$-periodic):

2026-06-12T22:38:26.992210 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0.00 0.25 0.50 0.75 1.00 1.25 |H(e^jω)| Ideal Lowpass Ideal Highpass 0 ω₁ ωc ω₂ π ω (rad/sample) 0.00 0.25 0.50 0.75 1.00 1.25 |H(e^jω)| Ideal Bandpass 0 ω₁ ωc ω₂ π ω (rad/sample) Ideal Bandstop
Fig. 11-1 — Magnitude responses of the four ideal filter types: brick-wall transitions, unit passband, zero stopband(四種理想濾波器:通帶增益 1、阻帶增益 0、瞬間過渡).

11.5.2 The Ideal Lowpass Impulse Response — and Why It Is Unrealizable

Take the inverse DTFT of the ideal lowpass response $H_{LP}(e^{j\omega})=1$ for $|\omega|\le\omega_c$, $0$ otherwise:

Ideal lowpass impulse response $$h_{LP}[n]=\frac{1}{2\pi}\int_{-\omega_c}^{\omega_c}e^{j\omega n}\,d\omega =\frac{\sin(\omega_c n)}{\pi n},\quad -\infty
2026-06-12T22:38:02.366558 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ −20 −15 −10 −5 0 5 10 15 20 n −0.05 0.00 0.05 0.10 0.15 0.20 0.25 h_LP[n] Ideal lowpass impulse response, ωc = π/4 (noncausal, infinite length)
Fig. 11-2 — Impulse response of the ideal lowpass filter with $\omega_c=\pi/4$: a sinc sequence extending over all $n$, including $n<0$(理想低通的脈衝響應是雙邊無限長的 sinc 序列).
Warning — Three strikes against the ideal filter
  1. Noncausal(非因果): $h_{LP}[n]\ne0$ for $n<0$ — the filter must respond before the input arrives.
  2. Infinitely long: the sinc never terminates, so no finite delay can fix the noncausality and no FIR can implement it exactly.
  3. Not absolutely summable: $h_{LP}[n]$ decays only like $1/n$, so $\sum|h_{LP}[n]|=\infty$ — the ideal filter is not even BIBO stable. Truncating the sinc causes the Gibbs ripples(吉布斯現象)you will meet in FIR window design.
直觀解釋(點擊展開)
頻域裡越「尖銳」的東西,時域裡就越「拖長」——這是傅立葉變換的基本取捨。磚牆式的不連續跳變是頻域裡最尖銳的特徵,所以它的時域對應(sinc)必須無限長、而且衰減極慢(只有 1/n)。因果、有限長的濾波器永遠只能「逼近」理想響應:你可以把過渡帶做窄、漣波做小,但不可能同時做到零過渡帶與零漣波。這就是為什麼下一小節要定義「容忍規格」——承認不完美,但把不完美量化。

11.5.3 Practical Filter Specifications: the Tolerance Scheme

Since brick walls are impossible, a practical lowpass spec relaxes the ideal in three ways: allow a small passband ripple(通帶漣波)$\delta_p$, allow a small nonzero stopband level(阻帶漣波)$\delta_s$, and insert a transition band(過渡帶)between the passband edge $\omega_p$ and stopband edge $\omega_s$ where the response is unconstrained:

Lowpass tolerance scheme $$\begin{aligned} 1-\delta_p \;\le\; \bigl|H(e^{j\omega})\bigr| \;\le\; 1+\delta_p, &\qquad |\omega|\le\omega_p \quad\text{(passband)}\\[2pt] \bigl|H(e^{j\omega})\bigr| \;\le\; \delta_s, &\qquad \omega_s\le|\omega|\le\pi \quad\text{(stopband)} \end{aligned}$$
2026-06-12T22:38:04.851067 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0 ωp ωs π ω 0.0 0.2 0.4 0.6 0.8 1.0 1.2 |H(e^jω)| 1+δp 1−δp δs passband transition stopband Lowpass tolerance scheme: shaded regions are forbidden
Fig. 11-3 — The lowpass tolerance scheme(容忍規格圖): the response must stay out of the shaded forbidden regions. Green curve: a third-order elliptic filter meeting $\omega_p=0.4\pi$, $\omega_s=0.55\pi$, $\delta_p=0.08$, $\delta_s=0.05$. The transition band $\omega_p\le\omega\le\omega_s$ is a free zone(過渡帶內不受限制).

Specifications are usually quoted in dB:

dB specifications $$R_p = -20\log_{10}\bigl(1-\delta_p\bigr)\ \text{dB (peak passband ripple)} \qquad A_s = -20\log_{10}\delta_s\ \text{dB (minimum stopband attenuation)}$$

For example $\delta_s=0.01$ means $A_s=40$ dB; $\delta_p=0.05$ means $R_p\approx0.45$ dB. (An alternative convention quotes the total passband swing $20\log_{10}\frac{1+\delta_p}{1-\delta_p}$ — read the problem statement carefully.) A complete lowpass specification is then the quadruple $(\omega_p,\ \omega_s,\ \delta_p,\ \delta_s)$, or equivalently $(\omega_p,\ \omega_s,\ R_p,\ A_s)$. The filter design problem of the coming chapters is: find the lowest-order filter whose response stays inside the template.

Key — The four numbers every spec needs
$\omega_p$ (passband edge), $\omega_s$ (stopband edge), $\delta_p$ (passband tolerance), $\delta_s$ (stopband tolerance). Tighter tolerances or a narrower transition band $\Delta\omega=\omega_s-\omega_p$ always cost a higher filter order — nothing is free.

11.6 Linear-Phase FIR Filters

11.6.1 Why Linear Phase? And Time-Reversal Filtering

Magnitude is only half the story. If the phase response $\angle H(e^{j\omega})$ is not linear in $\omega$, different frequency components experience different delays — the group delay(群延遲)$\tau(\omega)=-\,d\angle H/d\omega$ varies — and the waveform is smeared even when all magnitudes are untouched. This phase distortion(相位失真)is fatal in applications that care about waveform shape (ECG, seismic data, images, data pulses).

Linear phase = pure delay $$H(e^{j\omega})=A(\omega)\,e^{-j\omega D}\ \ (A(\omega)\text{ real}) \qquad\Rightarrow\qquad \tau(\omega)=D\ \text{samples for all }\omega$$

Every frequency is delayed by the same $D$ samples: the output is a filtered, shifted, but unsmeared copy of the input.

Time-reversal (zero-phase) filtering

For offline data there is an elegant trick. Filter the signal, time-reverse the result, filter again, and reverse once more. Each pass contributes $H(e^{j\omega})$ once with a conjugation, so the overall response is

Forward–backward filtering $$H_{\text{overall}}(e^{j\omega}) = H(e^{j\omega})\,H^{*}(e^{j\omega}) = \bigl|H(e^{j\omega})\bigr|^{2}$$

— real and nonnegative: exactly zero phase, with the magnitude squared (doubling attenuation in dB). This is MATLAB's filtfilt. The catch: the procedure is noncausal, so it only works on recorded (finite, stored) signals, not in real time(僅適用於離線資料,無法即時處理).

11.6.2 The Four Linear-Phase FIR Types

A causal length-$N$ FIR filter $h[n]$, $n=0,\dots,N-1$, has (generalized) linear phase if and only if its impulse response is symmetric or antisymmetric about its midpoint:

Linear-phase condition $$h[n]=\pm\,h[N-1-n] \qquad\Rightarrow\qquad H(e^{j\omega})= \begin{cases} e^{-j\omega(N-1)/2}\,A(\omega), & \text{symmetric }(+)\\[2pt] j\,e^{-j\omega(N-1)/2}\,A(\omega), & \text{antisymmetric }(-) \end{cases}$$

with $A(\omega)$ real (the amplitude response) and constant group delay $\tau=(N-1)/2$ samples. Two symmetry choices times two length parities give exactly four types:

TypeSymmetryLength $N$Group delay $\frac{N-1}{2}$Forced zerosCan realize
1symmetric $h[n]=h[N{-}1{-}n]$oddintegernoneLP, HP, BP, BS — anything
2symmetricevenhalf-integer$z=-1$ ($\omega=\pi$)LP, BP (not HP, not BS)
3antisymmetric $h[n]=-h[N{-}1{-}n]$oddinteger$z=+1$ and $z=-1$BP, differentiator, Hilbert
4antisymmetricevenhalf-integer$z=+1$ ($\omega=0$)HP, BP, differentiator, Hilbert
2026-06-12T22:38:06.620815 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ 0 1 2 3 4 5 6 n −4 −2 0 2 4 Type 1: symmetric, N odd (N=7) 0 1 2 3 4 5 n −4 −2 0 2 4 Type 2: symmetric, N even (N=6) 0 1 2 3 4 5 6 n −4 −2 0 2 4 Type 3: antisymmetric, N odd (N=7) 0 1 2 3 4 5 n −4 −2 0 2 4 Type 4: antisymmetric, N even (N=6)
Fig. 11-9 — Example impulse responses of the four linear-phase FIR types. Dashed red line: the center of (anti)symmetry at $n=(N-1)/2$ — an actual sample for odd $N$ (Types 1, 3), halfway between samples for even $N$ (Types 2, 4). Note the Type 3 center sample is forced to zero(Type 3 中心點必為 0).

11.6.3 Forced Zeros and Filter Suitability

The structural zeros in the table follow directly from the symmetry. Evaluate $H(z)=\sum h[n]z^{-n}$ at $z=\pm1$:

Key — Type 1 is the safe choice
Only Type 1 (symmetric, odd length) has no forced zeros and can approximate any of LP/HP/BP/BS. Exam shortcut: check (i) symmetric or antisymmetric? (ii) $N$ odd or even? then read off the type and its forbidden bands. Antisymmetric ⇒ dead at DC; even-length symmetric ⇒ dead at $\omega=\pi$.
直觀解釋(點擊展開)
為什麼對稱就會有線性相位?把脈衝響應想成以中心點 (N−1)/2 為鏡像。任何對稱序列都可以寫成「零相位(以中心為原點的偶/奇序列)」再「延遲 (N−1)/2」。零相位部分的頻率響應是純實數(偶對稱)或純虛數(奇對稱),延遲部分貢獻 e^{−jω(N−1)/2} 的線性相位——所以總相位是一條直線(奇對稱多一個 90° 的常數相移,稱為「廣義線性相位」)。而「強制零點」的直覺:反對稱序列所有樣本相加必為 0,所以 DC 增益必為 0;偶數長度的對稱序列在 ω=π 時左右兩半正負抵消,所以 π 處增益必為 0。選型時先想清楚你的濾波器在 ω=0 和 ω=π 需不需要增益。

11.7 Chapter Summary

Simple FIR prototypes

Lowpass $\tfrac12(1+z^{-1})$: $|H|=\cos\frac\omega2$, zero at $\pi$. Highpass $\tfrac12(1-z^{-1})$: $|H|=\sin\frac\omega2$, zero at DC. Both cut off at $\pi/2$; $M$-point moving average generalizes the LP with nulls at $2\pi k/M$.

Simple IIR prototypes

First-order LP/HP with pole $\alpha$: $\alpha=\frac{1-\sin\omega_c}{\cos\omega_c}$ sets the 3-dB cutoff. Second-order BP/BS: $\beta=\cos\omega_0$ sets the center/notch, $\cos B_w=\frac{2\alpha}{1+\alpha^2}$ sets the width. Matching pairs satisfy $H_1+H_2=1$ and $|H_1|^2+|H_2|^2=1$.

Decibels & cascades

Gain $=20\log_{10}|H|$ dB; $-3$ dB $=$ half power $=1/\sqrt2$ amplitude. Cascading: magnitudes multiply, dB add — stopband deepens but the passband narrows.

Ideal filters

Brick-wall LP/HP/BP/BS. Ideal LP has $h[n]=\frac{\sin\omega_c n}{\pi n}$: noncausal, infinite, not absolutely summable ⇒ unrealizable; real filters only approximate it.

Tolerance scheme

Spec $=(\omega_p,\omega_s,\delta_p,\delta_s)$: passband within $1\pm\delta_p$, stopband below $\delta_s$, free transition band. In dB: $R_p=-20\log_{10}(1-\delta_p)$, $A_s=-20\log_{10}\delta_s$.

Linear-phase FIR types

$h[n]=\pm h[N{-}1{-}n]$ ⇒ constant group delay $\frac{N-1}{2}$. Type 1 (sym, odd): anything. Type 2 (sym, even): no HP/BS. Type 3 (antisym, odd): zeros at $0$ and $\pi$. Type 4 (antisym, even): no LP/BS. Offline zero phase: filtfilt ⇒ $|H|^2$.

Exercises

Exercise 1 — Analyzing the Two-Point Average and First Difference

Problem: Consider the filters $H_0(z)=\tfrac12(1+z^{-1})$ and $H_1(z)=\tfrac12(1-z^{-1})$. (a) Derive the magnitude and phase responses of both filters. (b) Find the 3-dB cutoff frequency of each. (c) Show that the pair is power-complementary. (d) What is the gain of $H_0$ in dB at $\omega = 3\pi/4$?

Click to reveal solution

(a) Factor out the half-sample delay:

$$H_0(e^{j\omega})=\tfrac12\bigl(1+e^{-j\omega}\bigr)=e^{-j\omega/2}\,\frac{e^{j\omega/2}+e^{-j\omega/2}}{2}=e^{-j\omega/2}\cos\tfrac\omega2$$ $$H_1(e^{j\omega})=\tfrac12\bigl(1-e^{-j\omega}\bigr)=e^{-j\omega/2}\,\frac{e^{j\omega/2}-e^{-j\omega/2}}{2}=j\,e^{-j\omega/2}\sin\tfrac\omega2$$

So $|H_0|=\cos\frac\omega2$, $\angle H_0=-\frac\omega2$; and $|H_1|=\sin\frac\omega2$ (for $0\le\omega\le\pi$), $\angle H_1=\frac\pi2-\frac\omega2$. Both have linear phase (Types 2 and 4 respectively).

(b) $\cos\frac{\omega_c}2=\frac1{\sqrt2}\Rightarrow\omega_c=\frac\pi2$; likewise $\sin\frac{\omega_c}2=\frac1{\sqrt2}\Rightarrow\omega_c=\frac\pi2$. Same cutoff — they split the band evenly.

(c) $|H_0|^2+|H_1|^2=\cos^2\frac\omega2+\sin^2\frac\omega2=1$ for all $\omega$. $\blacksquare$

(d) $|H_0(e^{j3\pi/4})|=\cos\frac{3\pi}8=0.3827$, so the gain is $20\log_{10}0.3827=-8.34$ dB.

Exercise 2 — Designing a First-Order IIR Lowpass

Problem: Design the first-order IIR lowpass $H_{LP}(z)=\frac{1-\alpha}{2}\cdot\frac{1+z^{-1}}{1-\alpha z^{-1}}$ with a 3-dB cutoff at $\omega_c=\pi/3$. (a) Find $\alpha$ and write out $H_{LP}(z)$ numerically and the difference equation. (b) Verify the gains at $\omega=0$, $\omega=\omega_c$, and $\omega=\pi$. (c) Write the corresponding highpass $H_{HP}(z)$ with the same cutoff and state the two complementarity relations linking the pair.

Click to reveal solution

(a) With $\sin\frac\pi3=0.8660$, $\cos\frac\pi3=0.5$:

$$\alpha=\frac{1-\sin\omega_c}{\cos\omega_c}=\frac{1-0.8660}{0.5}=0.2679$$ $$H_{LP}(z)=0.3660\,\frac{1+z^{-1}}{1-0.2679\,z^{-1}} \qquad y[n]=0.2679\,y[n-1]+0.3660\,x[n]+0.3660\,x[n-1]$$

(b) At $\omega=0$: $H=0.3660\cdot\frac{2}{1-0.2679}=\frac{0.7321}{0.7321}=1$ (0 dB). At $\omega=\pi$: numerator $1+e^{-j\pi}=0$, so $H=0$ ($-\infty$ dB). At $\omega_c=\pi/3$: by construction of the $\alpha$ formula, $|H|=1/\sqrt2$ ($-3$ dB); direct substitution $z=e^{j\pi/3}$ confirms $|H|=0.7071$.

(c) $H_{HP}(z)=\dfrac{1+\alpha}{2}\cdot\dfrac{1-z^{-1}}{1-\alpha z^{-1}}=0.6340\,\dfrac{1-z^{-1}}{1-0.2679\,z^{-1}}$. The pair is delay-complementary, $H_{LP}(z)+H_{HP}(z)=1$, and power-complementary, $|H_{LP}(e^{j\omega})|^2+|H_{HP}(e^{j\omega})|^2=1$ — so the highpass output can be computed as $x[n]-y_{LP}[n]$.

Exercise 3 — The Ideal Lowpass Filter Is Unrealizable

Problem: An ideal lowpass filter has $H(e^{j\omega})=1$ for $|\omega|\le0.3\pi$ and $0$ for $0.3\pi<|\omega|\le\pi$. (a) Derive its impulse response $h[n]$ and evaluate $h[0]$, $h[1]$, $h[5]$. (b) Give three independent reasons why this filter cannot be implemented. (c) If we tolerate a delay, can a sufficiently long causal FIR filter implement it exactly? Explain.

Click to reveal solution

(a) Inverse DTFT over the passband only:

$$h[n]=\frac1{2\pi}\int_{-0.3\pi}^{0.3\pi}e^{j\omega n}\,d\omega =\frac{e^{j0.3\pi n}-e^{-j0.3\pi n}}{2\pi jn} =\frac{\sin(0.3\pi n)}{\pi n}$$

Values: $h[0]=\dfrac{\omega_c}{\pi}=0.3$; $h[1]=\dfrac{\sin 0.3\pi}{\pi}=\dfrac{0.8090}{3.1416}=0.2575$; $h[5]=\dfrac{\sin 1.5\pi}{5\pi}=\dfrac{-1}{15.708}=-0.0637$.

(b) (1) Noncausal: $h[-1]=h[1]\ne0$ — it needs future inputs. (2) Infinite duration: $h[n]\ne0$ for arbitrarily large $|n|$, so no finite implementation exists. (3) Unstable in the BIBO sense: $|h[n]|\sim\frac1{\pi|n|}$ and the harmonic series diverges, so $\sum_n|h[n]|=\infty$.

(c) No. Delaying by $D$ and truncating to $0\le n\le N-1$ gives a causal FIR approximation $h[n-D]w[n]$, but truncation in time means convolving the brick wall with a sinc-like kernel in frequency: ripples (Gibbs phenomenon, ≈9% overshoot for rectangular truncation) and a nonzero transition band appear for every finite $N$. Exact realization would require all infinitely many taps. This is precisely why practical specs use the tolerance scheme of Section 11.5.3.

Exercise 4 — Converting Tolerance Specs to Decibels

Problem: A lowpass filter must satisfy the tolerance scheme with $\omega_p=0.35\pi$, $\omega_s=0.5\pi$, $\delta_p=0.05$, $\delta_s=0.01$. (a) Compute the peak passband ripple $R_p$ and the minimum stopband attenuation $A_s$ in dB. (b) A different spec sheet demands $A_s = 60$ dB and $R_p = 0.2$ dB. Convert these back to $\delta_s$ and $\delta_p$. (c) The transition bandwidth is $\Delta\omega=\omega_s-\omega_p$. Qualitatively, what happens to the required filter order if $\Delta\omega$ is halved with tolerances unchanged?

Click to reveal solution

(a)

$$R_p=-20\log_{10}(1-\delta_p)=-20\log_{10}0.95=0.446\ \text{dB} \qquad A_s=-20\log_{10}\delta_s=-20\log_{10}0.01=40\ \text{dB}$$

(b) Invert the formulas:

$$\delta_s=10^{-A_s/20}=10^{-3}=0.001 \qquad \delta_p=1-10^{-R_p/20}=1-10^{-0.01}=1-0.97724=0.0228$$

(c) The order grows roughly in inverse proportion to the transition width (for FIR designs, $N\propto A_s/\Delta\omega$ by standard estimates such as the Kaiser formula). Halving $\Delta\omega$ approximately doubles the required order — sharpness is the most expensive item in a filter spec.

Exercise 5 — MATLAB: Smoothing a Noisy Signal with a Moving Average

Problem: A slow sinusoid $s[n]=2\sin(2\pi\cdot0.02\,n)$, $n=0,\dots,199$, is corrupted by white Gaussian noise of standard deviation $0.8$. In MATLAB, (a) filter the noisy signal with an $M=11$ point moving average and plot the input and output; (b) plot the filter's magnitude response and explain why $M=11$ works well here; (c) state the delay introduced and how to compensate it.

Click to reveal solution

(a) MATLAB code:

N = 200;  n = (0:N-1).';
s = 2*sin(2*pi*0.02*n);          % clean signal (f0 = 0.02 cycles/sample)
x = s + 0.8*randn(N,1);          % noisy observation

M = 11;
b = ones(1,M)/M;                 % moving-average coefficients
y = filter(b, 1, x);             % causal filtering, delay (M-1)/2 = 5
y_aligned = [y((M+1)/2:end); zeros((M-1)/2,1)];   % advance by 5 samples

subplot(2,1,1); plot(n, x, 'Color', [.5 .5 .5]); hold on;
plot(n, s, 'b', 'LineWidth', 1.5); legend('noisy x[n]','clean s[n]');
subplot(2,1,2); plot(n, y_aligned, 'r', 'LineWidth', 1.5); hold on;
plot(n, s, 'b--'); legend('filtered (aligned)','clean s[n]');

figure;                          % (b) magnitude response
[H, w] = freqz(b, 1, 1024);
plot(w/pi, abs(H)); grid on;
xlabel('\omega/\pi'); ylabel('|H(e^{j\omega})|');

Regenerated result (numpy/matplotlib, seed 11):

2026-06-12T22:38:07.001718 image/svg+xml Matplotlib v3.10.8, https://matplotlib.org/ −2 0 2 4 amplitude Noisy input and underlying signal x[n] = s[n] + noise clean s[n] 0 25 50 75 100 125 150 175 200 n −2 −1 0 1 2 amplitude Moving-average output: noise reduced, signal kept y[n]: 11-point moving average clean s[n]
Fig. 11-10 — Top: noisy input over the clean signal. Bottom: 11-point moving-average output (center-aligned) — broadband noise is strongly suppressed while the slow sinusoid passes nearly intact(雜訊被平均掉,慢速正弦幾乎不受影響).

(b) The signal lives at $\omega_0=2\pi\cdot0.02=0.04\pi$, deep inside the main lobe of the $M=11$ response (first null at $2\pi/11\approx0.18\pi$): its gain is $\bigl|\frac{\sin(11\omega_0/2)}{11\sin(\omega_0/2)}\bigr|\approx0.978$, i.e. a loss of only about 0.2 dB. The noise, by contrast, is spread uniformly over all $\omega$, and averaging $11$ independent samples cuts the noise power by a factor of $11$ ($\approx10.4$ dB). Hence: signal kept, noise reduced.

(c) The filter is a Type-1 linear-phase FIR with group delay $(M-1)/2=5$ samples at every frequency, so the output is simply shifted by 5. Compensate by advancing the output 5 samples (as in the code), by plotting against $n-5$, or — offline — by using filtfilt, which yields zero phase and squares the magnitude response.

Exercise 6 — Identifying a Linear-Phase Type

Problem: A causal FIR filter has impulse response $h[n]=\{1,\,-2,\,0,\,2,\,-1\}$ for $n=0,\dots,4$. (a) Determine whether it has linear phase, and if so, which type and what group delay. (b) Compute $H(e^{j0})$ and $H(e^{j\pi})$ and confirm they agree with the structural zeros of that type. (c) Could this filter be used as a lowpass filter? A highpass? What applications suit it?

Click to reveal solution

(a) Check $h[n]$ against $h[4-n]$: $h[0]=1$ vs $h[4]=-1$; $h[1]=-2$ vs $h[3]=2$; $h[2]=0$. So $h[n]=-h[4-n]$: antisymmetric with odd length $N=5$ — a Type 3 linear-phase filter (note the center sample $h[2]=0$, as Type 3 requires). Group delay $\tau=(N-1)/2=2$ samples, plus the constant $90^\circ$ phase factor $j$ of antisymmetric filters (generalized linear phase).

(b) $H(e^{j0})=\sum_n h[n]=1-2+0+2-1=0$. $H(e^{j\pi})=\sum_n(-1)^n h[n]=h[0]-h[1]+h[2]-h[3]+h[4]=1+2+0-2-1=0$. Both are zero — exactly the forced zeros at $z=\pm1$ that define Type 3.

(c) With zero gain at both $\omega=0$ and $\omega=\pi$ it can be neither a lowpass nor a highpass (nor a bandstop) — passbands at the band edges are impossible. It is shaped for bandpass-like behavior; Type 3 structures are the natural home of differentiators and Hilbert transformers(微分器與希爾伯特轉換器), both of which require $A(0)=0$.