Main Content

lyap

Solve continuous-time Lyapunov equation

Description

Use lyap to solve the special and general forms of the Lyapunov equation. Lyapunov equations arise in several areas of control, including stability theory and the study of the root mean square (RMS) behavior of systems.

X = lyap(A,Q) returns a solution to the Lyapunov equation AX+XAT+Q=0, where A and Q represent square matrices of identical sizes. If Q is a symmetric matrix, the solution X is also a symmetric matrix.

example

X = lyap(A,B,C) returns a solution to the Sylvester equation AX+XB+C=0, where the input A is an m-by-m matrix, input B is an n-by-n matrix, and both C and X are m-by-n matrices.

example

X = lyap(A,Q,[],E) solves the generalized Lyapunov equation AXET+EXAT+Q=0, where Q is a symmetric matrix. You must use empty square brackets [] for this syntax. If you place any values inside the brackets, the function returns an error.

example

Examples

collapse all

This example shows how to solve the Lyapunov equation:

AX+XAT+Q=0,

where

A=[12-3-4] and Q=[3111].

The A matrix is stable, and the Q matrix is positive definite.

Define the matrices.

A = [1 2; -3 -4];  
Q = [3 1; 1 1];

To solve the Lyapunov equation, use the lyap function.

X = lyap(A,Q)
X = 2×2

    6.1667   -3.8333
   -3.8333    3.0000

The function returns a symmetric matrix X. To check if X is positive definite, you can compute eigenvalues.

eig(X)
ans = 2×1

    0.4359
    8.7308

The solution is positive definite.

This example shows how to solve the Sylvester equation:

AX+XB+C=0,

where A=5, B=[4333], and C=[21].

Define the matrices.

A = 5;
B = [4 3; 3 3];
C = [2 1];

Use the lyap function to solve the Sylvester equation for these values of A, B, and C.

X = lyap(A,B,C)
X = 1×2

   -0.2063   -0.0476

The result is a 1-by-2 matrix.

This example shows how to solve the generalized Lyapunov equation AXET+EXAT+Q=0.

Generate the matrices A and E with random values.

rng(0)
A = rand(2)
A = 2×2

    0.8147    0.1270
    0.9058    0.9134

E = randn(2)
E = 2×2

    0.3188   -0.4336
   -1.3077    0.3426

Generate a symmetric Q matrix with complex values.

Q = complex(randn(2),randn(2));
Q = Q*Q'
Q = 2×2 complex

  15.6642 + 0.0000i   5.6211 + 4.1271i
   5.6211 - 4.1271i  16.9265 + 0.0000i

Solve the generalized Lyapunov equation.

X = lyap(A,Q,[],E)
X = 2×2 complex

  -2.0000 + 0.0000i  19.6841 - 3.6552i
  19.6841 + 3.6552i  20.9934 + 0.0000i

The solution X is a 2-by-2 symmetric matrix.

Input Arguments

collapse all

Input matrices, specified as matrices of the following sizes:

  • A, Q, and Em-by-m square matrices

  • Bn-by-n matrix

  • Cm-by-n matrix

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fi
Complex Number Support: Yes

Output Arguments

collapse all

Solution, returned as a matrix. For the Lyapunov equations, the solution X is an m-by-m square matrix. For the Sylvester equation, the solution X is a matrix of the same size as C.

Limitations

The continuous Lyapunov equation has a unique solution if the eigenvalues α1,α2,...,αn of A and β1,β2,...,βn of B satisfy αi+βj0 for all pairs (i,j).

If this condition is violated, lyap produces the error message:

Solution does not exist or is not unique.

Algorithms

lyap uses SLICOT routines SB03MD and SG03AD for Lyapunov equations and SB04MD (SLICOT) and ZTRSYL (LAPACK) for Sylvester equations.

References

[1] Bartels, R. H., and G. W. Stewart. “Algorithm 432 [C2]: Solution of the Matrix Equation AX + XB = C [F4].” Communications of the ACM 15, no. 9 (September 1972): 820–26. https://doi.org/10.1145/361573.361582.

[2] Barraud, A. “A Numerical Algorithm to solveA^{T}XA - X = Q.” IEEE Transactions on Automatic Control 22, no. 5 (October 1977): 883–85. https://doi.org/10.1109/TAC.1977.1101604.

[3] Hammarling, S. J. “Numerical Solution of the Stable, Non-Negative Definite Lyapunov Equation Lyapunov Equation.” IMA Journal of Numerical Analysis 2, no. 3 (1982): 303–23. https://doi.org/10.1093/imanum/2.3.303.

[4] Penzl, Thilo. “Numerical Solution of Generalized Lyapunov Equations.” Advances in Computational Mathematics 8, no. 1 (January 1, 1998): 33–48. https://doi.org/10.1023/A:1018979826766.

[5] Golub, G., S. Nash, and C. Van Loan. “A Hessenberg-Schur Method for the Problem AX + XB= C.” IEEE Transactions on Automatic Control 24, no. 6 (December 1979): 909–13. https://doi.org/10.1109/TAC.1979.1102170.

Version History

Introduced before R2006a

See Also

|