-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbilinear-filter-notes.tex
More file actions
359 lines (306 loc) · 17.6 KB
/
bilinear-filter-notes.tex
File metadata and controls
359 lines (306 loc) · 17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
\documentclass[a4paper]{article}
% https://www.writelatex.com/1267010tfjbxp#/3080075/
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage[margin=3cm]{geometry}
\usepackage{hyperref}
\title{Bilinear filter math notes}
\author{Kendrick, Ace, Eric}
\date{\today}
\begin{document}
\maketitle
Following Numerical Recipes 3rd ed. by Press et al,
\begin{equation}
z = e^{-2\pi i f \Delta} = \frac{1+iw}{1-iw} \label{eq:z}
\end{equation}
or equivalently
\begin{equation}
w = i \left(\frac{1-z}{1+z}\right) \label{eq:w}
\end{equation}
Where $\Delta$ is our sampling interval.
This implies
\begin{equation}
w \equiv \tan(\pi f \Delta).
\end{equation}
We can describe a digital filter as
\begin{equation}
y_n = \sum^{M}_{k=0} c_k x_{n-k} + \sum^{N-1}_{j=0} d_j y_{n-j-1}.
\end{equation}
Expanding this equation for $N=2$, we have
\begin{equation}
y_n = c_0 x_n + c_1 x_{n-1} + c_2 x_{n-2} + d_0 y_{n-1} + d_1 y_{n-2}.\label{eq:expanded_coeficients}
\end{equation}
Knowing the coefficients $c_k$ and $d_j$ we can calculate the filter's response to a given frequency as
\begin{equation}
\mathcal{H}(f) = \frac{\sum^{M}_{k=0} c_k e^{-2\pi i k f \Delta}}{1-\sum^{N-1}_{j=0} d_j e^{-2\pi i (j+1) f \Delta}}.
\end{equation}
We can rewrite this in terms of $z$ as
\begin{equation}
\mathcal{H}(f) = \frac{\sum^{M}_{k=0} c_k z^{-k}}{1-\sum^{N-1}_{j=0} d_j z^{-(j+1)}},
\end{equation}
or for $N=M=2$,
\begin{equation}
\mathcal{H}(f) = \frac{c_0 + c_1 z^{-1} + c_2 z^{-2}}{1 - d_0 z^{-1} - d_1 z^{-2}}.\label{eq:freq_response}
\end{equation}
\section{2nd Order Bandpass Filter}
We can design the amplitude of a filter response function $\mathcal{H}$ for a band pass filter as
\begin{equation}
|\mathcal{H}(f)|^2 = \left(\frac{w^2}{w^2 + a^2}\right)\left(\frac{b^2}{w^2 + b^2}\right).
\end{equation}
where
\begin{equation}
a = \tan(\pi f_\textrm{high} \Delta)
\end{equation}
is our high pass cutoff, and
\begin{equation}
b = \tan(\pi f_\textrm{low} \Delta)
\end{equation}
is our low pass filter.
For example, we could choose
\begin{equation}
\mathcal{H}(f) = \left(\frac{w}{w - ia}\right)\left(\frac{ib}{w - ib}\right).\label{eq:filter_choice}
\end{equation}
We can re-write this as
\begin{align}
\mathcal{H}(f) & = \left(\frac{i \left(\frac{1-z}{1+z}\right)}{i \left(\frac{1-z}{1+z}\right) - ia}\right)\left(\frac{ib}{i \left(\frac{1-z}{1+z}\right) - ib}\right) \\
& = \left(\frac{ \left(\frac{1-z}{1+z}\right)}{ \left(\frac{1-z}{1+z}\right) - a}\right)\left(\frac{b}{\left(\frac{1-z}{1+z}\right) - b}\right) \\
& = \left(\frac{\left(1-z\right)}{ \left(1-z\right) - a(1+z)}\right)\left(\frac{b\left(1+z\right)}{\left(1-z\right) - b\left(1+z\right)}\right) \\
& = \left(\frac{1-z}{ 1-z - a -az }\right)\left(\frac{b+bz}{1-z- b-bz}\right) \\
& = \frac{b + bz -zb -bz^2}{1 - z - b - bz -z + z^2 +zb + bz^2 -a +za +ab + abz -az + az^2 + azb + abz^2 } \\
& = \frac{b-bz^2}{1 -b -a +ab -2z +2abz +az^2 + abz^2 +z^2 +bz^2} \\
& = \frac{b-bz^2}{(1 -b -a +ab) - (2 +2ab)z + (a + ab + 1 +b )z^2} \\
& = \frac{b-bz^2}{(1-a)(1-b) - (2 +2ab)z + (1 + a)(1 + b)z^2} \\
& = \frac{bz^{-2}-b}{(1-a)(1-b)z^{-2} - (2 +2ab)z^{-1} + (1 + a)(1 + b)} \\
& = \frac{-\frac{b}{(1 + a)(1 + b)}+\frac{b}{(1 + a)(1 + b)}z^{-2}}{ \frac{(1-a)(1-b)}{(1 + a)(1 + b)}z^{-2} - \frac{2 +2ab}{(1 + a)(1 + b)}z^{-1} + 1} \\
& = \frac{-\frac{b}{(1 + a)(1 + b)} + (0) z^{-1} + \frac{b}{(1 + a)(1 + b)}z^{-2}}{1 - \frac{2 +2ab}{(1 + a)(1 + b)}z^{-1} - \left(-\frac{(1-a)(1-b)}{(1 + a)(1 + b)}\right)z^{-2}}
\end{align}
Comparing this to (\ref{eq:freq_response}), we have
\begin{align}
c_0 &= -\frac{b}{(1 + a)(1 + b)} \label{eq:c0}\\
c_1 &= 0 \\
c_2 &= \frac{b}{(1 + a)(1 + b)} \\
d_0 &= \frac{2 +2ab}{(1 + a)(1 + b)} \\
d_1 &= -\frac{(1-a)(1-b)}{(1 + a)(1 + b)} \label{eq:d1}
\end{align}
\section[High Pass Filter]{High Pass Filter of order $2 n$}
The high pass cutoff of the above bandpass filter is unfortunately not very
steep. To make a more selective filter we can choose a squared
amplitude response with a steeper cut off, for example the response of a $2n$-th order butterworth filter (a filter with a maximally flat response in the the passband, see \url{http://en.wikipedia.org/wiki/Butterworth_filter} and perhaps \url{http://www.recordingblogs.com/sa/tabid/88/Default.aspx?topic=Butterworth+filter})
\begin{align}
|\mathcal{H}(f)|^2 &= \frac{w^{4n}}{w^{4n} + a^{4n}}.
\end{align}
(Note that for a true Butterworth filter this should be written in terms of the frequency $\omega$ rather than our transformed frequency $w$; by using $w$ (which goes to infinity as $w$ goes to the Nyquest frequency) our filter will be compressed as the frequency approaches the Nyquest frequency, and thus have a cut-in that is sharper and earlier than a true Butterworth filter.)
We will next find a function $\mathcal{H}(f)$ that has this squared amplitude
and has poles (roots in the denominator) with positive imaginary components,
which is required for stability of the filter.
Note that the denominator will be zero when $w^{4n} = -a^{4n} = (-1)^{4n}
a^{4n}$, i.e. it is a polynomial whose roots are the product of each of the
$4n$ roots of $-1$ with the conventional (positive real) $4n$-th root of $a$.
Similarly, the numerator's roots are all $0$. We can use these observations to
factor the amplitude response as follows:
\begin{align}
|\mathcal{H}(f)|^2 &= \frac{w^{4n}}{w^{4n} + a^{4n}} \label{eq:high_pass_factor1}\\
&= \frac{\prod_{j=0}^{4 n - 1}(w - 0)}{\prod_{j=0}^{4 n - 1}\left(w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)\right)} \qquad\textrm{(see section \ref{roots})} \label{eq:high_pass_factor2}\\
&= \prod_{j=0}^{4 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{j=2n}^{4 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{k=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 (4 n - 1 - k))}{4 n}\right)}\right) \\
&= \prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{k=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (8n - 1 - 2 k)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{k=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi 8 n}{4 n} + \frac{i \pi (- 1 - 2 k)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{k=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(i 2 \pi\right) \exp\left(\frac{i \pi (- 1 - 2 k)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{k=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{-i \pi (1 + 2 k)}{4 n}\right)}\right) \\
&= \left(\prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)\right)
\left(\prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)\right)^{*}\label{eq:highpass_factor_n}.
\end{align}
Note that the first term is a rational function of $w$ whose poles (roots of
the denominator) all lie above the real axis as required for stability. The
second term is simply the complex conjugate of the first term. We thus choose
\begin{align}
\mathcal{H}(f) &= \prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right).
\end{align}
We now factor this function into quadratic terms, as cascaded quadratic filters
can be more stable than a single higher order filter of the same total order.
To do this, we note the symmetry of the roots across the imaginary axis and
pair each root with its mirror.
\begin{align}
\mathcal{H}(f) &= \prod_{j=0}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{j=n}^{2 n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{k=0}^{n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 (2 n - 1 - k)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{k=0}^{n - 1} \left(\frac{w}{w - a\exp\left(i \pi-\frac{i \pi (1 + 2 k)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{n - 1} \left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\prod_{k=0}^{n - 1} \left(\frac{w}{w + a\exp\left(-\frac{i \pi (1 + 2 k)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{n - 1}
\left(\frac{w}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)
\left(\frac{w}{w + a\exp\left(-\frac{i \pi (1 + 2 j)}{4 n}\right)}\right) \\
&= \prod_{j=0}^{n - 1}
\frac{w^2}{w^2 - w a \left(\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right) -
\exp\left(-\frac{i \pi (1 + 2 j)}{4 n}\right)\right) - a^2} \label{eq:high_pass_quadratic1} \\
&= \prod_{j=0}^{n - 1}
\frac{w^2}{w^2 - 2 i w a \sin\left(\frac{\pi (1 + 2 j)}{4 n}\right) - a^2} \qquad\textrm{(see section \ref{sin})}. \label{eq:high_pass_quadratic2}
\end{align}
For convenience, we let $\alpha = a^2$ and $\gamma_j = 2 a \sin\left(\frac{\pi (1 + 2 j)}{4 n}\right)$, and thus
\begin{align}
\mathcal{H}(f) &= \prod_{j=0}^{n - 1}\frac{w^2}
{w^2 - i w \gamma_j - \alpha}\label{eq:highpass_before_z}.
\end{align}
We next rewrite this equation in terms of $z$, so that
\begin{align}
\mathcal{H}(f) &= \prod_{j=0}^{n - 1}\frac{w^2}
{w^2 - i w \gamma_j - \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{\left(i\left(\frac{1 - z}{1 + z}\right)\right)^2}
{\left(i\left(\frac{1 - z}{1 + z}\right)\right)^2 - i \left(i\left(\frac{1 - z}{1 + z}\right)\right) \gamma_j - \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{-\left(\frac{1 - z}{1 + z}\right)^2}
{-\left(\frac{1 - z}{1 + z}\right)^2 + \left(\frac{1 - z}{1 + z}\right) \gamma_j - \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{\left(\frac{1 - z}{1 + z}\right)^2}
{\left(\frac{1 - z}{1 + z}\right)^2 - \left(\frac{1 - z}{1 + z}\right) \gamma_j + \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{(1 - z)^2}
{(1 - z)^2 - (1 - z)(1 + z) \gamma_j + (1 + z)^2 \alpha}.
\end{align}
Continuing with these new variables, we have
\begin{align}
\mathcal{H}(f) &= \prod_{j=0}^{n - 1}\frac{(1 - z)^2}
{(1 - z)^2 - \gamma_j (1 - z)(1 + z) + (1 + z)^2 \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{1 - 2z + z^2}
{1 - 2z + z^2 - \gamma_j + \gamma_j z^2 + \alpha + 2z \alpha + z^2 \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{z^2 - 2z + 1}
{(1 + \alpha + \gamma_j)z^2 + 2(\alpha - 1) z + (1 + \alpha - \gamma_j)} \\
&= \prod_{j=0}^{n - 1}\frac{1 - 2z^{-1} + z^{-2}}
{(1 + \alpha + \gamma_j) + 2(\alpha - 1) z^{-1} + (1 + \alpha - \gamma_j) z^{-2}} \\
&= \prod_{j=0}^{n - 1}\frac{1 - 2z^{-1} + z^{-2}}
{(1 + \alpha + \gamma_j) - 2(1 - \alpha) z^{-1} - (\gamma_j - \alpha - 1)z^{-2}}\\
&= \prod_{j=0}^{n - 1}\frac{\frac{1}{1 + \alpha + \gamma_j} + \frac{-2}{1 + \alpha + \gamma_j}z^{-1} + \frac{1}{1 + \alpha + \gamma_j}z^{-2}}
{1 - \frac{2(1 - \alpha)}{1 + \alpha + \gamma_j} z^{-1} - \frac{(\gamma_j - \alpha - 1)}{1 + \alpha + \gamma_j}z^{-2}}.
\end{align}
We compare this with (\ref{eq:freq_response}),
\begin{equation*}
\mathcal{H}(f) = \frac{c_0 + c_1 z^{-1} + c_2 z^{-2}}{1 - d_0 z^{-1} - d_1 z^{-2}},
\end{equation*}
we have
\begin{align}
c_{j,0} &= \frac{1}{1 + \alpha + \gamma_j} \\
c_{j,1} &= -\frac{2}{1 + \alpha + \gamma_j} \\
c_{j,2} &= \frac{1}{1 + \alpha + \gamma_j} \\
d_{j,0} &= \frac{2-2\alpha}{1 + \alpha + \gamma_j} \\
d_{j,1} &= \frac{\gamma_j - \alpha - 1}{1 + \alpha + \gamma_j}.
\end{align}
\section{LowPass}
A lowpass filter can be derived by taking 1 minus the highpass filter:
\begin{align}
|\mathcal{H}(f)|^2 &= 1 - \frac{w^{4n}}{w^{4n} + a^{4n}} = \frac{w^{4n} + a^{4n}}{w^{4n} + a^{4n}} - \frac{w^{4n}}{w^{4n} + a^{4n}} = \frac{a^{4n}}{w^{4n} + a^{4n}}
\end{align}
We note that the denominator is the same as equation (\ref{eq:high_pass_factor1}) and the numerator is in terms of $a$ rather than $w$. Thus we can transform it directly to a form similar to (\ref{eq:highpass_factor_n}):
\begin{align}
|\mathcal{H}(f)|^2
&= \left(\prod_{j=0}^{2 n - 1} \left(\frac{a}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)\right)
\left(\prod_{j=0}^{2 n - 1} \left(\frac{a}{w - a\exp\left(\frac{i \pi (1 + 2 j)}{4 n}\right)}\right)\right)^{*}\label{eq:lowpass_factor_n}.
\end{align}
From there we see that we can skip ahead to a form similar to (\ref{eq:highpass_before_z}); letting $\alpha = a^2$ and $\gamma_j = 2 a \sin\left(\frac{\pi (1 + 2 j)}{4 n}\right)$, and thus
\begin{align}
\mathcal{H}(f) &= \prod_{j=0}^{n - 1}\frac{\alpha }
{w^2 - i w \gamma_j - \alpha}\label{eq:lowpass_before_z}.
\end{align}
Again, next rewrite this equation in terms of $z$, so that
\begin{align}
\mathcal{H}(f) &= \prod_{j=0}^{n - 1}\frac{\alpha }
{w^2 - i w \gamma_j - \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{\alpha }
{\left(i\left(\frac{1 - z}{1 + z}\right)\right)^2 - i \left(i\left(\frac{1 - z}{1 + z}\right)\right) \gamma_j - \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{\alpha }
{-\left(\frac{1 - z}{1 + z}\right)^2 + \left(\frac{1 - z}{1 + z}\right) \gamma_j - \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{-\alpha }
{\left(\frac{1 - z}{1 + z}\right)^2 - \left(\frac{1 - z}{1 + z}\right) \gamma_j + \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{-\alpha (1 + z)^2}
{(1 - z)^2 - (1 - z)(1 + z) \gamma_j + (1 + z)^2 \alpha}.
\end{align}
Continuing with these new variables, we have
\begin{align}
\mathcal{H}(f) &= \prod_{j=0}^{n - 1}\frac{-\alpha (1 + z)^2}
{(1 - z)^2 - \gamma_j (1 - z)(1 + z) + (1 + z)^2 \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{-\alpha - 2\alpha z - \alpha z^2}
{1 - 2z + z^2 - \gamma_j + \gamma_j z^2 + \alpha + 2z \alpha + z^2 \alpha} \\
&= \prod_{j=0}^{n - 1}\frac{-\alpha z^2 - 2\alpha z - \alpha }
{(1 + \alpha + \gamma_j)z^2 + 2(\alpha - 1) z + (1 + \alpha - \gamma_j)} \\
&= \prod_{j=0}^{n - 1}\frac{-\alpha - 2\alpha z^{-1} - \alpha z^{-2}}
{(1 + \alpha + \gamma_j) + 2(\alpha - 1) z^{-1} + (1 + \alpha - \gamma_j) z^{-2}} \\
&= \prod_{j=0}^{n - 1}\frac{(-\alpha ) + (-2\alpha ) z^{-1} + (-\alpha )z^{-2}}
{(1 + \alpha + \gamma_j) - 2(1 - \alpha) z^{-1} - (\gamma_j - \alpha - 1)z^{-2}}\\
&= \prod_{j=0}^{n - 1}\frac{\frac{-\alpha }{1 + \alpha + \gamma_j} + \frac{-2 \alpha }{1 + \alpha + \gamma_j}z^{-1} + \frac{-\alpha }{1 + \alpha + \gamma_j}z^{-2}}
{1 - \frac{2(1 - \alpha)}{1 + \alpha + \gamma_j} z^{-1} - \frac{(\gamma_j - \alpha - 1)}{1 + \alpha + \gamma_j}z^{-2}}.
\end{align}
We compare this with (\ref{eq:freq_response}),
\begin{equation*}
\mathcal{H}(f) = \frac{c_0 + c_1 z^{-1} + c_2 z^{-2}}{1 - d_0 z^{-1} - d_1 z^{-2}},
\end{equation*}
we have
\begin{align}
c_{j,0} &= -\frac{\alpha }{1 + \alpha + \gamma_j} \\
c_{j,1} &= -\frac{2 \alpha }{1 + \alpha + \gamma_j} \\
c_{j,3} &= -\frac{\alpha }{1 + \alpha + \gamma_j} \\
d_{j,0} &= \frac{2-2\alpha}{1 + \alpha + \gamma_j} \\
d_{j,1} &= \frac{\gamma_j - \alpha - 1}{1 + \alpha + \gamma_j}.
\end{align}
\section{Stability}
Per Press et all, an IIR filter is only stable if all roots of
\begin{equation}
z^N - \sum^{N-1}_{j=0} d_j z^{(N-1)-j} = 0,\label{eq:stability}
\end{equation}
or in case with $N=2$
\begin{equation}
z^2 - (d_0 z + d_1) = 0,
\end{equation}
or equivalently
\begin{equation}
z^2 - d_0 z - d_1 = 0,
\end{equation}
lie withing the unit circle.
\section{Notes}
\subsection{Roots}
\label{roots}
Explanation of equation \ref{eq:high_pass_factor1} to \ref{eq:high_pass_factor2}:
$w^4 - a = 0$
$w^4 = a$
4 roots of $w^4$
$w = \sqrt[4]{a}$
$w = -\sqrt[4]{a}$
$w = i\sqrt[4]{a}$
$w = -i\sqrt[4]{a}$
Or, in general:
$w = \sqrt[4]{1}\sqrt[4]{a}$
$w = \exp(i 2 \pi k/4)\sqrt[4]{a}$
Also works for the nth power:
$w^n - a = 0$
$w = \exp(i 2 \pi k/n)\sqrt[n]{a}$
And for $w^n + a$ (rather than -a)
$w^n + a = 0$
$w^n - (-a) = 0$
$w = \exp(i 2 \pi k/n)\sqrt[n]{-a}$
$w = \exp(i 2 \pi k/n)\sqrt[n]{-1}\sqrt[n]{a}$
$w = \exp(i 2 \pi k/n)\exp(i \pi/n) \sqrt[n]{a}$
$w = \exp(i \pi (1 + 2 k)/n)\sqrt[n]{a}$
\subsection{Sine}
\label{sin}
Explanation of equation \ref{eq:high_pass_quadratic1} to \ref{eq:high_pass_quadratic2}:
$\sin(\theta) = \frac{e^{i \theta} - e^{-i\theta}}{2 i}$
$\exp(i\theta) = \cos(\theta) + i \sin(\theta)$
$\exp(-i\theta) = \cos(-\theta) + i \sin(-\theta)
= \cos(\theta) - i \sin(\theta)$
$\exp(i\theta) - \exp(-i\theta) = \cos(\theta) + i \sin(\theta) - (\cos(\theta) - i \sin(\theta)) = 2 i \sin(\theta)$
\section{todo}
\begin{itemize}
\item Restate (\ref{eq:expanded_coeficients}) in terms of (\ref{eq:c0})-(\ref{eq:d1})
\item Expand steps between (\ref{eq:z})-(\ref{eq:w})
\item Make choice of (\ref{eq:filter_choice}) less mysterious based on stability.
\item Explain stability criterion (\ref{eq:stability})
\item Add section on low pass filter of order $4n$.
\end{itemize}
\end{document}