## Problem
Consider [[discrete-time LTI system]] with 2 poles in $z_{1}=\frac{1}{4}$ and $z_{2}=-\frac{1}{2}$, 2 zeros at the origin, and unitary static gain. Knowing that it is a [[causal system]], find the [[transfer function]] of the system, and the [[difference equation]] that defines it.
![[ztran-o01s-pole-zero.png|300]]
> [!Solution]-
>
> The system as a [[rational transfer function]] in the form:
> $
> H(z)=\frac{P(z)}{Q(z)}
> $
> Poles are the zeros of $Q(z)$:
> $
> Q(z) = \left( z-\frac{1}{4} \right)\left( z+\frac{1}{2} \right)
> $
> If the system has 2 zeros at the origin, the numerator is:
> $
> P(z) = K z^{2}
> $
> The transfer function is:
> $
> H(z) = \frac{K z^{2}}{\left( z-\frac{1}{4} \right)\left( z+\frac{1}{2} \right)}
> $
> Unitary static gain means that $H(e^{j0t})=1$, that is:
> $
> K = \left(1 -\frac{1}{4} \right)\left(1 +\frac{1}{2} \right) = \frac{9}{8}
> $
> Reshaping $H(z)$:
> $
> \begin{align}
> H(z) &= \frac{9}{8} \frac{1}{\left( 1-\frac{1}{4}z^{-1} \right)\left( 1+\frac{1}{2}z^{-1} \right)} \\
> \frac{Y(z)}{X(z)}&=\frac{\frac{9}{8}}{1+\frac{1}{4}z^{-1}-\frac{1}{8}z^{-2}}
> \end{align}
> $
> that is
> $
> Y(z)+\frac{1}{4}Y(z)z^{-1}-\frac{1}{8}z^{-2}=\frac{9}{8}X(z)
> $
> using the [[time shifting property of the z-transform]]:
> $
> y(n) + \frac{1}{4}y(n-1)-\frac{1}{8}y(n-2)=\frac{9}{8} x(n)
> $
> resulting in the [[difference equation]]:
> $
> y(n) = \frac{9}{8}x(n)-\frac{1}{4}y(n-1)+\frac{1}{8}y(n-2)
> $
>
>
> The [[impulse response]] of [[discrete-time LTI system]] can be computed from the [[transfer function]].
>
> It can be computed using the `signal.lfilter()` function of the `scipy` Pyhthon package.
>
>
> ```run-python
> import numpy as np
> from scipy import signal
> import matplotlib.pyplot as plt
>
> def delta(n: np.array) -> np.array:
> """Discrete-time unit impulse signal"""
> return np.where(n ==0, 1, 0)
>
> # time axis
> n = np.arange(-7,10)
>
> y = signal.lfilter([9/8], [1, 1/4, -1/8], delta(n))
>
> plt.stem(n, y)
> plt.grid()
> plt.savefig('ztran-o01s.svg')
> plt.show()
> ```
>
> That results in:
> ![[ztran-o01s.svg]]
>
> The [[impulse response]] of the [[discrete-time LTI system]] is the inverse [[z-transform]] of the [[transfer function]].
>
> To compute it we can expand $H(z)$ in partial fractions
> $
> \begin{align}
> H(z) &= \frac{\frac{9}{8}}{1+\frac{1}{4}z^{-1}-\frac{1}{8}z^{-2}} \\
> &= \frac{\frac{3}{8}}{1-\frac{1}{4}z^{-1}} + \frac{\frac{3}{4}}{1+\frac{1}{2}z^{-1}}
> \end{align}
> $
>
> The region of convergence of a causal system is the outside of the circle that includes all the poles, that is, $|z| > \frac{1}{2}$.
>
> From the list of [[z-transform pairs]] we can select this pair:
> $
> a^{n}u(n) \xrightarrow[\cal ZT]{} \frac{1}{1-az^{-1}}, \, |z|>|a|
> $
>
> Using the linearity of the z-transform, we can compute the impulse response:
> $
> h(n) = \frac{3}{8} \left( \frac{1}{4} \right)^{n}u(n) + \frac{3}{4}\left( -\frac{1}{2} \right)^{n} u(n)
> $
>