# IIR: get magnitude and phase from coefficients

i'm trying to plot 1)the magnitude and 2)the phase response of an IIR eq with only its coefficients.

i've found somewhere that one can find the magnitude response starting with the transfer function :

ex: y(n) = a1*y(n-1) + b0*x(n) + b1*x(n-1) + b2*x(n-2)

... has the transfer function

       Y(Z)    b0 + b1 Z^-1 + b2 Z^-2
H(Z) = ---- = ----------------------
X(Z)     1 - a1 Z^-1


To find the frequency response at theta=pi (folding frequency)

Recall Z = exp( j*theta )

Z = exp(j*pi) = -1

         b0 + b1*(-1) + b2*1
H(-1) = ----------------------
1 - a1*(-1)


let's try with a frequency of 0.25*Pi

exp(0.25*j*pi) = 1 + j*sin(0.25*pi) ~= 1 + 0.72*j

but after some calculations i end up with a complex division:

     (b0 + b1 + 0,52*b2) + j*0.72*b1
=  -------------------------------------
(1 - a1) + a1*0.72*j


so where do i go from there?

and how to compute the phase ?

thanks a lot!

Jeff

• What is the problem? Just do the complex division and you have the result. The phase is arctan(imag/real) of the (with proper quadrant correction). The magnitude is sqrt(real^2+imag^2) – Hilmar Oct 2 '13 at 12:34
• oooh right on! that's correct, i was blocked at the complex division, thanks man! – IonOne Oct 2 '13 at 12:54
• @Hilmar You should make that into an answer. – Jim Clay Oct 2 '13 at 13:20