# Inverse Z Transform returning complicated expression

I want to study how the Z transform changes with the sampling rate T, in a closed loop system.

The command I'm using to do this is:

InverseZTransform[(-1 - T + z + E^T (1 + (-1 + T) z))/
(-T +  E^T (1 + (-2 + T) z + z^2)), z, n]


However, it takes a while to do so, and the result that appears is insanely huge and impractical.

For substitutions of T = 1, T = 0, etc, the inverse transform is very very easily found. I was wondering if someone could give any suggestions as to whats going on, because I really don't want to have to solve it by hand.

Also, for some reason, Apart[y[z] , z] also doesn't work. (y[z] is the function to invert).

At least in this case, it is better to work with the most generic form of your rational function, and then plug-in the desired coefficients later. Witness the following:

FullSimplify[InverseZTransform[(g + f z)/(c + b z + a z^2), z, n], n ∈ Integers]
(2^(-1 - n) (Sqrt[b^2 - 4 a c] ((-b + Sqrt[b^2 - 4 a c])/a)^n g + Sqrt[b^2 - 4 a c]
(-((b + Sqrt[b^2 - 4 a c])/a))^n g + (-((b + Sqrt[b^2 - 4 a c])/a))^n (2 c f - b g) +
((-b + Sqrt[b^2 - 4 a c])/a)^n (-2 c f + b g)) (-1 + UnitStep[-n]))/
(c Sqrt[b^2 - 4 a c])


which in itself is already complicated.

From there, make the necessary substitutions to get what you want:

Simplify[% /. {g -> E^T - T - 1, f -> 1 + E^T (T - 1),
c -> E^T - T, b -> E^T (T - 2), a -> E^T}]


whose output I shall omit. The result is still complicated, but not as much as the one obtained from directly evaluating InverseZTransform[] on the OP's expression.

f = Function[{T, n}, InverseZTransform[(-1 - T + z + Exp[T] (1 + (-1 + T) z))/(-T +

Plot[f /. {T -> x, n -> 3}, {x, 0, 5}]