How to compute magnitude and phase response from transfer function in Z-domain?

I have a transfer function $$H(z)=\frac{1+1.2z^{-1}+0.8z^{z^-2}}{1-0.9z^{-1}}$$ from which I'm supposed to sketch the magnitude and phase response. I know that you can transform $z=e^{j\omega}$ to get the frequency response, but I don't really understand what it means. The magnitude response is then $$\left|H(e^{j\omega})\right|=\left|\frac{1+1.2e^{-j\omega}+0.8e^{-j2\omega}}{1-0.9e^{-j\omega}}\right|,$$ but how do I calculate the values from here?

For example, if we set $\omega=0$, then the result is $30$. But if we set $\omega=\pi/4$, then the result is $$\left|\frac{1+1.2e^{-j\pi/4}+0.8e^{-j\pi/2}}{1-0.9e^{-j\pi/4}}\right|.$$ How does one solve this?

I also know that the formula for phase response is $$\arg(H(e^{j\omega}))=\frac{\Im(H(e^{j\omega}))}{\Re(H(e^{j\omega}))}$$ but I'm having a hard time to understand how to use it and what phase response actually is. Can you give me an example of how to calculate the phase response of a certain angle?

• Are you familiar with the Euler identity? So now Bob is your uncle. – jojek Mar 11 '15 at 10:16
• $e^{jw}=cos(w)+jsin(w)$? why so? – markus Mar 11 '15 at 10:21
• markus, probably the simplest proof (or explanation "why so") is here at Wikipedia. the thing to keep in mind is that the derivative of an exponential is an exponential and the derivative of a sinusoid (either sin() or cos()) is another sinusoid. so exponentials and sinusoids have something important mathematically in common. that's where the relationship comes from. BTW, i hate that Taylor series proof, although it also works. – robert bristow-johnson Mar 11 '15 at 14:29
• I guess "why so" referred to why jojek asked if the OP was familiar with Euler's identity. – Matt L. Mar 11 '15 at 16:35

For an example I'll use simple transfer function like: $$H(z) = \frac {z}{z-0.5}$$ Then substitue the $z$:$$H(e^{jw})=\frac{e^{jw}}{e^{jw}-0.5}$$ Expand to cos and sin: $$H(e^{jw})=\frac{cos(w)+jsin(w)}{cos(w)+jsin(w)-0.5}$$ Rationalize the denominator, group into real and imaginary part: $$\begin{eqnarray*}H(e^{jw})&=&\frac{cos(w)+jsin(w)}{cos(w)+jsin(w)-0.5}\cdot\frac{cos(w)-jsin(w)-0.5}{cos(w)-jsin(w)-0.5}\\ &=&\frac {e^{jw}\cdot (e^{-jw}-0.5)}{(e^{jw}-0.5)\cdot (e^{-jw}-0.5)}\\ &=&\frac {e^{jw-jw}-0.5e^{jw}}{e^{jw-jw}-0.5e^{jw}-0.5e^{-jw}+0.25}\\ &=&\frac {1-0.5e^{jw}}{1.25-0.5cos(w)-j0.5sin(w)-0.5cos(w)+j0.5sin(w)}\\ &=&\frac {1-0.5cos(w)-j0.5sin(w)}{1.25-cos(w)}\\ &=&\frac {1-0.5cos(w)}{1.25-cos(w)} - j\frac {0.5sin(w)}{1.25-cos(w)}\\ \end{eqnarray*}$$ Compute the magnitude: $$\begin{eqnarray*} \left|H(e^{jw})\right| &=& \sqrt{\Re(H(e^{jw}))^2+\Im(H(e^{jw}))^2}\\ &=& \frac {\sqrt{(1-0.5cos(w))^2+(0.5sin(w))^2}} {1.25-cos(w)}\\ &=& \frac {\sqrt{1-cos(w)+0.25cos^2(w)+0.25sin^2(w)}} {1.25-cos(w)}\\ &=& \frac {\sqrt{1-cos(w)+0.25(cos^2(w)+sin^2(w))}} {1.25-cos(w)}\\ &=& \frac {\sqrt{1-cos(w)+0.25}} {1.25-cos(w)}\\ &=& \frac {\sqrt{1.25-cos(w)}} {1.25-cos(w)}\\ \end{eqnarray*}$$ And you're done!
I think the idea here is to get a global picture of how the magnitude and the phase of $H(e^{j\omega})$ behave. This is most easily seen by computing the poles and zeros of $H(z)$. The zeros of $H(z)$ are the zeros of the numerator. In your case you'll find two complex conjugate zeros. And there is one real-valued pole corresponding to the zero of the denominator of $H(z)$. Then you could (as you already did) find $H(1)$, i.e. the DC value. Also compute the frequency corresponding to the zero (because there, $H(e^{j\omega})$ will have a dip, the depth of which depends on how close the zeros are to the unit circle, and you might want to evaluate $H(-1)$, i.e. the value at Nyquist. From these few value you can get a reasonable estimate as to how the magnitude of $H(e^{j\omega})$ behaves.
As for the phase, note that your formula (ratio of imaginary and real parts) is actually the tangent of the phase, not the phase itself. First of all, it is clear that the phase must be zero at DC (i.e. $z=1$), and at Nyquist (i.e. $z=-1$). Furthermore, the total phase response equals the phase of the numerator minus the phase of the denominator. So if you figure out the phase response of a single zero (for a single pole you get the same with a negative sign), you can compose the total phase simply the summing these partial phases for each pole and zero. Qualitatively, for each pole you get a decreasing contribution to the phase (with maximum decrease at the pole frequency), and for each zero you get an increasing contribution to the phase (with the maximum increase at the frequency of the zero).
You have to calculate complex exponentials. Every calculator or numerics package can do this. In the case of $\omega={\pi\over 4}$ the results are: $e^{-j{\pi\over 4}}=\sqrt 2- i\sqrt 2$ and $e^{-j{\pi\over 2}}=-i$. The expression for the magnitude evaluates to $3.3793$ at this angle.