# Notch Filter via Bernstein Polynomial

Context:

In the review article , the authors explain that we can model the frequency response of an FIR notch filter using Bernstein polynomials.

The paper shows the details, but at the end of it, they come up with the frequency response as:

$$H(\omega) = \sum_{i=0}^{n} a_{i} \left( \text{cos}(\omega) \right)^{i}$$

where $$n$$ is the filter order and the $$a_i$$ are found via:

$$a_i = 2^{-n} \left[ 2^{n} \binom{0}{i} + \sum_{k=L+1}^{n} (-1)^{k+i-L} 2^{n+1-k} \binom{n}{k} \binom{k-1}{L} \binom{k}{i} \right]$$

where $$L$$ is a design parameter that determines the location of the notch frequency $$\omega_d$$.

Question:

My question is -- how can we convert this into an FIR filter?

For instance, the zero-phase frequency response of an FIR filter is given by:

$$H(\omega) = \sum_{i=0}^{n} a_i \text{cos}\left( i \omega \right)$$

and then the coefficients of the FIR filter $$h_0, h_1, \ldots, h_n$$ are given by $$h_0 = a_0$$, and $$h_{n-i} = \frac{a_i}{2}$$.

Is there a simple mapping of response-to-coefficients for the form given in the article, but for causal and linear phase filters (such as given in )? If so, what is it?

In general, how can we convert the Bernstein frequency response model into an FIR filter? Must we sample $$H(\omega)$$ and then perform an inverse DFT (the interpolation approach given in ), or is there a closed form solution?

Opinion: It seems to me that there has to be, or else, why would you go through all the trouble to construct $$H(\omega)$$ using a Bernstein polynomial, when you could just specify it using a discontinuous function and window the resulting filter coeffs after taking the inverse DFT? Perhaps just because Bernstein polynomials are smooth, and so, we can just take an inverse DFT and avoid having to fool around with choosing the right window or sampling density/filter length?

References:

 S. Chandra, D. Roy, B. Kumar and S. B. Jain, "FIR Notch Filter Design -- A Review", Electronics and Energetics, vol. 14, no. 3, Dec. 2001, pp. 295-327

 I. Selesnick, "LINEAR-PHASE FIR FILTERS", Url: https://eeweb.engineering.nyu.edu/iselesni/EL713/zoom/linphase.pdf

• Are you constraining this to zero phase FIR filters? I.e. filters that are non-causal and where $h[-n] = h[n]$ ? Jul 21 at 15:30
• No I was just using it as an example. I'd rather have something linear phase causal. I'll update my question. Jul 21 at 15:35
• Maybe this me being stupid: why don't you just take your zero-phase filter and time shift it to make it causal an linear phase? It will have the same magnitude response. Jul 21 at 17:11
• @Hilmar I mean, fair enough -- but the problem is, the definition of $H(w)$ computed from the Bernstein polynomial is not the same as the standard one that is typically used: $cos(w)^i$ vs $cos(iw)$. So I don't know how to compute the coefficients $h_n$ from this response, even if we enforced zero-phase. The best I can think of is doing an inverse DFT on the sampled $H(w)$ response, but, that has its own problems (long filter order required to avoid ripples in the approximated response for example). So I want to find a closed form solution for the $h_n$. Jul 21 at 17:13
• If your FIR coefficients are real numbers, why not just save all of us headache and call it a "zero-phase FIR" and pretend we can see $\frac{n}2$ samples into the future? Jul 21 at 18:54

Note that the frequency response

$$H(\omega)=\sum_{k=0}^na_k[\cos(\omega)]^k\tag{1}$$

is real-valued and even, and, consequently, the corresponding impulse response is also real-valued and even, i.e., it's a zero-phase type I FIR filter.

The frequency response $$(1)$$ can also be written in the form

$$H(\omega)=\sum_{k=0}^nb_k\cos(k\omega)\tag{2}$$

The relationship between the coefficients $$a_k$$ and $$b_k$$ can be derived via the Chebyshev polynomials of the first kind:

$$\cos(k\omega)=T_k\big(\cos(\omega)\big)\tag{3}$$

From $$(3)$$ we can express the powers $$[\cos(\omega)]^k$$ as weighted sums of expressions $$\cos(l\omega)$$, $$l=0,\ldots,k$$. The exact formula is given on the wikipedia page on Chebyshev polynomials.

However, the easiest and probably also most efficient way to compute the filter coefficients from representation $$(1)$$ is to evaluate $$(1)$$ on an appropriate grid and use an inverse DFT (of course, implemented as an FFT).

• This is a decent answer. I can definitely take it from here. I figured that the FFT version would give the best tradeoff between efficiency and accuracy, as the smoothness of the Bernstein polynomials implies a quickly decaying IFFT, which means that we will be able to get away with a smaller filter length for a given error tolerance than if we were to IFFT the ideal discontinuous notch design. Jul 22 at 12:52
• Have you guys noticed that Matt's Eq (1) is not the same as the OP? Both use $a_i$ as coefficients m Jul 22 at 14:16
• @robertbristow-johnson: What's the difference? Jul 22 at 14:34
• under the word "Question" Jul 22 at 14:42
• @robertbristow-johnson: My first equation corresponds to the first equation in the OP, and the second one is the one you seem to be referring to. Of course, it would have been better to use a different symbol for the coefficients in both equations. But the basic problem is converting the representation using powers of $\cos(\omega)$ into a representation using a weighted sum of $\cos(k\omega)$, and this is what my answer addresses. Jul 22 at 15:36