TExcelTAD
Home › Fourier Analysis & Signals › The z-Transform

The z-Transform

The DTFT evaluates ∑h[n]e−iωn\sum h[n] e^{-i\omega n} on the unit circle. The z-transform replaces eiωe^{i\omega} by an arbitrary complex number zz, turning sequences into functions on the complex plane, often simple rational functions. It turns difference equations into algebra, makes stability a question about where the poles are, and is the discrete twin of the Laplace transform.

Definition

X(z)=∑n=−∞∞x[n] z−nX(z) = \sum_{n=-\infty}^{\infty} x[n]\, z^{-n}

The sum converges for zz in a region of convergence (ROC), an annulus. On the unit circle, z=eiωz = e^{i\omega}, the z-transform is the DTFT (when the circle lies in the ROC).

Two fundamental pairs:

δ[n−k]↔z−k,anu[n]↔11−az−1(∣z∣>∣a∣)\delta[n - k] \leftrightarrow z^{-k}, \qquad a^n u[n] \leftrightarrow \frac{1}{1 - a z^{-1}} \quad (\lvert z \rvert > \lvert a \rvert)

The second is a geometric series: ∑n≥0(az−1)n\sum_{n \ge 0} (a z^{-1})^n.

python · try it yourself
import numpy as np

a = 0.6
n = np.arange(200)
x = a ** n
for z in (2.0, 1.0, np.exp(0.7j), 0.7 + 0.2j):
    series = np.sum(x * z ** (-n.astype(float)))
    closed = 1 / (1 - a / z)
    print(f"z = {complex(z):.3f}: |z| = {abs(z):.3f}  series {complex(series):.5f}   closed form {complex(closed):.5f}")
z = 2.000+0.000j: |z| = 2.000  series 1.42857+0.00000j   closed form 1.42857+0.00000j
z = 1.000+0.000j: |z| = 1.000  series 2.50000+0.00000j   closed form 2.50000+0.00000j
z = 0.765+0.644j: |z| = 1.000  series 1.22367-0.87413j   closed form 1.22367-0.87413j
z = 0.700+0.200j: |z| = 0.728  series 2.20000-2.40000j   closed form 2.20000-2.40000j

For every ∣z∣>0.6\lvert z \rvert > 0.6 the truncated series matches the closed form.

Delay becomes multiplication

The key property: delaying by one sample multiplies by z−1z^{-1}, so x[n−k]↔z−kX(z)x[n - k] \leftrightarrow z^{-k} X(z). The convolution y=h∗xy = h * x becomes Y(z)=H(z)X(z)Y(z) = H(z) X(z), and a filter with difference equation

y[n]+a1y[n−1]+⋯+aNy[n−N]=b0x[n]+⋯+bMx[n−M]y[n] + a_1 y[n-1] + \cdots + a_N y[n-N] = b_0 x[n] + \cdots + b_M x[n-M]

has transfer function

H(z)=Y(z)X(z)=b0+b1z−1+⋯+bMz−M1+a1z−1+⋯+aNz−NH(z) = \frac{Y(z)}{X(z)} = \frac{b_0 + b_1 z^{-1} + \cdots + b_M z^{-M}}{1 + a_1 z^{-1} + \cdots + a_N z^{-N}}

These are exactly the b and a arrays that scipy.signal.lfilter(b, a, x) takes.

python · try it yourself
import numpy as np

b = [0.2, 0.2]                       # y[n] = 0.2 x[n] + 0.2 x[n-1] + 0.6 y[n-1]
a = [1.0, -0.6]

def H(z):
    return (b[0] + b[1] / z) / (a[0] + a[1] / z)

# impulse response by running the difference equation
h, y_prev, x_prev = [], 0.0, 0.0
for n in range(8):
    x = 1.0 if n == 0 else 0.0
    y = 0.2 * x + 0.2 * x_prev + 0.6 * y_prev
    h.append(round(y, 5)); y_prev, x_prev = y, x
print("impulse response:", h)

w = 0.4                              # compare H on the unit circle with the DTFT of h
long_h = [0.2] + [0.32 * 0.6 ** (n - 1) for n in range(1, 400)]
dtft = sum(hn * np.exp(-1j * w * n) for n, hn in enumerate(long_h))
print(f"H(e^(0.4i)) = {complex(H(np.exp(1j * w))):.5f}   DTFT of h = {complex(dtft):.5f}")
impulse response: [0.2, 0.32, 0.192, 0.1152, 0.06912, 0.04147, 0.02488, 0.01493]
H(e^(0.4i)) = 0.60333-0.48921j   DTFT of h = 0.60333-0.48921j

The impulse response is 0.2,0.32,0.32⋅0.6,…0.2, 0.32, 0.32 \cdot 0.6, \ldots, and the transfer function evaluated on the unit circle equals its DTFT.

Inverse z-transform by partial fractions

To find h[n]h[n] from a rational H(z)H(z), split it into simple fractions rk1−pkz−1\frac{r_k}{1 - p_k z^{-1}}, each of which inverts to rkpknu[n]r_k p_k^n u[n]. So the impulse response is a sum of geometric sequences, one per pole pkp_k. That is the bridge to stability in the next lesson.

In software

  • scipy.signal.tf2zpk, residuez (partial fractions), freqz (evaluate on the unit circle), dlti objects.
  • SymPy can compute z-transforms of symbolic sequences via summation.

Exercises

Exercise 1: A finite sequence

What is the z-transform of x=[1,2,3]x = [1, 2, 3] (starting at n=0n = 0)?

Answer

1+2z−1+3z−21 + 2z^{-1} + 3z^{-2}.

Solution

Each sample x[n]x[n] contributes x[n]z−nx[n] z^{-n}. Finite sequences give polynomials in z−1z^{-1}, converging everywhere except z=0z = 0.

Exercise 2: Transfer function

Write H(z)H(z) for y[n]=x[n]−x[n−2]+0.5 y[n−1]y[n] = x[n] - x[n-2] + 0.5\,y[n-1].

Answer

H(z)=1−z−21−0.5z−1H(z) = \dfrac{1 - z^{-2}}{1 - 0.5 z^{-1}}.

Solution

Transform term by term: Y=X−z−2X+0.5z−1YY = X - z^{-2}X + 0.5 z^{-1} Y, so Y(1−0.5z−1)=X(1−z−2)Y(1 - 0.5z^{-1}) = X(1 - z^{-2}).

Exercise 3: Partial fractions (code)

Verify that 1(1−0.5z−1)(1−0.25z−1)=21−0.5z−1−11−0.25z−1\frac{1}{(1 - 0.5z^{-1})(1 - 0.25z^{-1})} = \frac{2}{1 - 0.5z^{-1}} - \frac{1}{1 - 0.25z^{-1}} by comparing impulse responses for n=0..5n = 0..5.

Answer

Both give 1,0.75,0.4375,0.2344,0.1211,0.06151, 0.75, 0.4375, 0.2344, 0.1211, 0.0615.

Solution
python · try it yourself
import numpy as np
n = np.arange(6)
from_fractions = 2 * 0.5 ** n - 0.25 ** n
y = []
for k in range(6):                      # y[n] = x[n] + 0.75 y[n-1] - 0.125 y[n-2]
    x = 1.0 if k == 0 else 0.0
    y.append(x + 0.75 * (y[k - 1] if k >= 1 else 0) - 0.125 * (y[k - 2] if k >= 2 else 0))
print(np.round(from_fractions, 4).tolist())
print(np.round(y, 4).tolist())
[1.0, 0.75, 0.4375, 0.2344, 0.1211, 0.0615]
[1.0, 0.75, 0.4375, 0.2344, 0.1211, 0.0615]

The denominator (1−0.5z−1)(1−0.25z−1)=1−0.75z−1+0.125z−2(1 - 0.5z^{-1})(1 - 0.25z^{-1}) = 1 - 0.75z^{-1} + 0.125z^{-2} gives the difference equation used in the loop.

Test yourself

Delaying a sequence by kk samples multiplies its z-transform by…

  1. zkz^k
  2. z−kz^{-k}
  3. kk
  4. e−ke^{-k}

The z-transform of anu[n]a^n u[n] is…

  1. 11−az−1\frac{1}{1 - a z^{-1}}
  2. 11+az\frac{1}{1 + a z}
  3. aza z
  4. eaze^{a z}

Evaluating H(z)H(z) on the unit circle z=eiωz = e^{i\omega} gives…

  1. the impulse response
  2. the frequency response
  3. the poles
  4. the step response