# The Z-transform of a sequence: ztrans

### 5.58.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

.

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.

The ztrans command finds the Z-transform of a sequence.

- ztrans takes one mandatory and two optional arguments:
  - ax, a formula with a variable for the general term of a sequence.
  - Optionally, x, the variable (by default x).
  - Optionally, z, a variable to be used by the resulting function.
  ztrans(ax ⟨ x,z⟩>) returns the Z-transform of the sequence.

#### Examples.

- Input:
  ztrans(x)
  Output:

  x/(x2−2*x+1)

- Input:
  ztrans(n,n,z)
  Output:

  z
  z2−2 z+1

- Input:
  ztrans(1)
  Output:

  x
  x−1

  since

  ∞
  ∑
  n=0

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

  You 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 you

  ∞
  ∑
  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.