|
| 1 | +# Spectral Radius & Discrete Stability Margin |
| 2 | + |
| 3 | +## Overview & Motivation |
| 4 | + |
| 5 | +The spectral radius of a square matrix is the largest magnitude among all its eigenvalues. In discrete-time dynamical systems, the spectral radius of the state-transition matrix is the single most important scalar quantity: if it is strictly less than one, every state trajectory converges to zero; if it equals or exceeds one, at least one mode grows without bound or fails to decay. Rather than reporting only a binary stable/unstable flag, exposing the spectral radius and the complementary stability margin (one minus the spectral radius) gives the designer a quantitative handle on how much gain or perturbation the system can tolerate before losing stability. |
| 6 | + |
| 7 | +## Mathematical Theory |
| 8 | + |
| 9 | +### Characteristic Polynomial via Faddeev–LeVerrier |
| 10 | + |
| 11 | +Given an $n \times n$ matrix $A$, the characteristic polynomial is |
| 12 | + |
| 13 | +$$p(\lambda) = \det(\lambda I - A) = \lambda^n + c_{n-1}\lambda^{n-1} + \cdots + c_1\lambda + c_0.$$ |
| 14 | + |
| 15 | +The Faddeev–LeVerrier recurrence computes the coefficients $c_k$ without determinant expansion. Define auxiliary matrices $M_k$ by |
| 16 | + |
| 17 | +$$M_1 = A, \quad c_{n-1} = -\operatorname{tr}(M_1),$$ |
| 18 | +$$M_k = A\bigl(M_{k-1} + c_{n-k+1}I\bigr), \quad c_{n-k} = -\frac{1}{k}\operatorname{tr}(M_k), \quad k = 2, \ldots, n.$$ |
| 19 | + |
| 20 | +This recurrence requires only matrix-matrix multiplication, scalar multiplication of a matrix by the identity, and the trace, making it suitable for static (stack-allocated) computation without a heap. |
| 21 | + |
| 22 | +### Spectral Radius |
| 23 | + |
| 24 | +Given the full set of eigenvalues $\{\lambda_i\}_{i=1}^{n}$ (roots of the characteristic polynomial), |
| 25 | + |
| 26 | +$$\rho(A) = \max_{i} |\lambda_i|.$$ |
| 27 | + |
| 28 | +The roots are found numerically with the Durand–Kerner simultaneous root-finding iteration, which converges for arbitrary polynomials and requires only a fixed-size array of complex iterates. |
| 29 | + |
| 30 | +### Schur Stability |
| 31 | + |
| 32 | +A matrix $A$ is Schur-stable (the discrete-time analogue of Hurwitz stability) if and only if $\rho(A) < 1$. Every eigenvalue then lies strictly inside the complex unit disk, guaranteeing exponential decay of all modes. |
| 33 | + |
| 34 | +### Stability Margin |
| 35 | + |
| 36 | +$$\delta(A) = 1 - \rho(A).$$ |
| 37 | + |
| 38 | +A positive margin indicates Schur stability; $\delta = 0$ corresponds to marginal stability (an eigenvalue on the unit circle); $\delta < 0$ signals instability. The margin quantifies how far $\rho(A)$ is from the stability boundary. |
| 39 | + |
| 40 | +## Complexity Analysis |
| 41 | + |
| 42 | +| Case | Time | Space | Notes | |
| 43 | +|---------|-----------------------------|--------------|-----------------------------------------------------------------------| |
| 44 | +| Best | $O(n^3)$ | $O(n^2)$ | Faddeev–LeVerrier dominates; two $n\times n$ temporaries on the stack | |
| 45 | +| Average | $O(n^3 + n \cdot I)$ | $O(n^2 + n)$ | $I$ Durand–Kerner iterations, typically $\ll 200$ | |
| 46 | +| Worst | $O(n^3 + n \cdot I_{\max})$ | $O(n^2 + n)$ | Near-repeated roots slow DK convergence | |
| 47 | + |
| 48 | +The Faddeev–LeVerrier step executes $n$ matrix multiplications each costing $O(n^3)$, giving $O(n^4)$ total; for the small dimensions typical of embedded control matrices ($n \le 6$) this is negligible. |
| 49 | + |
| 50 | +## Step-by-Step Walkthrough |
| 51 | + |
| 52 | +Consider $A = \begin{pmatrix} 0 & -1 \\ 1 & 0 \end{pmatrix}$ (90° rotation, $\rho = 1$). |
| 53 | + |
| 54 | +1. **k = 1**: $M_1 = A \cdot 0 + I \cdot c_0$. With $c_0 = 1$: $M_1 = I$. Then $c_1 = -\tfrac{1}{1}\operatorname{tr}(A \cdot M_1) = -\operatorname{tr}(A) = 0$. |
| 55 | +2. **k = 2**: $M_2 = A(M_1 + c_1 I) = A \cdot I = A$. Then $c_2 = -\tfrac{1}{2}\operatorname{tr}(A \cdot A) = -\tfrac{1}{2}\operatorname{tr}(-I) = 1$. |
| 56 | + |
| 57 | +Characteristic polynomial: $\lambda^2 + 0\lambda + 1 = \lambda^2 + 1$. Roots: $\pm i$, magnitudes both 1. $\rho = 1$. |
| 58 | + |
| 59 | +## Pitfalls & Edge Cases |
| 60 | + |
| 61 | +- **Near-repeated roots**: Durand–Kerner converges slowly when two or more eigenvalues are nearly identical. The stability conclusion (inside/outside unit disk) is unaffected, but the raw $\rho$ value may have larger numerical error. |
| 62 | +- **Identity approximation in Matrix::Identity()**: This implementation builds its own exact identity to avoid reliance on library internals. |
| 63 | +- **Ill-conditioned characteristic polynomials**: For large $n$ the polynomial coefficients can have widely different magnitudes, degrading root-finder precision. The algorithm is intended for small matrices ($n \le 6$) typical of discrete-time state-space models. |
| 64 | +- **Size = 1 case**: Handled directly as $\rho = |a_{11}|$, bypassing polynomial computation. |
| 65 | +- **Zero matrix**: $\rho = 0$, $\delta = 1$ (maximally stable). Handled correctly by the recurrence. |
| 66 | + |
| 67 | +## Variants & Generalizations |
| 68 | + |
| 69 | +- **Power iteration** computes only the dominant eigenvalue magnitude without the full spectrum; cheaper for large $n$ but provides no stability margin without additional eigenpair deflation. |
| 70 | +- **QR algorithm** (Jacobi, Hessenberg QR) finds all eigenvalues more robustly for large or symmetric matrices; too expensive and heap-dependent for small embedded targets. |
| 71 | +- **Continuous-time analogue**: Replace the unit-disk criterion with the left half-plane criterion; Routh–Hurwitz or Lyapunov-based approaches apply. |
| 72 | + |
| 73 | +## Applications |
| 74 | + |
| 75 | +- Verifying discrete-time state-feedback or observer designs remain within the unit disk after coefficient quantisation. |
| 76 | +- Checking closed-loop stability after LQR or pole-placement synthesis before deployment. |
| 77 | +- Computing gain/phase margins indirectly by perturbing the loop gain and re-evaluating $\rho$. |
| 78 | +- Monitoring on-line whether a time-varying system's frozen eigenvalues have drifted outside the unit disk. |
| 79 | + |
| 80 | +## Connections to Other Algorithms |
| 81 | + |
| 82 | +- Uses **Durand–Kerner** (polynomial root-finder) for the eigenvalue computation stage. |
| 83 | +- The characteristic polynomial recurrence is mathematically related to **Leverrier's method** for matrix inverses and adjoints. |
| 84 | +- The Schur-stability criterion is the discrete-time counterpart of the Hurwitz criterion used in continuous-time control analysis. |
| 85 | +- The stability margin scalar is a prerequisite for **TESTING.md** evaluation metrics that require a quantitative stability distance. |
| 86 | + |
| 87 | +## References & Further Reading |
| 88 | + |
| 89 | +- Faddeev, D. K. & LeVerrier, U. J. F. — classical matrix identity; see G. H. Golub & C. F. Van Loan, *Matrix Computations*, 4th ed., Section 7.3. |
| 90 | +- Durand, E. (1960) and Kerner, I. O. (1966) — simultaneous root-finding; see *Numerical Recipes in C*, 3rd ed., Section 9.5. |
| 91 | +- Schur stability: K. J. Åström & B. Wittenmark, *Computer-Controlled Systems*, 3rd ed., Chapter 3. |
0 commit comments