Consider the discrete-time system $$ H(z) = a_0 + a_1 z^{-1} + a_2 z^{-2} $$ To compute the DTFT, let $z = e^{j\omega}$ such that $$ H(e^{j\omega}) = e^{-j\omega} \left(a_0 e^{j\omega} + a_1 + a_2e^{-j\omega}\right) \label{eq:H_w} \tag{1} $$ If $a_0 = a_2$, then $H(e^{j\omega})$ can be put into polar form as $$ H(e^{j\omega}) = \left\lvert a_1 + 2 \cos \omega\right\rvert e^{-j\omega} $$ However, if $a_0 \neq a_2$, then it is not clear how $H(e^{j\omega})$ can be put into polar form. More precisely, substituting $e^{j\omega} = \cos \omega + j \sin \omega$ into \eqref{eq:H_w} yields \begin{align} H(e^{j\omega}) &= e^{-j\omega} \big(a_0 (\cos \omega + j \sin \omega) + a_1 + a_2(\cos \omega - j \sin \omega)\big) \\ &= e^{-j\omega} \big( (a_0 + a_2)\cos \omega + j(a_0 - a_2) \sin \omega + a_1\big) \end{align} Since $(a_0 + a_2)\cos \omega + j(a_0 - a_2) \sin \omega$ is a complex number, then it can be expressed in polar form as $C(\omega)e^{j\theta(\omega)}$, where \begin{align} C(\omega) &= \sqrt{((a_0 + a_2)\cos \omega)^2 + ((a_0 - a_2) \sin \omega)^2} \\ \theta(\omega) &= \operatorname{atan2}\big( (a_0 - a_2) \sin \omega,\ (a_0 + a_2)\cos \omega \big) \end{align} Therefore, \begin{align} H(e^{j\omega}) &= e^{-j\omega} \left( C(\omega)e^{j\theta(\omega)} + a_1\right) \end{align} At this point, I can factorize $e^{j\frac{\theta(\omega)}{2}}$ out of the parentheses and then simplify further, but I feel that this method is cumbersome. Is there an easier approach?
-
$\begingroup$ There are different ways to slice this but none of them is "easy". $\endgroup$– HilmarCommented Dec 10, 2021 at 15:12
-
$\begingroup$ @Hilmar what are some other ways? If you expand on these other ways in an answer, I'm happy to accept it. $\endgroup$– mhdadkCommented Dec 10, 2021 at 17:30
-
1$\begingroup$ I have a general biquad frequency response thingie here if that does any good. $\endgroup$– robert bristow-johnsonCommented Dec 10, 2021 at 21:56
1 Answer
Here is one way to do it. Let's call the coefficients "$b$" instead of "$a$" since "$a$" is usually used for the denominator and "$b$" for the numerator.
Let's start with
$$H(e^{j\omega}) = b_0 + b_1 e^{-j\omega} + b_2 e^{-j2\omega} $$
The phase is the inverse tangent of the the imaginary part divided by the real part so we get:
$$\phi(\omega) = \operatorname{tan}^{-1} \left( \frac{- b_1 \sin(\omega) - b_2 \sin(2\omega)}{1 + b_1 \cos(\omega) + b_2 \cos(2\omega)} \right)$$
provided the quadrant is chosen properly. I'm not sure if there is a way to simplify this further. You could try to pull out $e^{-j\omega}$ to make it more symmetrical, but I don't think this will make it any easier.
For the magnitude squared we just multiply with complex conjugate.
$$\big|H(e^{j\omega})\big|^2 = H(e^{j\omega}) \cdot H^*(e^{j\omega}) = (b_0 + b_1 e^{-j\omega} + b_2 e^{-j2\omega})(b_0 + b_1 e^{j\omega} + b_2 e^{j2\omega})$$
We just have to multiply this out and sort the terms. We get something like this.
$$ \big|H(e^{j\omega})\big|^2 = b_0^2 + b_1^2 + b_2^2 + 2(b_0b_1 + b_1b_2)\cos(\omega) + 2b_0b_2\cos(2\omega)$$
None of these expressions is particularly pretty or intuitive, but that's just the way it is.
CAVEAT: I haven't double checked the math, so it's possible that there is an arithmetic error or typo in there.