solve_sylvester(a, b, q)¶
Computes a solution (X) to the Sylvester equation \(AX + XB = Q\).
- a(M, M) array_like
Leading matrix of the Sylvester equation
- b(N, N) array_like
Trailing matrix of the Sylvester equation
- q(M, N) array_like
- x(M, N) ndarray
The solution to the Sylvester equation.
If solution was not found
Computes a solution to the Sylvester matrix equation via the Bartels- Stewart algorithm. The A and B matrices first undergo Schur decompositions. The resulting matrices are used to construct an alternative Sylvester equation (
RY + YS^T = F) where the R and S matrices are in quasi-triangular form (or, when R, S or F are complex, triangular form). The simplified equation is then solved using
*TRSYLfrom LAPACK directly.
New in version 0.11.0.
Given a, b, and q solve for x:
>>> from scipy import linalg >>> a = np.array([[-3, -2, 0], [-1, -1, 3], [3, -5, -1]]) >>> b = np.array([]) >>> q = np.array([,,]) >>> x = linalg.solve_sylvester(a, b, q) >>> x array([[ 0.0625], [-0.5625], [ 0.6875]]) >>> np.allclose(a.dot(x) + x.dot(b), q) True