---
title: Filter structures
heading: Direct forms, transposed forms, cascades of second-order sections, parallel forms and lattices, with their costs and their sensitivity to coefficient rounding
eyebrow: S7 · Lesson 17 · Filter structures
xp: 50
---

::: hook
A system function says what a filter does; a structure says how it's computed, and in finite-precision arithmetic the two are not independent. The same eighth-order transfer function can be built as one long difference equation or as four little second-order sections in a chain, and with 16-bit coefficients the first might be unstable while the second works perfectly. This lesson lays out the standard structures, counts their multipliers and delays, and shows why practical IIR filters are almost always cascades of biquads, and why lattices appear wherever stability must be checked or guaranteed.
:::

::: play
- The poles of a fourth-order narrowband filter (two pole pairs at radius 0.95, angles 0.2 and 0.25 rad) built in **direct form**, with its four denominator coefficients rounded to B fractional bits.
- With plenty of bits the poles sit where they were designed. Reduce B and the clustered poles scatter, and some can cross the unit circle.
- The same poles in two second-order sections would each move only slightly, because each section's coefficients depend on just one pole pair.
:::
:::

```sim plot
view: zplane
range: 1.3
slider: B = 4..16 = 12 step 1
num: z^4
den: z^4 + round(-3.70306*2^B)/2^B*z^3 + round(5.23305*2^B)/2^B*z^2 + round(-3.34201*2^B)/2^B*z + round(0.814506*2^B)/2^B
```

::: predict
## A sixth-order IIR filter with six zeros is built in direct form I and in direct form II. How many delay elements does each need?

- [ ] 6 and 6
- [x] 12 and 6
- [ ] 6 and 12
- [ ] 13 and 13

::: reveal
Direct form I keeps separate delay lines for the input (6) and the output (6): 12. Direct form II, which puts the poles first and shares one delay line, needs only max(N, M) = 6, the minimum possible (it's canonic). Both use the same 13 multipliers. Direct form II's internal signals can be much larger than its input or output, which matters in fixed point.
:::
:::

::: nameit
## Direct forms

For $H(z) = \frac{\sum_{k=0}^{M}b_kz^{-k}}{1 - \sum_{k=1}^{N}a_kz^{-k}}$:

- **Direct form I**: zeros, then poles; M + N delays, M + N + 1 multipliers.
- **Direct form II**: poles, then zeros, sharing delays; max(M, N) delays (canonic).
- **Transposed forms**: reverse every branch and swap input and output; the transfer function is unchanged, but the order of additions, and so the rounding noise, differs. Transposed direct form II is common in floating point.

## Cascade and parallel forms

- **Cascade**: $H(z) = \prod_kH_k(z)$, each $H_k$ a second-order section (biquad) with one pole pair and one zero pair; ⌈N/2⌉ sections. Poles move only with their own section's coefficients, so the cascade is far less sensitive to rounding than one high-order direct form, especially for clustered poles.
- **Parallel**: $H(z) = \sum_kH_k(z)$ from partial fractions; zeros are set by how the sections add, so they're more sensitive.

## Coefficient sensitivity

A high-order polynomial's roots are extremely sensitive to its coefficients when they're close together, and narrowband filters have clustered poles. In a biquad $1 - 2r\cos\theta\,z^{-1} + r^2z^{-2}$, rounding $r^2$ to B bits moves the radius to $\sqrt{q(r^2)}$, a small, local change.

## Lattices

An FIR lattice (or an all-pole IIR lattice) is a chain of stages with **reflection coefficients** $k_1, \dots, k_N$. From $A(z) = 1 + \sum a_iz^{-i}$, the **step-down** recursion takes $k_N = a_N$ and

$$a_i^{(N-1)} = \frac{a_i - k_Na_{N-i}}{1 - k_N^2}$$

repeated down to $k_1$. The all-pole filter 1/A(z) is stable, and A(z) minimum phase, exactly when every $|k_m| < 1$: a stability test that needs no root finding. Lattices are used in speech coding and adaptive filters.
:::

::: example
## Find the lattice coefficients of $A(z) = 1 + 0.5z^{-1} + 0.2z^{-2}$, and say whether 1/A(z) is stable.

::: solution
1. **Last coefficient.** $k_2 = a_2 = 0.2$.
2. **Step down.**
   $$\begin{aligned} a_1^{(1)} &= \frac{0.5 - 0.2 \times 0.5}{1 - 0.04} \\ &= 0.4167 \end{aligned}$$
   so $k_1$ = 0.4167.
3. **Stability.** Both are less than 1 in magnitude, so 1/A(z) is stable.
4. **Check by rebuilding.**
   $$\begin{aligned} a_1 &= k_1 + k_1k_2 \\ &= 0.4167 \times 1.2 \\ &= 0.5 \end{aligned}$$
   as given.

**Answer:** $k_1$ = 0.4167 and $k_2$ = 0.2, both less than 1 in magnitude, so 1/A(z) is stable.
:::
:::

::: example
## The sim's fourth-order filter, in direct form, has denominator coefficients −3.70306, 5.23305, −3.34201 and 0.814506. Why does it fail at modest word lengths when two biquads don't?

::: solution
1. **Where the poles sit.** Its four poles lie within 0.05 rad of each other near radius 0.95, and the polynomial's coefficients are large numbers whose small differences place the poles.
2. **Effect of rounding.** An error of $2^{-9}$ in one coefficient shifts the cluster by far more than that.
3. **Split into biquads.** Each pole pair then depends on two modest coefficients only:
   $$\begin{aligned} A_1(z) &= 1 - 2(0.95)\cos(0.2)z^{-1} \\ &\quad + 0.9025z^{-2} \end{aligned}$$
   and its partner.
4. **Rounding a biquad.** Rounding 0.9025 to 8 bits gives
   $$\begin{aligned} r &= 0.99992 \times 0.95 \\ &\approx 0.9499 \end{aligned}$$
   which is harmless.

**Answer:** in direct form a tiny error in one coefficient moves the whole tight cluster of poles a long way; in biquads each pole pair rests on two modest coefficients, and 8-bit rounding leaves the radius at 0.9499.
:::
:::

::: example
## Find the lattice coefficients of $A(z) = 1 - 0.9z^{-1} + 0.64z^{-2}$ and decide whether 1/A(z) is stable.

::: solution
1. **Last coefficient.** $k_2 = a_2 = 0.64$.
2. **Step down.**
   $$\begin{aligned} a_1^{(1)} &= \frac{a_1 - k_2a_1}{1 - k_2^2} \\ &= \frac{a_1}{1 + k_2} \\ &= \frac{-0.9}{1.64} \\ &= -0.549 \end{aligned}$$
   so $k_1 = -0.549$.
3. **Stability.** Both magnitudes are below 1, so the filter is stable.
4. **Check.** Indeed its poles are a complex pair of radius $\sqrt{0.64} = 0.8$.

**Answer:** $k_1 = -0.549$ and $k_2 = 0.64$, so 1/A(z) is stable.
:::
:::

::: check
given: M = 2 | 4 | 6; N = 4 | 6 | 8
answer: M + N + 1
tolerance: 0

## A direct-form IIR filter has M = {M} zeros and N = {N} poles. How many multipliers does it need?

::: right
Right. M + 1 feedforward and N feedback coefficients: {answer}.
:::

::: misses
- [M + N] The feedforward side has M + 1 coefficients, $b_0$ to $b_M$.
- [any] Not yet. Count $b_0 \dots b_M$ and $a_1 \dots a_N$.
:::
:::

::: check
given: M = 2 | 4 | 6; N = 4 | 6 | 8
answer: (M + N + abs(M - N))/2
tolerance: 0

## How many delays does direct form II need for M = {M} zeros and N = {N} poles?

::: right
Right. max(M, N) = {answer}, the minimum: it's canonic.
:::

::: misses
- [M + N] That's direct form I, with separate delay lines.
- [any] Not yet. The shared delay line needs max(M, N).
:::
:::

::: check
given: N = 5 | 7 | 11 | 13
answer: ceil(N/2 - 0.0001)
tolerance: 0

## An order-{N} IIR filter is built as a cascade of biquads. How many sections does it need?

::: right
Right. ⌈N/2⌉ = {answer}; an odd order leaves one first-order section.
:::

::: misses
- [floor(N/2 + 0.0001)] Round up: an odd order needs one more section.
- [any] Not yet. Each biquad realizes two poles.
:::
:::

::: check
given: a = 0.3 | 0.6 | -0.8; k = 0.2 | 0.5 | -0.4
answer: a/(1 + k)
tolerance: 0.5%

## $A(z) = 1 + \given{a}z^{-1} + \given{k}z^{-2}$. What's the lattice coefficient $k_1$?

::: right
Right. $k_2$ = {k} and $k_1 = \frac{a_1 - k_2a_1}{1 - k_2^2} = \frac{a_1}{1 + k_2}$ = {answer}.
:::

::: misses
- [a] Step down first: divide out the second stage.
- [a/(1 - k)] $(1 - k_2)/(1 - k_2^2) = 1/(1 + k_2)$.
- [any] Not yet. Use the step-down recursion.
:::
:::

::: check
given: r = 0.9 | 0.95 | 0.97; B = 5 | 6 | 8
answer: sqrt(round(r^2*2^B)/2^B)
tolerance: 0.0001

## A biquad's $a_2 = r^2$ with r = {r} is rounded to {B} fractional bits. What pole radius results?

::: right
Right. $\sqrt{q(r^2)}$ = {answer}.
:::

::: misses
- [round(r*2^B)/2^B] It's $r^2$ that's stored and rounded, not r.
- [any] Not yet. Round $r^2\cdot2^B$ to an integer, divide by $2^B$, take the square root.
:::
:::

::: check
given: B = 8 | 12 | 15
answer: 2^(-B - 1)
tolerance: 0.5%

## Coefficients are rounded to {B} fractional bits. What's the largest possible rounding error?

::: right
Right. Half a step: $2^{-B-1}$ = {answer}.
:::

::: misses
- [2^(-B)] Rounding errs by at most half a step; truncation by a whole step.
- [any] Not yet. The step is $2^{-B}$.
:::
:::

::: check
kind: parts
given: N = 4 | 8 | 12

## An order-{N} IIR filter is built as a cascade of direct-form II biquads.

::: part
answer: N/2
unit: sections
tolerance: 0

### How many biquads does it need?

::: misses
- [any] ⌈N/2⌉.
:::
:::

::: part
answer: 5*N/2
unit: multipliers
tolerance: 0

### How many multipliers (five per biquad)?

::: misses
- [any] Five per section.
:::
:::

::: part
answer: N
unit: delays
tolerance: 0

### How many delays?

::: misses
- [any] Two per section.
:::
:::
:::

::: check
kind: derivation
vars: a = -1.8..1.8, b = 0.05..0.95

## $A(z) = 1 + az^{-1} + bz^{-2}$ has complex roots.

::: step
answer: b

### What is $k_2$?
:::

::: step
answer: a/(1 + b)

### What is $k_1$?
:::

::: step
answer: sqrt(b)

### What is the radius of the poles of 1/A(z)?
:::

::: right
Right. $|k_2| = b < 1$ is the same condition as the poles' radius $\sqrt b$ lying inside the circle.
:::
:::

::: explain
## Why are high-order IIR filters built as cascades of second-order sections?

::: model
A high-order denominator written as one polynomial has coefficients that each depend on all the poles together, and when the poles are clustered, as in any narrowband filter, the roots of the polynomial shift dramatically for tiny changes in its coefficients. Rounding those coefficients to a finite word length can then move poles far from where they were designed, distorting the response or pushing a pole outside the unit circle. In a cascade of biquads, each section's two coefficients set only its own pole pair, so a rounding error moves only that pair and only by a little. The overall response stays close to the design, and stability can be checked section by section.
:::
:::

::: practice

::: check
given: M = 3 | 5; N = 4 | 10
answer: M + N + 1
tolerance: 0

## Direct-form multipliers for M {M}, N {N}?

::: misses
- [any] M + N + 1.
:::
:::

::: check
given: a = 0.4 | -0.7; k = 0.3 | -0.6
answer: a/(1 + k)
tolerance: 0.5%

## $k_1$ for $1 + \given{a}z^{-1} + \given{k}z^{-2}$?

::: misses
- [any] $a_1/(1 + k_2)$.
:::
:::

::: check
given: N = 3 | 5 | 6 | 7 | 8 | 10 | 12
answer: ceil(N/2 - 0.0001)
tolerance: 0

## Biquads for order {N}?

::: misses
- [any] ⌈N/2⌉.
:::
:::
:::
