LyapunovSolve[a,c]
finds a solution
of the matrix Lyapunov equation
.
LyapunovSolve[a,b,c]
solves
.
LyapunovSolve[{a,d},c]
solves
.
LyapunovSolve[{a,d},{b,e},c]
solves
.
LyapunovSolve
LyapunovSolve[a,c]
finds a solution
of the matrix Lyapunov equation
.
LyapunovSolve[a,b,c]
solves
.
LyapunovSolve[{a,d},c]
solves
.
LyapunovSolve[{a,d},{b,e},c]
solves
.
Details
- LyapunovSolve solves the continuous-time Lyapunov and Sylvester equations.
- LyapunovSolve works on both numerical and symbolic matrices.
Examples
open all close allBasic Examples (1)
Scope (7)
{a, c} = {(| | |
| -- | -- |
| -3 | 2 |
| -1 | -1 |), (| | |
| - | - |
| 1 | 0 |
| 0 | 1 |)};
LyapunovSolve[a, c]//MatrixForma.% + %.a - cLyapunovSolve[(| | | |
| -- | -- | - |
| -1 | 1 | 0 |
| -1 | -1 | 1 |
| 1 | 1 | 0 |), (| | | |
| -- | -- | -- |
| -2 | 0 | 0 |
| 0 | -1 | 0 |
| 0 | 0 | -3 |), -(| | | |
| -- | -- | -- |
| c1 | 0 | 0 |
| 0 | c2 | 0 |
| 0 | 0 | c3 |)]Solve
for coefficient matrices with different dimensions:
N@LyapunovSolve[a = (| | | | |
| - | - | - | - |
| 1 | 2 | 3 | 4 |
| 4 | 5 | 6 | 7 |
| 7 | 8 | 9 | 1 |
| 0 | 0 | 0 | 0 |), b = (| | | |
| - | -- | - |
| 1 | -1 | 0 |
| 1 | 1 | 0 |
| 0 | 0 | 2 |), c = (| | | |
| -- | -- | -- |
| 12 | 10 | 12 |
| 24 | 22 | 24 |
| 27 | 25 | 27 |
| 12 | 10 | 12 |)]//MatrixFormLyapunovSolve[{a = (| | | |
| ------ | ------ | ------ |
| -0.49 | -0.371 | -0.193 |
| 0.967 | 0.87 | 0.134 |
| -0.464 | -0.86 | 0.204 |), d = (| | | |
| ------ | ------- | ------ |
| 1.853 | -0.0728 | 0.5857 |
| 0.922 | 1.775 | -1.583 |
| -0.185 | -1.237 | -0.069 |)}, c = (| | | |
| ----- | ------ | ------ |
| 0.014 | -0.259 | -0.117 |
| 0.418 | -0.202 | 0.484 |
| -0.2 | 0.44 | -0.074 |)]//MatrixFormLyapunovSolve[{a = (| | |
| ----- | ----- |
| 1.543 | 0.566 |
| 1.795 | 1.361 |), d = (| | |
| ----- | ----- |
| 0.225 | 0.093 |
| 0.167 | 0.336 |)}, {b = (| | |
| ----- | ----- |
| 0.432 | 0.173 |
| 0.579 | 1.221 |), e = (| | |
| ----- | ----- |
| 2.561 | 2.719 |
| 1 | 1.47 |)}, c = (| | |
| ----- | ----- |
| 1.495 | 1.445 |
| 1.188 | 1.343 |)]//MatrixFormSolve the Lyapunov equation
with symbolic coefficients:
LyapunovSolve[(a), (c)]Obtain the symbolic solution of
:
LyapunovSolve[{(a), (d)}, {(b), (e)}, (c)]Applications (7)
Test the stability of
by checking if the solution of
is positive definite for a negative definite
:
a = (| | | |
| ------- | ------- | ------- |
| -2.03 | -1.197 | -0.9514 |
| -0.1513 | -1.98 | 0.186 |
| 0.06049 | -0.6359 | -2.63 |);LyapunovSolve[a, -(| | | |
| - | - | - |
| 1 | 0 | 0 |
| 0 | 2 | 0 |
| 0 | 0 | 3 |)]//PositiveDefiniteMatrixQAs expected, the eigenvalues are in the left half-plane:
Eigenvalues[a]a = (| | | |
| ------- | ------- | ------- |
| 1.29 | -0.2947 | 0.573 |
| -0.2275 | 1.036 | -0.3158 |
| 0.3037 | -0.5616 | 1.714 |);LyapunovSolve[a, -(| | | |
| - | - | - |
| 1 | 0 | 0 |
| 0 | 2 | 0 |
| 0 | 0 | 3 |)]//PositiveDefiniteMatrixQEigenvalues[a]Compute the controllability Gramian of a stable continuous-time system:
{a, b} = {(| | |
| -- | -- |
| -1 | 1 |
| 1 | -2 |), (| |
| - |
| 1 |
| 0 |)};LyapunovSolve[a, -b.b]ControllabilityGramian[StateSpaceModel[{a, b}]]Compute the observability Gramian of a stable continuous-time system:
{a, c} = {(| | |
| ------- | ------- |
| -(7/40) | (3/40) |
| (3/40) | -(7/40) |), (1 1)};LyapunovSolve[a, -c.c]ObservabilityGramian[StateSpaceModel[{a, {{Subscript[b, 1]}, {Subscript[b, 2]}}, c}]]Compute the
norm of an asymptotically stable continuous-time system:
{a, b, c} = {(| | | |
| -- | -- | -- |
| -1 | 2 | 3 |
| 0 | -2 | 2 |
| 0 | 0 | -3 |), (| | |
| - | - |
| 1 | 1 |
| 1 | 1 |
| 1 | 1 |), (| | | |
| - | - | - |
| 1 | 1 | 1 |
| 1 | 1 | 1 |)};x = LyapunovSolve[a, -b.b];h2norm = Sqrt[Tr[c.x.c]]//NCompute the feedback gains that place poles at desired locations:
{a, b} = {(| | | |
| -- | ---- | ---- |
| -3 | 0 | 0 |
| 0 | -0.5 | -0.1 |
| 0 | 0.1 | -0.5 |), (| | |
| - | - |
| 1 | 0 |
| 0 | 1 |
| 0 | 0 |)};poles = {-6, -3 - 0.2I, -3 + 0.2I};With[{kk = ConstantArray[1, {2, 3}], aa = DiagonalMatrix[poles]}, kk.Inverse[LyapunovSolve[a, -aa, b.kk]]]//ChopEigenvalues[a - b.%]For MIMO systems, the feedback gains are not unique:
With[{kk = {{1, 0, 0}, {0, 1, 1}}, aa = DiagonalMatrix[poles]}, kk.Inverse[LyapunovSolve[a, -aa, b.kk]]]//ChopEigenvalues[a - b.%]Construct an observer for a StateSpaceModel:
{a, b, c} = {(| | |
| -- | -- |
| -1 | 3 |
| -3 | -1 |), (| |
| - |
| 1 |
| 0 |), (1 0)};ssm = StateSpaceModel[{a, b, c}]First, choose an appropriate
and
such that the Lyapunov equation
yields a nonsingular solution:
f = (| | |
| -- | -- |
| -1 | 0 |
| 0 | -3 |);g = (| |
| - |
| 1 |
| 3 |);Subscript[x, L] = LyapunovSolve[-f, a, g.c]//N;
MatrixRank[Subscript[x, L]] == 2Then construct the observer as
,
, where
is the observer state vector,
is the output,
is the input, and
is the estimated state vector:
obs = StateSpaceModel[{f, ArrayFlatten[{{g, Subscript[x, L].b}}], Inverse[Subscript[x, L]]}, SystemsModelLabels -> {{"y", "u"}, {"x1hat", "x2hat"}, {"z1", "z2"}}]Compute the estimated state trajectories for a UnitStep input:
y = OutputResponse[ssm, UnitStep[t], t];Overscript[x, ^ ] = OutputResponse[obs, Flatten@{y, UnitStep[t]}, t]Compute the actual state trajectories for a UnitStep input:
x = StateResponse[{ssm, {0.2, 0.1}}, UnitStep[t], t]Plot the actual and estimated states:
{Plot[Evaluate[First /@ {x, Overscript[x, ^ ]}], {t, 0, 6}, PlotRange -> All, PlotLegends -> {"x1", "x1hat"}],
Plot[Evaluate[Last /@ {x, Overscript[x, ^ ]}], {t, 0, 6}, PlotRange -> All, PlotLegends -> {"x2", "x2hat"}]}Properties & Relations (5)
The equation
, with a negative definite
, yields a unique positive definite solution if and only if the eigenvalues of
are in the closed left half-plane:
Subscript[a, unstable] = (| | |
| --- | ---- |
| 0.5 | 0.1 |
| 0 | -0.1 |);LyapunovSolve[Subscript[a, unstable], -(| | |
| - | - |
| 1 | 0 |
| 0 | 1 |)]//PositiveDefiniteMatrixQEigenvalues[Subscript[a, unstable]]Subscript[a, stable] = (| | |
| ------- | ------- |
| -1.0782 | -0.1956 |
| 0.3913 | -0.0217 |);LyapunovSolve[Subscript[a, stable], -(| | |
| - | - |
| 1 | 0 |
| 0 | 1 |)]//PositiveDefiniteMatrixQEigenvalues[Subscript[a, stable]]The definite integral
is the solution to
if
is asymptotically stable:
{a, c} = {(| | |
| -- | -- |
| -1 | 3 |
| 0 | -1 |), (| | |
| - | - |
| 1 | 0 |
| 0 | 1 |)};-Subsuperscript[∫, 0, ∞]MatrixExp[a t].c.MatrixExp[at]ⅆt//MatrixFormLyapunovSolve[a, c] == %Compute the infinite-horizon quadratic cost for the asymptotically stable system
:
{a, q} = {(| | |
| -- | -- |
| -1 | 0 |
| 0 | -2 |), (| | |
| --- | - |
| 0.1 | 0 |
| 0 | 1 |)};s = LyapunovSolve[a, -q];Subscript[x, 0] = (| |
| -- |
| -1 |
| 1 |);
((1/2)Transpose[Subscript[x, 0]].s.Subscript[x, 0])[[1, 1]]Compute using direct integration:
((1/2)Subsuperscript[∫, 0, ∞](MatrixExp[a t].Subscript[x, 0]).q.(MatrixExp[a t].Subscript[x, 0]) ⅆt)[[1, 1]]LyapunovSolve[a = (| | | |
| -- | -- | - |
| 1 | 1 | 0 |
| -1 | -1 | 4 |
| 1 | 5 | 2 |), (| | | |
| - | - | - |
| 0 | 0 | 0 |
| 0 | 0 | 0 |
| 0 | 0 | 0 |), (c = (| | | |
| -- | - | - |
| 1 | 4 | 1 |
| 0 | 2 | 0 |
| -1 | 0 | 3 |))]//MatrixFormLinearSolve gives the same solution:
LinearSolve[a, c]//MatrixFormSolve the Lyapunov equation
using LinearSolve:
{a, b, c, d, e} = {(| | |
| ------ | ------- |
| 0.6685 | 0.3482 |
| 0.154 | -0.7161 |), (| | |
| ------- | ------ |
| -0.1552 | 0.1178 |
| -0.9785 | 0.2884 |), (| | |
| ------- | ------- |
| 0.7412 | -0.9487 |
| -0.0326 | 0.3568 |), (| | |
| ------ | ------- |
| 0.8778 | 0.8733 |
| 0.3024 | -0.4085 |), (| | |
| ------- | ----- |
| 0.874 | 0.753 |
| -0.4265 | 0.758 |)};Partition[LinearSolve[KroneckerProduct[a, e] + KroneckerProduct[d, b], Flatten[c]], 2]LyapunovSolve gives the same solution:
LyapunovSolve[{a, d}, {b, e}, c]Related Guides
History
Text
Wolfram Research (2010), LyapunovSolve, Wolfram Language function, https://reference.wolfram.com/language/ref/LyapunovSolve.html.
CMS
Wolfram Language. 2010. "LyapunovSolve." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LyapunovSolve.html.
APA
Wolfram Language. (2010). LyapunovSolve. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LyapunovSolve.html
BibTeX
@misc{reference.wolfram_2026_lyapunovsolve, author="Wolfram Research", title="{LyapunovSolve}", year="2010", howpublished="\url{https://reference.wolfram.com/language/ref/LyapunovSolve.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_lyapunovsolve, organization={Wolfram Research}, title={LyapunovSolve}, year={2010}, url={https://reference.wolfram.com/language/ref/LyapunovSolve.html}, note=[Accessed: 13-June-2026]}