# Converting transfer function that is a sum of unusual rational polynomials to finite difference equation

I have the following rather exotic transfer function:

$$H(z) = cz^{-m} + \frac{b_0 z^{-1} + b_1z^{-2} + \dots + b_{2m}z^{-2m}}{1 + a z^{-1}} + \frac{q_0 z^{-1} + q_1z^{-2} + \dots + q_{2m}z^{-2m}}{1 + p z^{-1}}$$

Where $c$, $b_0,\ldots,b_{2m}$, $a$, $q_0,\ldots, q_{2m}$, $p$ are real valued constants and $m > 1$.

How do I go about converting this to a finite difference equation via the inverse $\mathcal Z$-transform?

I thought I had got to grips with the inverse $\mathcal Z$-transform, but I can't seem to convert $H(z)$ to a finite difference equation that produces the right output.

My attempt:

\begin{align} y[n] &= c x[n - m] &+& (b_0 x[n - 1] + \dots + b_{2m} x[n - 2m]) \\ &&-& a y[n - 1]\\ &&+& (q_0 x[n - 1] + \dots + q_{2m} x[n - 2m])\\ &&-& p y[n - 1] \end{align}

This doesn't seem to be correct. When I test this its magnitude response is not even close to the original transfer function.

My assumption is that the three terms $cz^{-m}$, $\frac{b_0 z^{-1} + b_1z^{-2} + \ldots + b_{2m}z^{-2m}}{1 + a z^{-1}}$, $\frac{q_0 z^{-1} + q_1z^{-2} + \ldots + q_{2m}z^{-2m}}{1 + p z^{-1}}$ can be transformed separately.

• Think about the denominators. If you are trying to write the equation into one that is just in terms of $z^{-p}$ then you need to multiply both sides by $1+az^{-1}$ and $1+bz^{-1}$. So $y$ will have at least a second order difference equation to contribute (your equation has $-(a+b)y[n-1]$ as a term... I don't think that's correct). – Peter K. Jul 13 '16 at 14:51
• @Peter K. is it not the case that inverse z-transform follows this rule: $\mathscr{Z^{-1}} \{ H_1(z) + H_2(z) \} = \mathscr{Z^{-1}} \{ H_1(z) \} + \mathscr{Z^{-1}} \{ H_2(z) \}$? That was my assumption. – keith Jul 13 '16 at 14:56
• That's true, except that what you want to do is: $\mathscr{Z^{-1}} \{ H(z)\} = \mathscr{Z^{-1}} \{ Y(z) / X(z) \}$ and you need to write an equation like $p_1(z^{-1}) Y(z) = p_2(z^{-1}) X(z)$ where $p_1(z^{-1})$ and $p_2(z^{-1})$ are polynomials in $z^{-1}$. – Peter K. Jul 13 '16 at 15:21
• @Peter K. I think I'm beginning to understand thank you :-) – keith Jul 13 '16 at 15:24

The expression: $$H(z) = cz^{-m} + \frac{b_0 z^{-1} + b_1z^{-2} + \dots + b_{2m}z^{-2m}}{1 + a z^{-1}} + \frac{q_0 z^{-1} + q_1z^{-2} + \dots + q_{2m}z^{-2m}}{1 + p z^{-1}}$$
Can be rewritten as: $$H_1(z)=cz^{-m} \\ H_2(z)=\frac{b_0 z^{-1} + b_1z^{-2} + \dots + b_{2m}z^{-2m}}{1 + a z^{-1}}\\ H_3(z)=\frac{q_0 z^{-1} + q_1z^{-2} + \dots + q_{2m}z^{-2m}}{1 + p z^{-1}}\\ H(z) = H_1(z)+ H_2(z)+ H_3(z)$$
Hence: $$y_1(t)=cu(t-m)\\ y_2(t)=b_0 u(t-1) + \dots + b_{2m}u(t-2m) - a y_2(t-1)\\ y_3(t)=q_0 u(t-1) + \dots + q_{2m}u(t-2m) - p y_3(t-1)\\ y(t) = y_1(t)+y_2(t)+y_3(t)$$
The standard transfer function is obtained simply by multiplying and simplifying terms: $$H(z)=\frac{c(1+(a+p)z^{-1}+apz^{-2})z^{-m} + b_0(1+pz^{-1})z^{-1} + \dots + b_{2m}(1+pz^{-1})z^{-2m} + q_0(1+az^{-1})z^{-1} + \dots + q_{2m}(1+az^{-1})z^{-2m} }{(1+az^{-1})(1+pz^{-1})}$$ which leads to the univariable finite difference equation, which can be simplified further.....: $$y(t)=c(1+(a+p)z^{-1}+apz^{-2})y(t-m) + b_0(1+pz^{-1})z^{-1} + \dots + b_{2m}(1+pz^{-1})u(t-2m) + q_0(1+az^{-1})z^{-1} + \dots + q_{2m}(1+az^{-1})u(t-2m) - (a+p)z^{-1}-apz^{-2}$$