z transform is very important in signal process. I can find fourier, laplace, cosine transform and so on in sympy tutorial. But I do not know how to do z transform using sympy. Could you tell me how to do it ?
SymPy doesn't have it implemented as a transform function yet, but you can represent the summations directly. However, after some playing with it, it looks it is limited in what sums it can actually compute. Here's an example of one that works:
>>> pprint(summation(n*z**-n, (n, -oo, oo)))
⎧ z 1 │1│
⎪- ───────── + ────────── for │─│ < 1 ∧ │z│ < 1
⎪ 2 2 │z│
⎪ (-z + 1) ⎛ 1⎞
⎪ z⋅⎜1 - ─⎟
⎪ ⎝ z⎠
⎪
⎨ ∞
⎪ ___
⎪ ╲
⎪ ╲ -n
⎪ ╱ n⋅z otherwise
⎪ ╱
⎪ ‾‾‾
⎩ False
There is a nice package (lcapy) which is based on sympy but can do z transform and inverse and a lot more other time discrete stuff.
https://pypi.org/project/lcapy/
Simply try
import lcapy as lc
from lcapy.discretetime import n
xk=n*2**n*lc.exp(3j*n)
X0=xk.ZT()
print(X0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With