Documentation

sylvester

Solve Sylvester equation AX + XB = C for X

Description

example

X = sylvester(A,B,C) returns the solution, X, to the Sylvester equation.

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.

Examples

collapse all

Create the coefficient matrices A and B.

A = [1 -1 1; 1 1 -1; 1 1 1];
B = magic(3);

Define C as the 3-by-3 identity matrix.

C = eye(3);

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

X = sylvester(A,B,C)
X = 3×3

0.1223   -0.0725    0.0131
-0.0806   -0.0161    0.1587
-0.0164    0.1784   -0.1072

The result is a 3-by-3 matrix.

Create a 4-by-4 coefficient matrix, A, and 2-by-2 coefficient matrix, B.

A = [1 0 2 3; 4 1 0 2; 0 5 5 6; 1 7 9 0];
B = [0 -1; 1 0];

Define C as a 4-by-2 matrix to match the corresponding sizes of A and B.

C = [1 0; 2 0; 0 3; 1 1]
C = 4×2

1     0
2     0
0     3
1     1

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

X = sylvester(A,B,C)
X = 4×2

0.4732   -0.3664
-0.4006    0.3531
0.3305   -0.1142
0.0774    0.3560

The result is a 4-by-2 matrix.

Input Arguments

collapse all

Input matrices, specified as matrices. Input A is an m-by-m square matrix, input B is an n-by-n square matrix, and input C is an m-by-n rectangular matrix. The function returns an error if any input matrix is sparse.

Data Types: single | double
Complex Number Support: Yes

Output Arguments

collapse all

Solution, returned as a matrix of the same size as C. The function returns an error if the eigenvalues of A and -B are not distinct (in this case, the solution, X, is singular or not unique).

collapse all

Sylvester Equation

The Sylvester equation is

$AX\text{​}+XB=C.$

The equation has a unique solution when the eigenvalues of A and -B are distinct. In terms of the Kronecker tensor product, $\otimes$, the equation is

$\left[I\otimes A+{B}^{T}\otimes I\right]X\left(:\right)=C\left(:\right),$

where I is the identity matrix, and X(:) and C(:) denote the matrices X and C as single column vectors.