# Highpass filter design that is better than the moving difference filter

From Nguyen & Strang's Wavelets and Filter Banks:

Problem 4 Invent a highpass filter $$K$$ with three or four taps (coefficients) that is better than the moving difference $$H_1$$: the goal is $$| K (\omega) | < | H_1 (\omega) | \quad \text{ for } 0 < | \omega | < \frac{\pi}{2}$$ and $$| H_1 (\omega) | < | K (\omega) | < 1 \quad \text{ for } \frac{\pi}{2} < | \omega| < \pi.$$

We know that

$$H_1(\omega) = \frac12 \left( 1 - e^{-j\omega} \right) \\$$

$$\left| H_1 (\omega) \right| = \left| \sin \frac{\omega}{2} \right|$$

I'm not sure if the best way to tackle this is by going for an anti-symmetrical filter (4 taps, k1 = -k3, and k2 = -k4). Should I just assume coefficients until I actually meet the condition 1 stated? Or is there another approach? Perhaps setting an equation system to find out about h1 and h2 for K(w)?

Also, does condition 2 mean that for this interval of |W|, the filter needs to be invertible too?

• The simplest thing to try is to just place 3 zeros on the unit circle in the z-plane to create a 4 tap FIR filter: $(z-z_1)(z-z_2)(z-z_3)$. I would set $z_1 = 1$ to notch DC. The other two zeros would be complex conjugates $z_{(2,3)}= e^{\pm j\omega_z}$. Commented Mar 9, 2021 at 14:53

[ 0.25 -0.6035 0.25 0.1035] seems to work.

Here is how I did that: Since the "breakeven point" is specified at $$\pi/2$$, we know that $$|K(0)|^2 = 0$$, $$|K(\pi/2)|^2 = 0.5$$ , and $$|K(\pi)|^2 = 1$$ . The magnitude of the spectrum is thus given at 4 different points. DC and Nyquist are real and we have a conjugate complex pair at $$\omega = \pi/2$$. We can use this to populate a 4 point frequency domain vector and perform an inverse FFT to get a 4 tab impulse response.

The only thing we don't know is the phase at $$\omega = \pi/2$$. A highpass filter generally has a falling phase and the phase should be zero at Nyquist. Hence we should interpret the phase at DC to be 180 degrees and so it's reasonable to guess the phase at $$\omega = \pi/2$$ half way in between and, $$\phi = -\pi/2$$ seems like a reasonable first guess.

y = ifft([0 .707i 1 -.707i].');


You can play around with the phase and see if it can be made better (whatever that means), but given the amplitude constraints, any 4-tab solution must more or less look this way in the frequency domain.

EDIT

Turns out a phase of 75 degrees gives optimum performance in a sense that it both maximizes the gain at $$\omega =3\pi/4$$ and minimizes the gain at $$\omega =\pi/4$$

• Thanks so much for this Hilmar. I'm curious, did you arrive to this solution analytically? Or did you find it by plotting the phase and module of the transfer function? Commented Apr 2, 2021 at 13:54
• I did a quick numerical search. You can certainly do it analytically as well: Express the magnitude as a function of the phase at $\omega = \pi/2$, then maximize for any convenient frequency above $\pi/2$ or minimize for any frequency below $pi/2$. However that was more algebra that I was willing to do. If you are interested in a more detailed outline on how to do this, ask another follow up question. Commented Apr 3, 2021 at 12:31