### 5.63.1 The Z-transform of a sequence: ztrans

The Z-transform of a sequence a0, a1, …, an, … is the function

f(z) =

∞
∑
n=0

an
zn

.

The ztrans command takes one or three arguments.

- A formula in the variable x for the general term ax of a sequence, or
- A formula for the general term of a sequence, the variable used in the formula, and a variable to be used by the resulting function.

ztrans returns the Z-transform of the sequence.

For example, the Z-transform of the sequence

0, 1, 2, 3, …

is

f(z) = 0 + 1/z + 2/z2 + 3/z3 + …

which has closed form

f(z) = z/(z−1)2.

Input:

ztrans(x)

Output:

x/(x^2-2*x+1)

Input:

ztrans(n,n,z)

Output:

z/(z^2-2*z+1)

Note that
Input:

ztrans(1)

Output:

x/(x-1)

since

∞
∑
n=0

1/xn = 1/(1−1/x) = x/(x−1).

We also have
Input:

ztrans(1,n,z)

Output:

z/(z-1)

Note that differentiating both sides of

∞
∑
n=0

1/zn = z/(z−1)

gives us

∞
∑
n=0

n/zn−1 = 1/(z−1)2

and so, multiplying both sides by z,

∞
∑
n=0

n/zn = z/(z−1)2 = z/(z2 − 2z + 1)

as indicated above.