Recursive filter with repeated poles

This post follows this previous resolved post where I was trying to find the inverse Z-transform of a more simple filter output (that I used as an example to get the methodology). The present filter implements an additional integrator and I tried to use the same method. The problem is, I am not sure about how to deal with repeated poles.

$$H(z)$$ and $$X(z)$$ are given by:

$$H(z)= \frac{(1-z^{-K})(1-z^{-L})}{{(1-z^{-1})}^{2}}$$ $$X(z) =\mathcal{Z}\{x[nT]\}= \mathcal{Z}\left\{Ae^{-\frac{nT}{\tau}}u[n]\right\} = A\dfrac{z}{z-e^{-\frac{T}{\tau}}}= A\dfrac{1}{1-e^{-\frac{T}{\tau}}z^{-1}}$$

I want to express $$y[n]$$ as a function of the pulse amplitude $$A$$, $$L$$, $$K$$, $$n$$ (sample number), $$T$$(sampling period), and the time constant $$\tau$$; my goal being to retrieve the pulse amplitude $$A$$.

I used polynomial long division to develop $$H(z)$$ and i came up with something like this, assuming $$K>L$$:

$$(1)\space H(z)=1+2z^{-1}+3z^{-2}+...+(L+1)z^{-L+1}+Lz^{-L}+Lz^{-L-1}+..+Lz^{-K+1}+(L-1)z^{-K}+(L-2)z^{-K-1}+...+z^{-K-L+2}$$

Now I describe $$Y(z)$$ using partial fraction expansion: $$Y(z) = H(z).X(z) = A.\left[\frac{(1-z^{-K})(1-z^{-L})}{{(1-z^{-1})}^{2}(1-e^{-\frac{T}{\tau}}z^{-1})}\right] = A.\left[\frac{B_0}{(1-e^{-\frac{T}{\tau}}z^{-1})} + \frac{B_1}{(1-z^{-1})} + \frac{B_2}{{(1-z^{-1})}^2}\right]$$ \begin{align*} & (1-z^{-K})(1-z^{-L})=B_0.{(1-z^{-1})}^{2}+ B_1.(1-z^{-1}).(1-e^{-\frac{T}{\tau}}z^{-1})+B_2.(1-e^{-\frac{T}{\tau}}z^{-1}) \\ & H(z)(1-z^{-1})^{2}= B_0.{(1-z^{-1})}^{2}+ B_1.(1-z^{-1}).(1-e^{-\frac{T}{\tau}}z^{-1})+B_2.(1-e^{-\frac{T}{\tau}}z^{-1})\\ \end{align*} We obtain: \begin{align*} &B_0 = H(z) = 1+2z^{-1}+3z^{-2}+...+(L+1)z^{-L+1}+Lz^{-L}+Lz^{-L-1}+..+Lz^{-K+1}+(L-1)z^{-K}+(L-2)z^{-K-1}+...+z^{-K-L+2}\\ & B_2 = 0 \\ \end{align*} Not sure about $$B_1$$: \begin{align*} &(2)\space B_1 = \frac{d}{dz^{-1}}\left[H(z).(1-z^{-1})^{2}\right]_{z^{-1}=1} = \frac{d}{dz^{-1}}\left[\frac{1-z^{-K}-z^{-L}+z^{-K-L}}{1-e^{-\frac{T}{\tau}}z^{-1}}\right]_{z^{-1}=1} = \left[\frac{(Kz^{-K}+Lz^{-L}-(L+K)z^{-K-L})(1-e^{-\frac{T}{\tau}}z^{-1})-(1-z^{-K}-z^{-L}+z^{-K-L})(e^{-\frac{T}{\tau}}z^{-2})}{(1-e^{-\frac{T}{\tau}}z^{-1})^{2}}\right]_{z^{-1}=1} \\ \end{align*} If $$B_0$$ is correct (I am not sure), the inverse z-transform of $$\frac{B_0}{(1-e^{-\frac{T}{\tau}}z^{-1})}$$ can easily be retrieved. As for $$B_1$$, I get: \begin{align*} &(3)\space \frac{B_1}{1-z^{-1}}=-\frac{(1-z^{-K})(1-z^{-L})e^{-\frac{T}{\tau}}z^{-2}}{(1-e^{-\frac{T}{\tau}}z^{-1})^{2}(1-z^{-1})}=-\frac{(1 + z^{-1} + \dots + z^{-K+1} -z^{-L}-z^{-L-1}- \dots -z^{-K-L+1})e^{-\frac{T}{\tau}}z^{-2}}{(1-e^{-\frac{T}{\tau}}z^{-1})^{2}}{} \end{align*}

Now according to this table http://lpsa.swarthmore.edu/LaplaceZTable/LaplaceZFuncTable.html, my expression looks similar to the follow one.

However I tried to apply it on a concrete example (using Excel), and it looks like I have missed something or got something wrong.

Any help would be greatly appreciated

I assume that by "inverse Z-transform" you simply mean the impulse response of the filter.

That's much easier done in the time domain directly. The first section has an impulse response of $$h_1[n] =\begin{cases} 1 & \text{ if } n= 0\\ -1 & \text{ if } x= K\\ 0 & otherwise \end{cases}$$ So basically a positive spike at n=0 and a negative spike at $$n = K$$

The integrator picks up the first spike and keeps it until you hit the negative spike, which cancels the positive one and everything is zero again. So the resulting impulse response is a rectangular window $$h_2[n] =\begin{cases} 1 & \text{ if } 0 \leq n < K \\ 0 & otherwise \end{cases}$$

The second half of the filter has exactly the same structure as the first half and so it produces a rectangular window of length $$L$$.

The overall impulse response is then simply the convolution of both rectangular windows. This will be a triangle for $$K=L$$ and a trapezoid otherwise. The ramps of the trapezoid have the length of the smaller of K and L and the length of the flat part is the difference between K and L. Total length is $$L+K-1$$

Assuming K is the smaller one we could write this as

$$h[n] =\begin{cases} n+1 & \text{ if } 0 \leq n < K \\ K & \text{ if } K \leq n < L \\ K-1-(n-L) & \text{ if } L \leq n < L+K-1 \\ 0 & otherwise \end{cases}$$

• The reason I wanted to express $y[n]$ as a function of the pulse amplitude (A), $\tau$, $K$, $L$, and $n$ is to retrieve A using: $$y_{measured}[n_{flatTop}] = A*\left[y_{calculated}[n_{flatTop}]\right]$$ with $y_{measured}[n_{flatTop}]$ the measure of the filter output for $n$ within the trapezoid flat top, and $y_{calculated}[n_{flatTop}]$ the theorical filter output at this same $n$, without considering A. I tried it and it seems that I am missing another term in the equation, in addition to $B_0$. This seems to be confirmed by the fact that $B_0$ only has additions of positive terms. – Dams0622 Nov 28 '18 at 22:38