I have been studying IIR filters and know that a rational transfer function:

$$ H(z) = \frac {b_0 + b_1 z^{-1} + ... + b_N z^{-N}}{1 + a_1 z^{-1} + ... + a_N z^{-N}} $$

has a finite difference equation:

$$ y[n] = b_0 x[n] + b_1 x[n - 1] + ... + b_n x[n - N] - a_1 y[n - 1] - ... - a_N y[n - N] $$

What I am confused about is how the transformation from transfer function to difference equation is performed.

I have read about the z-transform and the inverse z-transform and understand that the inverse z-transform is the key, but none of the internet sources I have read provide a joined up walk though of how to take a transfer function and derive a finite difference equation from first principles.

Could anyone recommend a good source, or explain the end-to-end approach?


You do not really need the inverse $\mathcal{Z}$-transform to derive the difference equation corresponding to a given rational transfer function. You just need to know that $z^{-k}$ corresponds to a delay of $k$ samples. The inverse $\mathcal{Z}$-transform of $H(z)$ would give you the corresponding impulse response, but you don't need the impulse response to write down the difference equation.

Knowing that


you can rewrite the equation given in your question as

$$Y(z)\left(1+a_1z^{-1}+\ldots +a_Nz^{-N}\right)=X(z)\left(b_0+b_1z^{-1}+\ldots +b_Nz^{-N}\right)\tag{1}$$

With the correspondences $Y(z)z^{-k}\Longleftrightarrow y[n-k]$ and $X(z)z^{-k}\Longleftrightarrow x[n-k]$ you can directly write down the difference equation from $(1)$:

$$y[n]+a_1y[n-1]+\ldots +a_Ny[n-N]=b_0x[n]+b_1x[n-1]+\ldots +b_Nx[n-N]$$

Here's a way to show that $\mathcal{Z}\{x[n-k]\}=X(z)z^{-k}$:


  • $\begingroup$ Thanks Matt. The inverse z transform can be defined as $ x[n] = \frac{1}{2 \pi i} \oint f(z) z^{n - 1} dz $ where I do not know whether $f(z)$ would be $H(z)$ or your $X(z)$ or $Y(z)$. How would I express the difference equation in terms of the contour integral prior to solving it and arriving at the difference equation? Or would that not even be possible? $\endgroup$
    – keith
    Jul 4 '16 at 10:52
  • $\begingroup$ @keith: If you use $H(z)$ as $f(z)$ in that formula, you'll get the impulse response $h[n]$, which you don't need. This formula is useless for what you want to do. As I wrote in my answer, what you need to know is that $z^{-k}$ corresponds to a delay of $k$ samples. Note that you can't take the inverse Z-transform of $X(z)$ or $Y(z)$ because they are not given. $\endgroup$
    – Matt L.
    Jul 4 '16 at 10:59
  • $\begingroup$ Thanks Matt, your help was what I needed to make the last mental leap to do this using maths alone (I've up voted you as way of thanks). See my answer for the application of the contour integral (btw Y(z) and X(z) are given in terms of $b_n$ and $a_n$!). $\endgroup$
    – keith
    Jul 4 '16 at 11:33
  • $\begingroup$ @keith: OK, I see. If you like to use the contour integral as an exercise, that's OK. But it is actually quite an overkill in this case. I've added to my answer a way to see that $z^{-k}$ corresponds to a $k$ sample delay. As I've mentioned before, this latter fact is the only thing you need to know to derive the difference equation from the rational transfer function. $\endgroup$
    – Matt L.
    Jul 4 '16 at 11:38

From Matt's answer, I think I've deduced the working I was interested in.


$$ H(z) = \frac {Y(z)} {X(z)} $$

Which gives:

$$ Y(z) + Y(z)a_1z^{−1} + ... + Y(z)a_Nz^{−N} = b_0 X(z) + X(z)b_1z^{−1} + ... + X(z)b_Nz^{−N} \tag{1} $$

Given that the inverse z-transform is defined as the contour integral (this is the bit I was missing):

$$ y[n]=\frac{1}{2 \pi i} \oint Y(z)z^{n−1}dz \tag{2} $$

$$ x[n]=\frac{1}{2 \pi i} \oint X(z)z^{n−1}dz \tag{3} $$

Then integrating both sides of (1) using $\frac{1}{2 \pi i} \oint ... z^{n−1}dz$:

Left hand side:

$$ \frac{1}{2 \pi i} \oint ( Y(z) + Y(z)a_1z^{−1} + ... + Y(z)a_Nz^{−N} )z^{n−1}dz $$


$$ \frac{1}{2 \pi i} \oint Y(z)z^{n−1}dz + \frac{a_1}{2 \pi i} \oint Y(z)z^{n−2}dz + ... + \frac{a_N}{2 \pi i} \oint Y(z)z^{n−1-N}dz $$

Where by inspection of the definition of (2):

$$ y[n]=\frac{1}{2 \pi i} \oint Y(z)z^{n−1}dz $$

$$ a_1y[n - 1]=\frac{a_1}{2 \pi i} \oint Y(z)z^{n−2}dz $$

$$ a_Ny[n - N]=\frac{a_N}{2 \pi i} \oint Y(z)z^{n− N -1}dz $$


$$ y[n] + a_1y[n - 1] + ... + a_Ny[n - N] = \frac{1}{2 \pi i} \oint ( Y(z) + Y(z)a_1z^{−1} + ... + Y(z)a_Nz^{−N} )z^{n−1}dz $$

And similarly for right hand side finally gives:

$$ y[n] + a_1 y[n - 1] + ... + a_N y[n - N] = b_0 x[n] + b_1 x[n - 1] + ... + b_N x[n - N] $$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.