Can MATLAB solve a Lyapunov equation symbolically?

10 views (last 30 days)
I have a 3x3 matrix called J. I need to show that there exists at least one X and Q such that where Q is a Hermitian matrix and is the conjugate transpose of J (see https://en.wikipedia.org/wiki/Lyapunov_equation )
Matrix J is currently in terms of many parameters and variables which makes finding X and Q by hand difficult. Can MATLAB help with this? It seems using symbolic MATLAB would help but I'm not sure how to move forward.
  9 Comments
Sam Chak
Sam Chak on 10 Mar 2022
Can you check the state matrix J if it is possible for such that ?
econogist
econogist on 10 Mar 2022
It's not possible that . That's why I'm having to go the Lyapunov route in the first place really since when I tried to prove stability via eigenvalues alone (hoping all three would be less than 0), the dominant eigenvalue was equal to 1.

Sign in to comment.

Accepted Answer

Sam Chak
Sam Chak on 9 Mar 2022
Try this script:
syms k Q pe D B Ur Up Sr Sp p11 p12 p13 p22 p23 p33
A = sym('A', [3 3]); % state matrix
P = sym('P', [3 3]); % positive definite symmetric matrix
A = [(Q*pe-(D-B)*Ur)/(pe^2) -((D-B)*Up/(pe^2)) sym('0');
-((D-B)*Ur/(pe^2)) (Q*pe-(D-B)*Up)/(pe^2) sym('0');
Sr Sp sym('1')];
P = [p11 p12 p13;
p12 p22 p23;
p13 p23 p33];
Q = sym(eye(3)); % identity matrix
N = sym(zeros(3)); % zero matrix
L = A*P*A.' - P + Q; % discrete-time Lyapunov equations
eqns = [L(1, 1) == 0, L(1, 2) == 0, L(1, 3) == 0, L(2, 2) == 0, L(2, 3) == 0, L(3, 3) == 0];
S = solve(eqns);
sol = [S.p11; S.p12; S.p13; S.p22; S.p23; S.p33]
Credits to @Torsten.
  12 Comments
Torsten
Torsten on 10 Mar 2022
Edited: Torsten on 10 Mar 2022
You write:
I have a 3x3 matrix called J. I need to show that there exists at least one X and Q such that
J*X*J^H - X + Q = 0 where Q is a Hermitian matrix and J^H is the conjugate transpose of J.
I don't understand why you don't take an arbitrary Hermitian matrix X (e.g. X = 0) and set Q = X - J*X*J^H which is Hermitian, so fulfills the requirement. Or where do I go wrong here ?
Sam Chak
Sam Chak on 10 Mar 2022
Edited: Sam Chak on 10 Mar 2022
Thanks @Walter Roberson for showing how to solve this rigorously.
The stability conditions for asymptotic stability says that a discrete-time linear system is asymptotically stable if its eigenvalues are inside the unit circle , and marginally stable if it has at least one eigenvalue on the unit circle.
I have double-checked the state matrix supplied by @Matt Woolf, that
will always produce at least one eigenvalue on the unit circle.
Naturally, since , when trying to solve the discrete-time Lyapunov equation, , then will be eliminated in the process. For example,
A = [-0.1 -0.2 0; 0.3 0.4 0; 0.5 0.6 1]
eig(A)
Q = eye(3);
P = dlyap(A, Q)
the chosen state matrix will produce an error message:
Here is a second example that a state matrix with all its eigenvalues are inside the unit circle.
clear all
A = [-0.2 -0.2 0.4; 0.5 0 1; 0 -0.4 -0.5]
eig(A) % check the eigenvalues of A are inside the unit circle
Q = eye(3) % identity matrix
P = dlyap(A, Q)
eig(P) % check the signs of the eigenvalues of P
A*P*A' - P + Q % check if it produces the zero matrix
Because the eigenvalues of P are all positive, the matrix is positive definite and the discrete-time system is asymptotically stable.
By the way, Q does not have be an identity matrix. It is possible to investigate the stability of the system using Q = diag([0, 0, 1]), so long as the rank of the observability matrix is full rank. 3rd example:
clear all
A = [-0.2 -0.2 0.4; 0.5 0 1; 0 -0.4 -0.5]
eig(A)
C = [0 0 1]; % output matrix
Q = C'*C % a Hermitian matrix
rank(obsv(A, C)) % check the rank of the observability matrix
P = dlyap(A, Q)
eig(P)
A*P*A' - P + Q

Sign in to comment.

More Answers (1)

Sam Chak
Sam Chak on 10 Mar 2022
Edited: Sam Chak on 10 Mar 2022
Let's try a new one by reducing the non-dependant variables. I have simplified the computation by letting , , , and , with and maintained. Also, I have replaced with in order to investigate whether the solution exists.
clear all; clc
syms a b c d Sr Sp p11 p12 p13 p22 p23 p33
A = sym('A', [3 3]); % state matrix
P = sym('P', [3 3]); % positive definite symmetric matrix
A = [a b sym('0');
c d sym('0');
Sr Sp sym('0.5')];
P = [p11 p12 p13;
p12 p22 p23;
p13 p23 p33];
Q = sym(eye(3)); % identity matrix
L = A*P*A.' - P + Q; % discrete-time Lyapunov equations
eqns = [L(1, 1) == 0, L(1, 2) == 0, L(1, 3) == 0, L(2, 2) == 0, L(2, 3) == 0, L(3, 3) == 0];
S = solve(eqns);
sol = [S.p11; S.p12; S.p13; S.p22; S.p23; S.p33]
simplify(sol)
pretty(S.p33)
In this example, the solution exists, though is still pretty long even after simplification, not mentioning that you have to substitute k, q, pe, D, B, Ur, Up, back into the a, b, c, d.
More importantly, you need to recheck your derivation/modeling of the state matrix if . If it is, it could imply that the system is marginally stable and you can't find any P that satisfies the discrete Lyapunov equation.
  3 Comments
Sam Chak
Sam Chak on 10 Mar 2022
Edited: Sam Chak on 10 Mar 2022
The stability issue maybe not as bad as you think. Although I don't know what your system really is, if your system
is controllable, then there exists a feedback gain matrix K in the controller
that arbitrarily assigns the system eigenvalues to any set . When the two equations are combined, you can rewrite the closed-loop system as
,
where the closed-loop state matrix is
.
In other words, produces the desired system eigenvalues that can be chosen with appropriate choice of the feedback gain matrix K through the pole placement technique.
econogist
econogist on 10 Mar 2022
Thanks so much for this response, Sam. I'm going to have to sit with it for a bit as some of what you wrote is beyond my knowledge.
The full system is here, by the way: https://math.stackexchange.com/questions/4398126/is-this-3-equation-nonlinear-system-stable

Sign in to comment.

Categories

Find more on Matrix Computations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!