Skip to main content

Sylvester Equation Solver

Calculate sylvester equation instantly with our math tool. Shows detailed work, formulas used, and multiple solution methods.

Share this calculator

Formula

AX + XB = C

Where A, B, and C are known matrices and X is the unknown matrix. A unique solution exists if and only if the eigenvalues of A and the negatives of the eigenvalues of B are disjoint (no common values). The solver uses the Kronecker product vectorization approach for 2x2 matrices.

Worked Examples

Example 1: Diagonal Coefficient Matrices

Problem: Solve AX + XB = C where A = [[1,0],[0,2]], B = [[3,0],[0,4]], C = [[5,6],[7,8]].

Solution: Since A and B are diagonal, the equation simplifies element-wise:\n(a_ii + b_jj) * x_ij = c_ij\nx_11 = 5/(1+3) = 1.25\nx_12 = 6/(1+4) = 1.2\nx_21 = 7/(2+3) = 1.4\nx_22 = 8/(2+4) = 1.333\nX = [[1.25, 1.2], [1.4, 1.333]]

Result: X = [[1.25, 1.2], [1.4, 1.333]] | Residual = 0

Example 2: Non-Diagonal Sylvester Equation

Problem: Solve AX + XB = C where A = [[2,1],[0,3]], B = [[1,0],[1,2]], C = [[10,8],[9,12]].

Solution: Form the 4x4 system using Kronecker products:\n(I kron A + B^T kron I) * vec(X) = vec(C)\nSolve the 4x4 system by Gaussian elimination\nEigenvalues of A: 2, 3\nEigenvalues of -B: -1, -2 (disjoint from A eigenvalues)\nUnique solution exists

Result: Solution X found via Kronecker product method | Residual near 0

Frequently Asked Questions

What is the Sylvester equation?

The Sylvester equation is a matrix equation of the form AX + XB = C, where A, B, and C are known matrices and X is the unknown matrix to be solved for. Named after James Joseph Sylvester who studied it in the 19th century, this equation arises naturally in many areas of mathematics, engineering, and control theory. The equation has a unique solution if and only if the eigenvalues of A and the negatives of the eigenvalues of B have no values in common. When this condition holds, the solution X can be found using various numerical methods including the Bartels-Stewart algorithm, which first reduces A and B to Schur form.

When does the Sylvester equation have a unique solution?

The Sylvester equation AX + XB = C has a unique solution if and only if the spectra (sets of eigenvalues) of A and -B are disjoint, meaning no eigenvalue of A equals any eigenvalue of -B. This is equivalent to saying that for every pair of eigenvalues lambda_i of A and mu_j of B, lambda_i + mu_j is not equal to zero. When this condition fails, the equation either has no solution or infinitely many solutions, depending on the right-hand side C. This condition can be checked before attempting to solve the equation by computing the eigenvalues of both matrices and verifying no sums equal zero.

How is the Sylvester equation solved numerically?

The most efficient numerical method is the Bartels-Stewart algorithm, which first computes the Schur decompositions A = Q_A * T_A * Q_A^T and B = Q_B * T_B * Q_B^T. The equation is then transformed to T_A * Y + Y * T_B = D (where Y and D are transformed versions of X and C), which can be solved column by column using back substitution because T_A and T_B are triangular. This approach costs about 25n^3 operations for n-by-n matrices. Alternatively, the equation can be vectorized using Kronecker products to form a larger standard linear system, though this is less efficient with n^6 complexity.

What is the Kronecker product approach to solving the Sylvester equation?

The vectorization approach converts AX + XB = C into a standard linear system by stacking the columns of X into a single vector. Using the vec operator and Kronecker product properties, the equation becomes (I kron A + B-transpose kron I) * vec(X) = vec(C). This transforms the matrix equation into a system of n-squared linear equations in n-squared unknowns, which can be solved by standard methods like Gaussian elimination. While conceptually simple and useful for small matrices, this approach is computationally expensive for large matrices because the system size grows quadratically with the original matrix dimension.

What are the main applications of the Sylvester equation?

The Sylvester equation appears extensively in control theory, where it arises in observer design, controller synthesis, and model reduction. In signal processing, it connects to the solution of Wiener-Hopf equations. In numerical linear algebra, solving Sylvester equations is a subroutine in computing matrix square roots, matrix logarithms, and the matrix sign function. The closely related Lyapunov equation (AX + XA^T = C) is fundamental in stability analysis of dynamical systems. In computer science, Sylvester equations appear in model order reduction for circuit simulation and in computational methods for partial differential equations.

What is the difference between Sylvester and Lyapunov equations?

The Lyapunov equation AX + XA^T = C is a special case of the Sylvester equation where B = A^T (or B = A* for the complex case). This specialization has important theoretical and computational implications. The Lyapunov equation arises specifically in stability analysis: a linear system dx/dt = Ax is stable if and only if for any positive definite C, the Lyapunov equation has a positive definite solution X. Specialized algorithms exploit the symmetry of the Lyapunov equation for greater efficiency. The continuous Lyapunov equation uses AX + XA^T, while the discrete version uses AXA^T - X = C.

References