LyapunovSolver<T>
Models & Types · AiDotNet.Control
Solves the continuous and discrete Lyapunov equations exactly.
For Beginners
The question is whether a system settles down or blows up. Rather than computing eigenvalues, this looks for a bowl-shaped energy function that the system always slides down. If one exists, the system is stable — and you have the energy function, which is worth more than the yes/no answer.
How It Works
Solves AᵀP + PA + Q = 0 (continuous) and AᵀPA − P + Q = 0 (discrete) for the
symmetric P. Both are linear in P, so unlike the Riccati equations these need no
iteration at all: rewriting the unknown matrix as a vector turns each into an ordinary linear
system that a single factorization solves.
What the answer means. Lyapunov’s theorem: the system is stable exactly when, for every
positive-definite Q, the solution P comes back positive definite. That gives a
stability test requiring no eigenvalues — and more usefully, xᵀPx is then an explicit
energy-like quantity that decreases along every trajectory, which is a certificate of stability
rather than merely a verdict.
Where else it turns up. With Q = BBᵀ the solution is the controllability Gramian,
measuring how easily each direction of the state space can be driven; with Q = CᵀC it is
the observability Gramian, measuring how visibly each direction shows up in the outputs.
Comparing the two is the basis of balanced model reduction — the states that are both hard to
reach and hard to see are the ones safe to discard.
On the method. Writing the unknown as a vector produces an n²-by-n² system,
which is direct and exact but grows quickly. For the sizes control problems actually reach — a
handful to a few dozen states — this is immediate, and it has the decisive advantage of needing
no ordered Schur factorization, which the asymptotically better Bartels-Stewart algorithm does.
The coefficients are built by expanding the equation entry by entry rather than through Kronecker
products, which keeps the indexing conventions from being a source of silent error.
Constructors
| Constructor | Summary |
|---|---|
LyapunovSolver() |
Methods
| Method | Summary |
|---|---|
Matrix<T> ControllabilityGramian(Matrix<T> stateMatrix, Matrix<T> inputMatrix, ControlTimeDomain timeDomain) |
Returns the controllability Gramian, which measures how easily each direction of the state space can be driven by the inputs. |
Matrix<T> ObservabilityGramian(Matrix<T> stateMatrix, Matrix<T> observationMatrix, ControlTimeDomain timeDomain) |
Returns the observability Gramian, which measures how visibly each direction of the state space shows up in the outputs. |
Matrix<T> SolveContinuous(Matrix<T> stateMatrix, Matrix<T> constantTerm) |
Solves the continuous-time Lyapunov equation AᵀP + PA + Q = 0. |
Matrix<T> SolveDiscrete(Matrix<T> stateMatrix, Matrix<T> constantTerm) |
Solves the discrete-time Lyapunov (Stein) equation AᵀPA − P + Q = 0. |