# Ideal high pass filter for discrete signal

there. I currently get stuck on a question. I was asking to find an inverse discrete-time Fourier transform for the ideal high pass filter. Here is the question It is getting more confused after I read the second solution of this post How to produce a high-pass filter from a low-pass one?

It tends out I can either calculate it by time-shifting property Or I can calculate it through the definition But they lead to a different result. My textbook solution said the second one is correct. But I cannot find any problem with the first one.

If we assume $$\ 0 \le n < N-1$$ for $$h[n]$$, using N = 61, $$\alpha =30$$, cutoff analog frequency $$=1500Hz$$. (Assume the sampling rate $$=44100 Hz$$ )

I got these two graphs:

(for first solution)

and

(for the second)

Here are my codes

I really don't know why they lead to different results.

• What do you get if you plot the FFT of each? What happens if you use a different $\omega_c$? Apr 9 '20 at 11:46
• I will try, although I haven't learnt FFT yet.
– JACK
Apr 9 '20 at 11:51
• It looks like Matlab/Octave code, so just plot abs(fft(h,1024)), or whatever number of points. Apr 9 '20 at 11:52
• Ty! In this case, h means "first" and "second", right?
– JACK
Apr 9 '20 at 11:55
• Yes, replace h with whatever FIR you have. Apr 9 '20 at 11:56

HINT: Your original LPF is $$-\omega_c \lt \omega \lt +\omega_c$$. When you shift it by $$\pi$$, your integral limit for second method is $$\int_{-\pi}^{-\pi + \omega_c}$$ and $$\int_{\pi - \omega_c}^{\pi}$$.

For the first method, it should be $$h[n] = (-1)^{(n-\alpha)}\frac{sin(\omega_c(n-\alpha))}{\pi(n-\alpha)}$$ because you have to apply shift of $$\alpha$$ on $$n$$. This will fix your plot of (1).

For (2), with the changed limits as I hinted at the beginning $$h[n] = \frac{1}{2\pi}\int_{-\pi}^{-\pi + \omega_c}e^{-j\alpha\omega}e^{j\omega n}d\omega + \frac{1}{2\pi}\int_{\pi-\omega_c}^{\pi}e^{-j\alpha\omega}e^{j\omega n}d\omega\\ = \frac{1}{2\pi j(n-\alpha)}[e^{-j(n-\alpha)(-\pi+\omega_c)} - e^{j(n-\alpha)(-\pi)}] +\frac{1}{2\pi j(n-\alpha)}[e^{-j(n-\alpha)(\pi)} - e^{-j(n-\alpha)(\pi-\omega_c)}] \\ = \frac{1}{2\pi j(n-\alpha)}e^{-j(n-\alpha)(-\pi)}[e^{-j(n-\alpha)\omega_c} - 1]+\frac{1}{2\pi j(n-\alpha)}e^{-j(n-\alpha)(\pi)}[1 - e^{j(n-\alpha)\omega_c}]\\ = \frac{1}{2\pi j(n-\alpha)}(-1)^{(n-\alpha)}[e^{-j(n-\alpha)\omega_c} - e^{j(n-\alpha)\omega_c}]\\ = (-1)^{(n-\alpha)}\frac{sin(\omega_c(n-\alpha)}{\pi(n-\alpha)}$$

• I have edited my post now to include how the integral will work out. It is indeed possible as given in that link. Redo the integral and see. Do not read my answer before you do the integral. Plot the frequency response. There was a mistake in your first h[n] also. You forgot the $(n-\alpha)$ instead you used only $n$ for the power of $(-1)$ Apr 9 '20 at 12:27
• Wow thanks! That makes sense!
– JACK
Apr 9 '20 at 12:28
• But w_c is still a fixed point, lets forget the shifting property for a moment.
– JACK
Apr 9 '20 at 12:47
• The question states that $w_c<|w|\leq\pi$, isnt that you still have to intergrate them from $-\pi$ to $-w_c$ and $w_c$ to $\pi$
– JACK
Apr 9 '20 at 12:49
• No, the limit $\omega_c \lt |\omega| \le \pi$ is for LPF. It is not correct for HPF once you shift by $\pi$. You can draw the axis and see. Apr 9 '20 at 13:07

You can use a relation $$H_{hp}(e^{j\omega})= 1 - H_{lp}(e^{j\omega})$$ in time-domain, so that

$$h_{hp}[n] = \delta[n] - h_{lp}[n] = \delta[n]-\frac{\sin(\omega_c(n-\alpha)}{\pi(n-\alpha)},$$

in order to have the same cut-off frequency for the both filters.