### 1.26 Check continuous system stability in the Lyapunov sense

Problem: Check the stability (in Lyapunov sense) for the state coeﬃcient matrix $A=\begin {bmatrix} 0 & 1 & 0\\ 0 & 0 & 1\\ -1 & -2 & -3 \end {bmatrix}$

The Lyapunov equation is solved using lyap() function in MATLAB and LyapunovSolve[] function in Mathematica, and then the solution is checked to be positive deﬁnite (i.e. all its eigenvalues are positive).

We must transpose the matrix $$A$$ when calling these functions, since the Lyapunov equation is deﬁned as $$A^TP+PA=-Q$$ and this is not how the software above deﬁnes them. By simply transposing the $$A$$ matrix when calling them, then the result will be correct.

Mathematica

 Remove["Global*"]; (mat = {{0,1,0},{0,0,1},{-1,-2,-3}})  $\left ( {\begin {array}{ccc} 0 & 1 & 0 \\ 0 & 0 & 1 \\ -1 & -2 & -3 \\ \end {array}} \right )$ p = LyapunovSolve[Transpose@mat, -IdentityMatrix[Length[mat]]]; MatrixForm[N[p]]  $\left ( {\begin {array}{ccc} 2.3 & 2.1 & 0.5 \\ 2.1 & 4.6 & 1.3 \\ 0.5 & 1.3 & 0.6 \\ \end {array}} \right )$ N[Eigenvalues[p]]  $$\{6.18272,1.1149,0.202375\}$$

Matlab

 clear all; A=[0 1 0 0 0 1 -1 -2 -3]; p=lyap(A.',eye(length(A)))  p = 2.3 2.1 0.5 2.1 4.6 1.3 0.5 1.3 0.6  e=eig(p)  e = 0.20238 1.1149 6.1827 

Maple

 with(LinearAlgebra): A:=<<0,1,0;0,0,1;-1,-2,-3>>; p,s:=LyapunovSolve(A^%T,-<<1,0,0;0,1,0;0,0,1>>); Eigenvalues(p); ` \left [ {\begin {array}{c} 6.18272045921436+ 0.0\,i \\ \noalign {\medskip } 1.11490451203192+ 0.0\,i\\ \noalign {\medskip } 0.202375028753723+ 0.0\,i\end {array}} \right ]