Reputation: 121
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 ?
Upvotes: 10
Views: 18514
Reputation: 1
I had the same problem. From my experience sympy can solve most of the z transforms but had problem with trig functions. And while lcapy could solve ZT of trig, it had problems solving others. So ended I up on using them both, and it is working.
Upvotes: 0
Reputation: 121
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)
Upvotes: 3
Reputation: 2699
I added two comments with code examples on how to get the transform here, note they don't always work.
https://github.com/sympy/sympy/issues/12502
Upvotes: 0
Reputation: 91610
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
Upvotes: 1