# Example: Digital Lowpass Filter

Suppose we want to construct a digital filter with cutoff $$f_c$$ from a 2-pole Butterworth lowpass filter. Then start with its transfer function

$H(s) = \frac{1}{s^2 + \sqrt{2}s + 1}$

which has $$1$$ as the cutoff freqency.

In order for the transformation to work we need the cutoff to be $$\tan(a/2)$$ instead of $$1$$, where $$a = 2 \pi f_c / f_s$$. So we compute $$\omega = tan(\pi f_c/f_s)$$ and replace $$s$$ with $$s/\omega$$ so that the cutoff is at $$i\omega$$ instead of $$i$$. Then we perform a bilinear transform by replacing $$s$$ with $$\frac{z-1}{z+1}$$. We end up with

$H(z) = \frac{1}{\frac{1}{\omega^2} (\frac{z-1}{z+1})^2 + \sqrt{2} \frac{1}{\omega}\frac{z-1}{z+1} + 1} = \frac{z^2 + 2z + 1}{(\frac{1}{\omega^2} + \frac{\sqrt{2}}{\omega} + 1)z^2 + (2 - \frac{2}{\omega^2})z + (\frac{1}{\omega^2} - \frac{\sqrt{2}}{\omega} + 1)}$

So letting $$d = \frac{1}{\omega}$$, $$c = 1 /(d^2 + \sqrt{2}d + 1)$$, we have the filter coefficients:

$a_0 = c, a_1 = 2c, a_2 = c, b_1 = (2 - 2d^2)c, b_2 = (d^2 + 1 - \sqrt{2}d)c$

Ben Lynn blynn@cs.stanford.edu 💡