---
title: "Problem set 5: FIR design and the DFT"
heading: "Problem set 5: window and Kaiser designs, equiripple estimates, the DFT, circular convolution and block convolution"
eyebrow: S7 · Problem set 5
type: problems
---

::: hook
These problems cover lessons 22 to 25: windowed ideal responses, window tables and Kaiser's formulas, equiripple length estimates and weights, DFT bins and amplitudes, circular against linear convolution, and the arithmetic and latency of overlap-add and overlap-save.
:::

::: pool
pick: 12

::: check
kind: parts
given: p = 0.2 | 0.35; d = 0.1 | 0.15; A = 45 | 70

## A Kaiser lowpass: passband edge {p}π, transition {d}π, {A} dB.

::: part
answer: p + d/2
tolerance: 0.5%

### Cutoff for the ideal response, in units of π?

::: misses
- [any] Midway between the edges.
:::
:::

::: part
answer: step(A - 50)*0.1102*(A - 8.7) + step(50 - A)*(0.5842*(A - 21)^0.4 + 0.07886*(A - 21))
tolerance: 0.5%

### β?

::: misses
- [any] Kaiser's β formula for this A.
:::
:::

::: part
answer: ceil((A - 8)/(2.285*d*pi))
tolerance: 0

### M, rounded up?

::: misses
- [any] $(A - 8)/(2.285\Delta\omega)$.
:::
:::
:::

::: check
kind: parts
given: M = 26 | 40 | 62; c = 0.3 | 0.45; n = 5 | 11

## A windowed lowpass with M = {M}, cutoff {c}π, Hamming window.

::: part
answer: sin(c*pi*(n - M/2))/(pi*(n - M/2))
tolerance: 0.5%

### $h_d[\given{n}]$?

::: misses
- [any] Centered sinc.
:::
:::

::: part
answer: 0.54 - 0.46*cos(2*pi*n/M)
tolerance: 0.5%

### w[{n}]?

::: misses
- [any] $0.54 - 0.46\cos(2\pi n/M)$.
:::
:::

::: part
answer: sin(c*pi*(n - M/2))/(pi*(n - M/2))*(0.54 - 0.46*cos(2*pi*n/M))
tolerance: 0.5%

### h[{n}]?

::: misses
- [any] Their product.
:::
:::
:::

::: check
kind: parts
given: d = 0.05 | 0.1 | 0.2

## A transition width of {d}π with fixed windows.

::: part
answer: 8/d
tolerance: 0.5%

### M for a Hamming window (main-lobe width)?

::: misses
- [any] 8π/M = Δω.
:::
:::

::: part
answer: 12/d
tolerance: 0.5%

### M for a Blackman window?

::: misses
- [any] 12π/M = Δω.
:::
:::
:::

::: check
kind: parts
given: a = 0.01 | 0.03; b = 0.001 | 0.0001; d = 0.06 | 0.12

## A lowpass needs δ₁ = {a}, δ₂ = {b}, transition {d}π.

::: part
answer: (-10*log(a*b) - 13)/(2.324*d*pi)
tolerance: 0.5%

### Equiripple order estimate?

::: misses
- [any] Kaiser's equiripple formula.
:::
:::

::: part
answer: (-20*log(b) - 8)/(2.285*d*pi)
tolerance: 0.5%

### Kaiser window order?

::: misses
- [any] A from δ₂.
:::
:::

::: part
answer: a/b
tolerance: 0.5%

### Weight ratio K?

::: misses
- [any] δ₁/δ₂.
:::
:::
:::

::: check
kind: parts
given: R = 0.1 | 0.5 | 1; b = 0.001 | 0.00003

## A specification with {R} dB passband ripple and stopband δ₂ = {b}.

::: part
answer: (10^(R/20) - 1)/(10^(R/20) + 1)
tolerance: 0.5%

### δ₁?

::: misses
- [any] $(10^{R/20} - 1)/(10^{R/20} + 1)$.
:::
:::

::: part
answer: -20*log(b)
unit: dB
tolerance: 0.05

### Stopband attenuation?

::: misses
- [any] $-20\log\delta_2$.
:::
:::
:::

::: check
kind: parts
given: M = 30 | 48 | 80

## An optimal Type I lowpass of order {M}.

::: part
answer: M/2 + 2
tolerance: 0

### Minimum alternations?

::: misses
- [any] L + 2.
:::
:::

::: part
answer: M/2 + 3
tolerance: 0

### Maximum (extraripple)?

::: misses
- [any] L + 3.
:::
:::

::: part
answer: M + 1
tolerance: 0

### Taps?

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

::: check
kind: parts
given: f = 0.75 | 3 | 7.5; s = 12 | 48; N = 256 | 2048; A = 1 | 0.2

## A tone of amplitude {A} at {f} kHz, sampled at {s} kHz, {N}-point DFT.

::: part
answer: s*1000/N
unit: Hz
tolerance: 0.5%

### Bin spacing?

::: misses
- [any] $f_s/N$.
:::
:::

::: part
answer: f*N/s
tolerance: 0.5%

### Bin index of the tone?

::: misses
- [any] $fN/f_s$.
:::
:::

::: part
answer: A*N/2
tolerance: 0.5%

### |X| at that bin, if it's an integer?

::: misses
- [any] AN/2.
:::
:::
:::

::: check
kind: parts
given: L = 7 | 9; m = 1 | 3; n = 0 | 2; let N = L + m

## Two length-{L} pulses of ones, convolved with {N}-point DFTs.

::: part
answer: 2*L - 1
tolerance: 0

### Smallest N with no wrap-around?

::: misses
- [any] 2L − 1.
:::
:::

::: part
answer: (L - abs(n - L + 1) + abs(L - abs(n - L + 1)))/2 + (L - abs(n + N - L + 1) + abs(L - abs(n + N - L + 1)))/2
tolerance: 0

### Circular output at n = {n}?

::: misses
- [any] Linear value plus the wrapped tail.
:::
:::
:::

::: check
kind: parts
given: L = 60 | 200 | 1000; P = 33 | 129

## Sequences of lengths {L} and {P}.

::: part
answer: L + P - 1
tolerance: 0

### Linear convolution length?

::: misses
- [any] L + P − 1.
:::
:::

::: part
answer: 2^ceil(log(L + P - 1)/log(2) - 0.0001)
tolerance: 0

### Smallest power-of-two FFT?

::: misses
- [any] Next power of two.
:::
:::
:::

::: check
kind: parts
given: N = 1024 | 4096; P = 100 | 300 | 600; s = 44.1 | 96

## Overlap-save with N = {N}, P = {P}, at {s} kHz.

::: part
answer: N - P + 1
tolerance: 0

### Outputs per block?

::: misses
- [any] N − P + 1.
:::
:::

::: part
answer: 4*(N*log(N)/log(2) + N)/(N - P + 1)
tolerance: 0.5%

### Multiplies per output (model)?

::: misses
- [any] $4(N\log_2N + N)/(N - P + 1)$.
:::
:::

::: part
answer: (N - P + 1)/s
unit: ms
tolerance: 0.5%

### Block latency?

::: misses
- [any] (N − P + 1)/f_s.
:::
:::
:::

::: check
kind: parts
given: X = 200000 | 1000000; N = 2048 | 8192; P = 257 | 1025

## Overlap-add over a {X}-sample signal, N = {N}, P = {P}.

::: part
answer: ceil(X/(N - P + 1) - 0.0001)
tolerance: 0

### Blocks?

::: misses
- [any] ⌈X/(N − P + 1)⌉.
:::
:::

::: part
answer: P - 1
tolerance: 0

### Samples of tail added into the next block?

::: misses
- [any] P − 1.
:::
:::
:::

::: check
kind: parts
given: x = 1 | 2; y = 3 | -1; z = 2 | 4; a = 1 | 0.5

## x = [{x}, {y}, {z}] convolved with h = [1, {a}].

::: part
answer: y + a*x
tolerance: 0.5%

### Linear output sample 1?

::: misses
- [any] $x_1 + ax_0$.
:::
:::

::: part
answer: x + a*z
tolerance: 0.5%

### Sample 0 of the 3-point circular convolution?

::: misses
- [any] The tail $a x_2$ wraps onto sample 0.
:::
:::
:::

::: check
kind: parts
given: d = 0.04 | 0.08 | 0.15

## A 44 dB lowpass has a {d}π transition.

::: part
answer: 8/d
tolerance: 0.5%

### What order does a Hann window need?

::: misses
- [any] $8\pi/\Delta\omega$.
:::
:::

::: part
answer: 36/(2.285*d*pi)
tolerance: 0.5%

### And a Kaiser window?

::: misses
- [any] $(A - 8)/(2.285\Delta\omega)$.
:::
:::
:::

::: check
kind: parts
given: L = 100 | 200; P = 30 | 90; N = 128 | 256

## Sequences of lengths {L} and {P} are convolved with {N}-point DFTs.

::: part
answer: (L + P - 1 - N)*step(L + P - 1 - N)
unit: samples
tolerance: 0

### How many outputs are corrupted by wraparound?

::: misses
- [any] L + P − 1 − N, or none.
:::
:::
:::

::: check
kind: parts
given: P = 64 | 512; f = 2 | 8; s = 8 | 48

## A {P}-tap filter runs by overlap-save with FFTs {f} times its length at {s} kHz.

::: part
answer: 4*(f*P*log(f*P)/log(2) + f*P)/(f*P - P + 1)
tolerance: 0.5%

### How many real multiplications per output?

::: misses
- [any] $4(N\log_2N + N)/(N - P + 1)$.
:::
:::

::: part
answer: P/(4*(f*P*log(f*P)/log(2) + f*P)/(f*P - P + 1))
tolerance: 0.5%

### How many times cheaper than direct convolution?

::: misses
- [any] P over that cost.
:::
:::
:::
:::
