# Differences in transforming a sinc FIR filter from lowpass to highpass using spectral inversion and spectral reversal

I have designed a lowpass sinc 1023 tap FIR filter with a Blackman window and this works fine.

I understand there are then two ways to transform this lowpass filter to a highpass one.

One is spectral inversion where you invert every coefficient and add 1 to the centre coefficient. https://tomroelandts.com/articles/how-to-create-a-simple-high-pass-filter

The other is spectral reversal where you invert every other coefficient but only after generating a new lowpass filter with the frequency reflected about Fsample/2. https://tomroelandts.com/articles/spectral-reversal-to-create-a-high-pass-filter

Both methods work well, giving similar though not quite identical results in the passband. But the stopbands are quite different, with spectal reversal having much deeper rejection in the stopband. However I cannot find any literature explaining why there is a difference. Any suggestions on why the two methods are different or where I can read up more about them ? Thanks in advance.

• I have no experience on this topic, but I would suggest looking at rounding errors. With so many taps, you're likely to have a large dynamic range in the coefficients, leading to potential errors when you do arithmetic on them.
– MBaz
May 11 '21 at 1:14
• i think you need to be more clear here: " invert every coefficient and add 1 to the centre coefficient." Do you mean negate every coefficient and add 1 to the center coefficient? May 11 '21 at 1:51
• Yes negate every coefficient. May 11 '21 at 9:14

• The spectral inversion changes the original passband into stopband and the original stopband into passband.

• The spectral reversal left shifts the frequency response $$H(e^{j\omega})$$ by $$\pi$$, which looks like a frequency reflection. Simple proof: $$\mathcal{Z} \{ (-1)^nh(n) \} = \sum_{n=-\infty}^{\infty} (-1)^nh(n) z^{-n} = \sum_{n=-\infty}^{\infty} h(n) (-z)^{-n} = H(-z)$$ Substituting $$z=e^{j\omega}$$ into it and we have the frequency response $$H(-e^{j\omega}) = H(e^{j(\omega+\pi)})$$ In other words, the original lowpass filter and its spectral reversed highpass filter have different cutoff frequencies unless they are respectively halfband lowpass and highpass filters.

• If you set the cutoff frequency to be $$\omega_c=0.5\pi$$, these two methods give quite similar results.

N = 1023;
n = (0:N-1) - (N-1)/2;
fc = 0.25; % cutoff frequency = 0.5
h = 2*fc*sinc(2*fc*n) .* hann(N).'; % windowed sinc function
figure; freqz(h)

h_inv = -h; % spectral inversion
h_inv((N+1)/2) = h_inv((N+1)/2) + 1;
figure; freqz(h_inv)

h_rev = h.* (-1).^n;  % spectral reversal
figure; freqz(h_rev)

• That explains it well and fits what I was observing. I was worried I had some programming error but it seems not. May 11 '21 at 9:15

This answer is gonna come in installments.

First consider the ideal $$\operatorname{sinc}(\cdot)$$ filter, which in the frequency domain is an ideal brickwall. We'll do this in normalized angular frequency, $$\omega$$.

Let

$$H_\mathrm{LPF}(e^{j\omega}) = \begin{cases} 1, \qquad |\omega| < \omega_0 \\ 0, \qquad \omega_0 < |\omega| \le \pi \\ \end{cases}$$

and define the frequency response outside of $$\pm\pi$$ to be periodic:

$$H_\mathrm{LPF}(e^{j(\omega+2\pi)}) = H_\mathrm{LPF}(e^{j\omega}) \qquad \forall \omega \in \mathbb{R}$$

This will have impulse response of

$$h_\mathrm{LPF}[n] = \frac{\omega_0}{\pi} \operatorname{sinc}\left( \frac{\omega_0}{\pi} n \right)$$

Now, if you make a high-pass filter by subtracting the low-pass from a wire:

$$H_\mathrm{HPF}(e^{j\omega}) = 1 - H_\mathrm{LPF}(e^{j\omega})$$

Then the cutoff frequency remains the same $$\omega_0$$ and the impulse response is

\begin{align} h_\mathrm{HPF}[n] &= \delta[n] - h_\mathrm{LPF}[n] \\ & = \delta[n] - \frac{\omega_0}{2} \operatorname{sinc}\left( \frac{\omega_0}{\pi} n \right) \\ \end{align}

Now, suppose you make a high-pass filter by heterodyning the low-pass from DC to Nyquist:

$$H_\mathrm{HPF}(e^{j\omega}) = H_\mathrm{LPF}(e^{j(\pi+\omega)})$$

Then the cutoff frequency becomes $$\pi-\omega_0$$ and the impulse response is

\begin{align} h_\mathrm{HPF}[n] &= (-1)^n h_\mathrm{LPF}[n] \\ & = (-1)^n \frac{\omega_0}{\pi} \operatorname{sinc}\left( \frac{\omega_0}{\pi} n \right) \\ \end{align}

So, if we harmonize the two definitions of the cutoff frequencies, the two brick-wall high-pass filters will be identical in the frequency domain, so they should in the time domain. But that would mean that

\begin{align} \delta[n] - \frac{\omega_0}{\pi} \operatorname{sinc}\left( \frac{\omega_0}{\pi} n \right) &\stackrel{?}{=} (-1)^n \frac{\pi - \omega_0}{\pi} \operatorname{sinc}\left( \frac{\pi-\omega_0}{\pi} n \right) \\ \\ &= (-1)^n \frac{\pi - \omega_0}{\pi} \frac{\sin\left( \pi \frac{\pi-\omega_0}{\pi} n \right)}{\pi \frac{\pi-\omega_0}{\pi} n} \qquad & (n \ne 0) \\ \\ &= (-1)^n \ \frac{\sin\big( (\pi - \omega_0) n \big)}{\pi n} \qquad & (n \ne 0) \\ \\ &= (-1)^n \ \frac{\sin(\pi n)\cos(\omega_0 n) - \cos(\pi n)\sin(\omega_0 n)}{\pi n} \qquad & (n \ne 0) \\ \\ &= (-1)^n \ \frac{0\cos(\omega_0 n) - (-1)^n\sin(\omega_0 n)}{\pi n} \qquad & (n \ne 0) \\ \\ &= (-1)^n \ \frac{- (-1)^n \ \sin\left(\pi\frac{\omega_0}{\pi} n\right)}{\pi n} \qquad & (n \ne 0) \\ \\ &= \frac{- \sin\left(\pi\frac{\omega_0}{\pi} n\right)}{\pi n} \qquad & (n \ne 0) \\ \\ &= -\frac{\omega_0}{\pi} \frac{\sin\left(\pi\frac{\omega_0}{\pi} n\right)}{\pi \frac{\omega_0}{\pi} n} \qquad & (n \ne 0) \\ \\ &= -\frac{\omega_0}{\pi} \operatorname{sinc}\left(\frac{\omega_0}{\pi} n \right) \qquad & (n \ne 0) \\ \end{align}

So I guess it's true, because you can also show that equally exists for the case of $$n=0$$.

• interesting thought process! I hope you continue... May 14 '21 at 18:42
• The relationship seems to hold even when you make it causal by truncating and shifting the sinc and shifting the impulse accordingly (importantly). Very interesting! May 14 '21 at 19:37
• thanks @DanBoschen, i actually forgot about this. often something interrupts me from finishing these things but there should be a consistent result if the lowpass and highpass are brick walls. i actually need to verify some of my equations. May 15 '21 at 2:25
• Once you complete it, it will forever be known as Bristow-Johnson’s Identity May 15 '21 at 2:56
• No, we used to make HPFs by subtracting an LPF from a wire. with these brick walls it should just add up, but it's not exactly right. i am not sure what's wrong. May 15 '21 at 3:05