Z-Transforms and Linear Recursions¶
The motivating problem for this lecture goes as follows.
A train leaves the depot empty.
At each station, on average, 40 people mount, while 20% of the riders dismount.
Suppose we are consultants for a train company, who asks us: Will there ever be a train long enough to accommodate the 40 people mounting at each station?
Signal Processing¶
Introducing signal processing, consider the schematic for a data acquisition system in Fig. 9.

Fig. 9 Schematic of a data acquisition system.¶
The data acquisition process has three stages:
A process is measured by a sensor.
The measurements are converted from analog to digital (A-D).
The computer manipulates, stores, and displays the data.
We are concerned with the third stage of the acquisition process.
The Z-Transform of a signal¶
To introduce the z-transform of a signal, consider Fig. 10.

Fig. 10 Every \(T\) time units, a signal is sampled.¶
In studying signals, we are interested in capturing their growth or decay. As our first example, let us consider a constant signal. In the series
replace \(z\) by \(1/z\) to obtain:
So the z-transform of \(x = \{ 1, 1, 1, 1, 1, 1, 1, \ldots \}\) is
For any constant \(\alpha\), \(x = \{ \alpha, \alpha, \alpha, \ldots \}\) has z-transform \(\displaystyle X = \frac{\alpha z}{z-1}\).
Our second example has exponential growth. Again, in the series
replace \(z\) by \(2/z\) to obtain:
So the z-transform of \(x = \{ 1, 2, 4, 8, 16, 32, 64, \ldots \}\) is
Observe: the essence of the signal, the growth rate is the root of \(z-2\).
Our third example has exponential decay. Once more, in the series
replace \(z\) by \(1/(2z)\) to obtain:
So the z-transform of \(\displaystyle x = \left\{ 1, \frac{1}{2}, \frac{1}{4}, \frac{1}{8}, \frac{1}{16}, \frac{1}{32}, \frac{1}{64}, \ldots \right\}\) is
The essence of the signal, the decay rate is the root of \(z-1/2\).
Delayed Signals and Weighted Averages¶
What is the z-transform of a delayed signal?
Let \(x = \{ x_0, x_1, x_2, x_3, x_4, x_5, x_6, \ldots \}\) have z-transform \(\displaystyle X = \sum_{k=0}^\infty x_k z^{-k}\).
Let \(y\) be the signal \(x\) with one time unit delay:
\[y = \{ 0, x_0, x_1, x_2, x_3, x_4, x_5, x_6, \ldots \}.\]
What is the z-transform \(Y\) of \(y\)? Well, consider
We then apply the definition of the z-transform:
to find \(z^{-1} X\) as the z-transform of the delayed signal.
What is the z-transform of a weighted average?
Let \(x\) be a signal with z-transform \(X\).
Let us make a new signal \(y\), with a weighted average.
\[y_k = \alpha x_k + \beta x_{k-1}, \quad \alpha + \beta = 1, \quad x_{-1} = 0.\]
What is the z-transform \(Y\) of \(y\)? We compute:
Solving Linear Recursions by Z-Transforms¶
Recall our motivating problem:
A train leaves the depot empty.
At each station, on average, 40 people mount, while 20% of the riders dismount.
We can define a recursion relation for this problem:
Let \(x_n\) be the number of riders at the \(n\)-th station. \(x_0 = 0\), as the train leaves the depot empty.
As 20% dismount, 80% or 4 out of five remain, forty are added:
\[x_n = \left( \frac{4}{5} \right) x_{n-1} + 40, \quad n = 1, 2, \ldots\]
With z-transforms we can solve linear recursions.
The general method to solve a linear recursion proceeds in three steps:
Transform the recursion to the frequency domain.
Solve the transformed recursion.
Transform the solution back to the time domain.
For our motivating problem, we derived the linear recursion:
The z-transform is
We solve to obtain \(X\) as an expression in \(z\):
and find
To process this answer further, we need the partial fraction decomposition.
Observe: \(\alpha_i \not= \alpha_j\), for all \(i \not= j\) implies \(q'(\alpha_i) \not = 0\).
For the proof of this rewriting of a quotient we apply Lagrange interpolation. The Lagrange form of the polynomial interpolating \(p(x)\) through \(\alpha_1\), \(\alpha_2\), \(\ldots\), \(\alpha_n\) is
Because
the interpolation problem has a unique solution, and
\(\deg(p) < n\),
the Lagrange form of the interpolating polynomial equals \(p(x)\). Rewriting the Lagrange interpolating polynomial then goes as follows.
as
This completes the proof.
Returning now once more to our motivating problem, for the z-transform, we found:
And then we apply
to find
Then we arrive at the solution combining
and
which gives
Observe that we find 200 as an upper bound, which answers the original question.
For completeness, we bring the solution from the frequency domain into the time domain. We compute the inverse of
as follows:
Let \(x_1\) be the inverse of \(X_1\): \(x_1 = \{ 1, 1, 1, \ldots \}\).
Let \(x_2\) be the inverse of \(X_2\): \(\displaystyle x_2 = \frac{4}{5} \left\{ 1, \frac{4}{5}, \left( \frac{4}{5} \right)^2, \ldots \right\}\).
Now we make a linear combination:
for \(k= 1, 2, \ldots\), using the initial condition \(x_0 = 0\).
While our motivating problem was simple enough to be solved by hand,
most problems are not that simple.
Below is an interactive Julia session using sympy.rsolve
to solve our recursion.
julia> using SymPy
julia> n = Sym("n")
n
julia> x = SymFunction("x")
x
julia> eq = Eq(x(n), (4/5)*x(n-1) + 40)
x(n) = 0.8x(n - 1) + 40
julia> init = Dict(x(0) => 0)
Dict{Sym, Int64} with 1 entry:
x(0) => 0
julia> sympy.rsolve(eq, x(n), init)
n
200.0 - 200.0 0.8
A plot of the solution is shown in Fig. 11.

Fig. 11 Plot of a solution to a linear recursion.¶
As we can see from the horizontal asymptote at 200 in Fig. 11 the solution to our motivating problem: Will there ever be a train long enough to accommodate the 40 people mounting while 20% are dismounting at each station? is to have a train with 200 seats. The plot in Fig. 11 also shows that after 10 stops, the train starts to become very full. While mathematically sound, the solution does not seem realistic enough as the number of people of course has to be a whole number. The Monte Carlo simulation suggested in the exercises can provide a more realistic model.
Exercises¶
Find the z-transform of 1, 2, 3, 1, 2, 3, 1, 2, 3, \(\ldots\)
Show that the z-transform of a linear combination of two signals is the linear combination of the two z-transforms of the signals.
Set up a Monte Carlo simulation for our motivating problem:
At each stop, each rider on board of the train flips a loaded coin so on average one out of five on board dismount.
Run the simulation for 20 stops, each simulation results in a vector of 20 integers, counting the number of riders on board.
Run the simulation sufficiently many times (e.g.: 1,000) and make a plot of the average counts for each stop. Compare your plot with the plot of the solution of the recursion.
Consider the compound interest rate \(i\). \(x(n)\) is the balance after compounding \(n\) times.
Apply the z-transform method to solve
\[x(n+1) = (1+i) x(n), \quad x_{-1} = 1/(1+i).\]Use
sympy.rsolve
to solve the recursion.
Compute the partial fraction decomposition of \(\displaystyle \frac{1}{(z-1)(z-2)(z-3)}\).
You may use computer algebra for this computation.
Bibliography¶
Charles R. MacCluer, start of Chapter 3 of Industrial Mathematics. Modeling in Industry, Science, and Government, Prentice Hall, 2000.
J.R. Ragazzini and L.A. Zadeh: The Analysis of Sampled-Data Systems. Transactions of the American Institute of Electrical Engineers, Part II: Applications and Industry. 71 (5): 225-234, 1952.