Advanced maths

Sylvester matrix equation calculator AX + XB = C

Solve or classify an exact rational Sylvester equation, with a shared Lyapunov mode and substitution checks.

Your numbers

One matrix row per line; commas or spaces separate columns. Use integers, decimals with up to six places, or fractions. Entries and fraction components are bounded by 1,000,000.
One matrix row per line; commas or spaces separate columns. Use integers, decimals with up to six places, or fractions. Entries and fraction components are bounded by 1,000,000.
One matrix row per line; commas or spaces separate columns. Use integers, decimals with up to six places, or fractions. Entries and fraction components are bounded by 1,000,000.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

A Sylvester equation places an unknown matrix on both sides of known matrix factors. Its entries still form a linear system, so exact rational elimination can determine consistency and uniqueness. This page supports different square sizes for A and B, with C and X having the matching rectangular shape. A Lyapunov special case sets B to A transpose on the same page. Unique solutions are substituted back into the complete equation.

THE FORMULA(AX + XB)ᵢⱼ = Cᵢⱼ; expand entries into a linear system for all unknown X entries.

A worked example

Let A = diag(1,2), B = diag(3,4) and C = [[4,10],[15,24]]. Each unknown entry is multiplied by the sum of its row eigenvalue from A and column eigenvalue from B. The resulting unique solution is X = [[1,2],[3,4]]. Every entry of AX+XB−C is then exactly zero.

Good to know

A and B must be square and at most 3×3; C has rows(A) rows and columns(B) columns. Exact rational growth is bounded. Inconsistent and infinite-solution cases are classified but no full parametric family is generated. Lyapunov mode uses the stated plus-C convention AX+XAᵀ=C, not the sometimes-used equation with −C on the right.

Equation shape determines the unknown matrix shape

If A is m×m and B is n×n, then X must be m×n. Both AX and XB have that shape, so C must too. A rectangular C is therefore valid even though the two known coefficient matrices are square. The entrywise solver builds m times n unknowns and does not assume A and B have the same dimension.

In the diagonal example, the system separates into independent scalar equations. For general matrices the entries couple, but exact row reduction handles them together. The result includes the coefficient-system rank, making the unique-solution claim traceable to the number of unknown entries as well as a zero substitution residual. The rank criterion is evaluated on the expanded entry system, rather than inferred from whether A or B happens to be invertible.

Diagonal Sylvester coefficients divide each right-hand entry by its own row-column sum4/4 = 110/5 = 215/5 = 324/6 = 4Each coefficient is Aii + Bjj
With A diagonal (1,2), B diagonal (3,4), and C = [[4,10],[15,24]], the four denominators are 4,5,5,6. The unique solution is [[1,2],[3,4]].

The Moore–Penrose pseudoinverse calculator for rectangular matrices handles a generalized inverse of a supplied matrix, a different task from solving this entrywise matrix equation.

A valid input equation need not have one solution

The scalar equation 1·x + x·(−1) = 0 has every x as a solution. Replacing its right-hand side by one makes it inconsistent. These are legitimate Sylvester configurations, not malformed matrices. The calculator distinguishes infinitely many solutions from no solution instead of returning a fabricated zero matrix or dividing by a vanished coefficient.

For larger numerical problems, specialized algorithms use Schur forms and can be more efficient. This small exact implementation exposes entry equations and consistency without a floating tolerance. The existing Sylvester criterion calculator checks positive definiteness using principal minors and has a similar name but a different mathematical purpose. Keeping that distinction in the title prevents the equation solver from being mistaken for a duplicate of the criterion test.

A few questions, answered

Is Lyapunov mode a separate calculator?

No. It is the Sylvester special case B=Aᵀ and shares this page, with its sign convention displayed explicitly.

Does a zero residual alone prove uniqueness?

No. It proves that a candidate solves the equation. Uniqueness also requires full rank of the coefficient system, which is checked separately.

Find your calculator

Start typing to explore the library.