# Z-Transform: Stability

## Introduction

*Knowledge required for this post:
z-transform introduction (transfer functions, impulse responses)*

This the second post of my series about the z-transform. While the first post was more like an introduction, this post will cover one of the z-transform's applications: checking if an LTI system is stable.

When we talk about stability we want to refer to the so called **BIBO (bounded-input, bounded-output) stability**.
As the name already implies, a BIBO stable system should respond with a bounded output to a bounded input.
One crucial thing to keep in mind is that bounded input refers to **all** possible inputs.
It is not sufficient to take only one input and show that the system is stable for this particular input.

An example for a unstable system is the well-known audio feedback.
If you don't correctly arrange your microphones and speakers when planning a concert,
only a small sound (bounded-input) at the microphone is enough to create a loop feedback and thus an extremely annoying squealing.
Luckily the system stops being linear at some point, saving your equipment from becoming a black hole.

To prevent such desasters, it would be interesting to know if and when a system becomes unstable in advance.
And you might have guessed it: the z-transform is the right tool to obtain this information.
In the next sections, we will use the z-transform to show if a discrete LTI is stable just by looking at the transfer function!

## Definition

As always let's look at some definitions to get a better understanding of stability and boundedness.
By reading textbooks or Wikipedia articles you can find out that a function \(f(k)\) is bounded if there exists a constant \(c\)
such that:
$$ |f(k)|\leq c < \infty \quad \text{for all } k $$
So, if our system is stable, we can find a constant for the input \(x(k)\):
$$|x(k)|\leq c_x < \infty \quad \text{for all } k $$
And for the output \(y(k)\):
$$|y(k)|\leq c_y < \infty \quad \text{for all } k$$
Let's look at an illustrative example since this might be confusing at first:
In the figure above, you can see a sine wave \(f(k)=sin(k\cdot 2 \pi)\) for which we can easily find a constant such that:
$$|f(k)| \leq c=1$$
This is illustrated by the grey "tube" which encapsulates the function.
Therefore, this function is bounded.

An unbounded example is \(f(k)=e^{k} \cdot sin(k \cdot 2 \pi)\):
Obviously it is not possible to find a "tube" which encsapsulates the function.

With this definition in my mind we will now look at discrete LTI systems. As shown in the first post the input-output relation can be represented by convoluting the input \(x(k)\) with a system's impulse response \(h(k)\): $$ y(k) = h(k) * x(k) = \sum_{n=-\infty}^{\infty} h(n) \cdot x(k-n)$$

The question we now want to answer is: If we know that the input \(x(k)\) is bounded,
which requirements have to be fullfilled by the impulse response \(h(k)\) to get a bounded output \(y(k)\)?

The simple answer is: if the impulse is bounded then output is bounded as well.

Let's try to show this mathematically starting with the absolute values of the input-output value relations
(you can also find this proof at the corresponding Wikipedia article):
$$
|y(k)| = |\sum_{n=-\infty}^{\infty} h(n) \cdot x(k-n)|
$$
Using the triangle inequality:
$$|y(k)| \leq \sum_{n=-\infty}^{\infty} |h(n)| \cdot |x(k-n)|$$
Since we assumed that our input is bounded, we can substitute it by a constant:
$$|y(k)| \leq \sum_{n=-\infty}^{\infty} |h(n)| \cdot c_x$$
$$|y(k)| \leq c_x \cdot \sum_{n=-\infty}^{\infty} |h(n)| $$
In order, to have a bounded \(y(k)\) we require \(h(k)\) to be bounded:

Note, that we used the triangular inequality which leads to an upward estimation.
At this point we can say that the finite sum implies stability, but we cannot say that stability implies a finite sum.
However, there is a proof that this implication goes both ways (I found one in
*Digital Signal Processing: Principles, Algorithms & Applications (3rd Ed.): pages 88-89*)
But we don't want to get lost in proofs, so please refer to the book if you want to get every piece of knowledge there is ;)

## Applying the z-transform

As promised we will use the transfer function (and therefore the z-transform) to determine if a system is stable or not.
But first, we have to introduce a few new terms starting with the so called **Region Of Convergence (ROC)**.
In order to understand this term we will use the following example system:
This system can be described by the following transfer function:
$$Y(z) = Y(z) \cdot 0.5z^{-1} + X(z)$$
$$H(z) = \frac{1}{1-0.5z^{-1}}$$
If we want to be able to get the impulse response from this transfer function, we need to use the geometric series:

So, how can we use this knowledge for determining the stability? Let's do some math with the transfer function and try to find a relation to the stability condition: $$ |H(z)| = |\sum_{k=-\infty}^{\infty}h(k)z^{-k}| \leq \sum_{k=-\infty}^{\infty}|h(k)z^{-k}| = \sum_{k=-\infty}^{\infty}|h(k)||z^{-k}| $$ Choosing \(|z|=1\) results in: $$ |H(|z|=1)| \leq \sum_{k=-\infty}^{\infty}|h(k)|$$ As you can see the right term is actually the necessary condition for stability. This means, if a system is stable then the z-transform converges for \( |z|=1 \). We can also express this as:

**If a system is stable, the unit circle is included in the region of convergence.**

If we regard our example, we have a ROC of \(0.5 < |z|\) which means that the system is stable! However, there is one thing I didn't tell you yet...

## Hol'up: Ambiguity and Causality

In the previous section we determined the ROC for the following expression: $$H(z) = \frac{1}{1-0.5z^{-1}}$$ Which converges for \(|z|>0.5\) to: $$H(z) = \sum_{k=0}^{\infty} 0.5^k \cdot z^{-k}$$ Using basic math or partial fraction decomposition we can rearrange this to: $$H(z) = 1 - \frac{0.5}{0.5-z}$$ Which converges for \(|z|<0.5\) to $$H(z) = 1- 0.5 \cdot \sum_{k=0}^{\infty} 2^k \cdot z^{k}$$

This is seems to be really confusing at first. The same transfer functions seems to have multiple impulse responses and multiple ROCs. So which one is now correct?!

The sad truth about the z-transform is that it is actually ambigous...
Multiple impulse responses can be mapped to the same z-transform.
In the above case the following impulse responses are both valid time domain representations of the transfer function:
There are two important differences between them.

First, \(h_1(k)\) is stable while \(h_2(k)\) is not stable.
As we are trying to show stability or instability it is quite important to know the corresponding impulse response.

The second is that \(h_1(k)\) is **causal** while \(h_2(k)\) is **anticausal**.
An anticausal system solely depends on the future values.
This means that its difference equation only includes terms such as \(y(k+2)\) or \(x(k+7)\).
You can directly see this by looking at the impulse response of \(h_2(k)\).
We get a response even tough the we haven't fed in the "1".
As such a system is predicting the future it cannot be used for realtime applications.
In contrast to an anticausal system, a causal system depends only one past values and therefore only includes
terms such as \(y(k-2)\) or \(x(k-3)\) in its difference equation. Such a system is realtime capable.

If we only had the transfer function there would be no way to determine the stability of the underlying system!
Thus, we need more information!

For our example transfer function, we know that we derived it the following difference equation:
$$y(k)=0.5 \cdot y(k-1) + x(k)$$
We know that our system has to be causal (there are no future value terms).
Therefore \(h_1(k)\) is the corresponding impulse response and our system is stable!

Let's do a quick summary of this section:

- The z-transform is ambigous. Multiple impulse responses can have the same z-transform.
- If we want to relate a z-transform to an impulse response we need more information such as the ROC.
- Causal systems seem to converge for \(|z|>a\) while anticausal systems converge for \(|z| < a\). We will proove this in the next section.

## Poles and stability

In the previous section it was shown how the stability and ROC for one particular system was determined.
But how can we generalize this concept and directly "see" from the transfer function if a system is stable?

The first step is to rearrange the transfer function.
We use the fact that every transfer function we have for an LTI system is basically just a **rational function**.
So, a function with a numerator polynom and a denominator polynom. For example:
$$H(z) = \frac{z+1}{z^2-5z+6}$$
Using **partial fraction decomposition** a rational function can be expressed as sum of the following simple terms:
$$\frac{a_i}{(z-d_{i,\infty})^j}$$
Where \(d_{i,\infty}\) is a so called **pole**. At a pole the denominator is 0.
Using the geometric series, we can now determine for each of the terms if they do converge.
If all the terms converge, our transfer function is stable.

As an example let us try to analyze the stability the given system. First we try to determine the poles. You can simply do this by using the pq-formula or by intensively staring and hoping that your brain comes up with an idea: $$H(z)=\frac{z+1}{z^2-5z+6} = \frac{z+1}{(z-3) \cdot (z-2)}$$ As you can see from the denominator we have two poles, one at \(d_{1,\infty}=3\) and one at \(d_{2,\infty}=2\). By doing some further calculations the term can be expressed as: $$H(z)=\frac{-4}{3-z}+\frac{3}{2-z} $$ Note, we can also represent this as: $$H(z)=\frac{z^{-1}+z^{-2}}{1-5z^{-1}+6z^{-2}} = \frac{z^{-1}+z^{-2}}{(1-3z^{-1}) \cdot (1-2z^{-1})} =\frac{1}{6}+\frac{-3/2}{1-2z^{-1}}+\frac{4/3}{1-3z^{-1}}$$ If we want to analyze causal systems, this would be the preferred representation. It is important to note that this representation has the same poles!

As a next step we have to analyze the convergence of the single summands.
Only if all terms converge, the overall transfer function will converge as well.
Assuming we have a causal system the ROC for the summands are \(|z|>3\) and \(|z|>2\).
The area where both of them converge is \(|z|>3\).
If we'd assume an anticausal system, the ROC would be \(|z|<2\).

From this example we can see that **the ROC is determined by the poles of the transfer function**.
Here is an Argand diagram with the corresponding poles to visualize this very important statement (causality assumed):
In the diagram the poles are represented by an "x".
You can see that the ROC is determined by the pole with highest absolute value.
Furthermore, this system is not stable as the unit circle is not included in the ROC.

In general, this leads us to the following two important statements:

**For causal systems: A system is stable if all the poles are within the unit circle**

**For anticausal systems: A system is stable if all the poles are outside the unit circle**

## Summary

In this post it was shown how the z-transform can be used to determine if an LTI is stable. The most important points are:

- A system is stable if the absolute sum of its impulse response is finite: $$ c_h = \sum_{n=-\infty}^{\infty} |h(n)| < \infty $$
- A system is stable if the Region Of Convergence (ROC) of the transfer function includes the unit circle
- Unfortunately the transfer function is ambigous. Multiple impulse responses can be mapped to the same transfer function
- To resolve the ambiguity we need more information about the underlying system (such as causality or dircetly the ROC)
- A causal system depends only on past values while an anticausal system depends only on future values
- Causal systems converge for \(|z|>a\) (the ROC includes infinity) while anticausal systems converge for \( |z| < a \) (the ROC includes 0)
- With the poles of a transfer function the ROC can easily be determined
- For a causal system all poles have to be within the unit circle to ensure stability
- For a anticausal system all poles have to be outside the unit circle to ensure stability