Stability analysis (pole-zero plot) in Signal Processing - Time & Space Complexity
We want to understand how the time to analyze system stability grows as the system size increases.
Specifically, we ask: How does checking poles and zeros scale with input size?
Analyze the time complexity of the following code snippet.
import numpy as np
from scipy.signal import tf2zpk
# Given numerator and denominator coefficients
num = np.array([1, -0.5, 0.25])
den = np.array([1, -1.2, 0.36])
# Compute zeros, poles, and gain
zeros, poles, gain = tf2zpk(num, den)
# Check stability by examining poles
stable = np.all(np.abs(poles) < 1)
This code finds poles and zeros of a system and checks if all poles lie inside the unit circle to decide stability.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Finding roots of the denominator polynomial (poles).
- How many times: The root-finding algorithm processes all coefficients once, internally using iterative methods.
As the polynomial degree (input size) grows, root-finding takes more time because it must handle more coefficients.
| Input Size (degree n) | Approx. Operations |
|---|---|
| 10 | About 1,000 operations |
| 100 | About 1,000,000 operations |
| 1000 | About 1,000,000,000 operations |
Pattern observation: Operations grow roughly with the cube of the polynomial degree.
Time Complexity: O(n^3)
This means the time to find poles grows roughly with the cube of the number of coefficients.
[X] Wrong: "Finding poles is a simple linear scan and takes O(n) time."
[OK] Correct: Root-finding involves complex iterative calculations that grow faster than linearly with polynomial degree.
Understanding how stability checks scale helps you explain system analysis efficiency clearly and confidently.
"What if we used a simpler method that only approximates poles? How would the time complexity change?"
Practice
Solution
Step 1: Understand pole location and stability
Stability depends on poles, not zeros. Poles with negative real parts mean the system's response decays over time.Step 2: Identify correct pole location for stability
Poles in the left half-plane (negative real parts) ensure the system is stable.Final Answer:
All poles must lie in the left half of the complex plane (negative real parts). -> Option AQuick Check:
Stable system = poles with negative real parts [OK]
- Confusing zeros with poles for stability
- Thinking poles on imaginary axis are stable
- Assuming zeros affect stability directly
Solution
Step 1: Recall scipy.signal function for pole-zero plot
The function to plot poles and zeros is pzmap, not pzplot.Step 2: Check correct usage with plotting enabled
Using pzmap with plot=True plots the pole-zero map correctly.Final Answer:
signal.pzmap(system, plot=True) -> Option AQuick Check:
Use pzmap with plot=True for pole-zero plot [OK]
- Using non-existent function pzplot
- Forgetting plot=True argument
- Confusing function names
poles = [-1+2j, -1-2j, 0.5], what can you say about the system's stability?Solution
Step 1: Analyze the real parts of each pole
Poles are -1+2j (real part -1), -1-2j (real part -1), and 0.5 (real part 0.5).Step 2: Determine stability from pole real parts
Since one pole has positive real part (0.5), the system is unstable.Final Answer:
The system is unstable because one pole has a positive real part. -> Option DQuick Check:
Positive real pole means unstable system [OK]
- Ignoring positive real part pole
- Assuming complex conjugates guarantee stability
- Confusing marginal stability with instability
from scipy import signal system = signal.TransferFunction([1, 3], [1, 2, 1]) signal.pzplot(system)
What is the error and how to fix it?
Solution
Step 1: Identify the function causing error
The function pzplot does not exist in scipy.signal, causing the error.Step 2: Use correct function to plot poles and zeros
Use pzmap(system, plot=True) to plot poles and zeros correctly.Final Answer:
Function pzplot does not exist; use pzmap(system, plot=True) instead. -> Option CQuick Check:
Use pzmap, not pzplot, for pole-zero plots [OK]
- Using non-existent pzplot function
- Swapping numerator and denominator unnecessarily
- Wrong import statement causing confusion
-0.5, -1+1j, -1-1j and zeros at 0, -2. Which statement best describes the system's stability and response?Solution
Step 1: Check pole locations for stability
All poles have negative real parts (-0.5, -1), so system is stable.Step 2: Analyze pole types for response behavior
Complex conjugate poles (-1±1j) cause oscillations that decay over time.Step 3: Consider zeros' effect on stability
Zeros do not affect stability directly; zeros at 0 and -2 are not in right half-plane.Final Answer:
The system is stable with oscillatory decay due to complex poles. -> Option BQuick Check:
Negative real poles + complex = stable oscillatory decay [OK]
- Confusing zeros with poles for stability
- Thinking zeros at zero cause instability
- Ignoring oscillatory nature of complex poles
Ready to prove it?
Pass the test and this pattern moves unknown
