# Analytically designing a notch-filter for specified frequency 50 Hz

I tried to analytically construct a causal notch filter that stops frequencies at 50Hz and I thought if zeros are more than poles it will be non-causal so I chose equal amount of poles and zeros resulting in

$$\dfrac{\left(z-e^{100\pi i} \right)\left(z-e^{-100\pi i} \right)}{z^2}$$

Is this correctly designed and causal?

You've designed a causal filter with a notch at $\omega_0=100\pi$. But the result is probably not what you want. Note that you've designed an FIR (finite impulse response) filter. Its frequency response has a large overshoot towards high frequencies.

What you actually want is an IIR filter, with poles away from the origin of the complex $z$-plane. A simple way to design a notch filter is to place the zeros at the desired notch frequency (as you did), and place poles at the same angle but slightly inside the unit circle. If $0<r<1$ is the pole radius, your transfer function looks like this:

$$H(z)=\frac{(z-e^{j\omega_0})(z-e^{-j\omega_0})}{(z-re^{j\omega_0})(z-re^{-j\omega_0})}=\frac{z^2-2z\cos(\omega_0)+1}{z^2-2zr\cos(\omega_0)+r^2}\tag{1}$$

You can apply scaling to the transfer function $(1)$ such that its gain at DC equals 1.

Finally, note that you have to take the sampling frequency into account. The notch frequency $\omega_0$ in $(1)$ is normalized. If $f_0$ is the desired notch frequency in Hertz, and if $f_s$ is the sampling frequency in Hertz, then

$$\omega_0=2\pi\frac{f_0}{f_s}$$

As an example, take $f_0=50\text{ Hz}$, $f_s=1000\text{ Hz}$, and $r=0.98$. The figure below shows the transfer function of the FIR notch filter you proposed (top), and the IIR transfer function according to Equation $(1)$ (bottom): • Great answer, it helped alot! But now I have another question... Why is it neccesary to divide by the sampling frequency $f_s$? It seems to me the correct frequencies should be filtered out no matter the sampling frequency since $$H(e^{jw})\cdot X(e^{jw})$$ should result in 0 whenever $H(e^{jw})=0$. Oct 27, 2015 at 12:57
• @Jakkarn: For fixed filter coefficients, if you change $f_s$ the position of the notch also changes. The $\omega$ in $H(e^{j\omega})$ is always normalized by the sampling frequency. This is a basic property of discrete-time systems. Oct 27, 2015 at 13:00
• That is true... The $n$-axis would be all wrong if ignored. Thanks for all help! Oct 27, 2015 at 13:15