-1

My goal is to solve the system of equation known as Lyapunov equation, that is finding x in the following equation:

A*X + X*transpose(A) +Q = 0

plus another linear constraint that is X*v = 0

where all matrices A, X ,Q are n by n matrices and v is a vector with length n.

How can I find such X in matlab?

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120
solver
  • 1
  • 3
    Have you tried to use Google to find a solver? I am confident that you will find many useful sites. If you still have a question please modify the original one according what you have found, tried. [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) – rozsasarpi Aug 05 '16 at 08:26

1 Answers1

0

Solution

Solving Lyapunov equations in Matlab is very easy. Both the continuous and discrete Lyapunov equation have a built-in function:

Extra note: if the links would not work, or you want a quick way to check the documentation of a Matlab function offline, every built-in Matlab function has a short help page reachable by help NameOfTheFunction. Furthermore the extended help page, as also visible on the web, with examples can also be retrieved offline by typing doc NameOfTheFunction in the Matlab terminal.

Example

Given the following continuous Lyapunov equation:

A*X + X*transpose(A) + Q =  0

The solution in Matlab for a stable A and positive definite Q is given as:

X = lyap(A,Q)

In some cases the equation is slightly different:

A*X + X*B + C = 0

This equation calls the Sylvester equation and is again solvable with the built-in Lyapunov function of Matlab:

X = lyap(A,B,C)

The same analogue solution steps exist for the discrete case, where the Lyapunov and Sylvester equation look slightly different:

A*X*transpose(A) -X + Q = 0 -> X = dlyap(A,Q)
A*X*B - X + C = 0 -> X = dlyap(A,B,C)
Community
  • 1
  • 1
  • 3
    Common Stack Overflow convention is to include boilerplate solution code in answer. External links may expire. While I agree that's not very likely in case of MATLAB official docs, a little piece of code really helps answer to shine. – Łukasz Rogalski Aug 05 '16 at 09:08
  • @ChristofVermeersch Thanks, I am well aware of that. However, lyap is for the case that matrix A is full rank (i.e. rank of A is n). Since rank of my matrix A is n-1 lyap doesn't work. However, adding the condition X*v = 0 causes X to have a unique solution. But I am asking how can I do it? – solver Aug 05 '16 at 23:34
  • I suppose that this is only solvable by using an iterative method, which uses Krylov Subspace iterations. Is there a particular reason why your matrix is not of full rank? – Christof Vermeersch Aug 08 '16 at 16:05