# 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$? – a concerned citizen Apr 9 at 11:46
• I will try, although I haven't learnt FFT yet. – JACK Apr 9 at 11:51
• It looks like Matlab/Octave code, so just plot abs(fft(h,1024)), or whatever number of points. – a concerned citizen Apr 9 at 11:52
• Ty! In this case, h means "first" and "second", right? – JACK Apr 9 at 11:55
• Yes, replace h with whatever FIR you have. – a concerned citizen Apr 9 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)$ – jithin Apr 9 at 12:27
• 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 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. – jithin Apr 9 at 13:07