How to solve matrix equation $AX+XB=C$ for $X$

How does one solve the matrix equation $AX+XB=C$ for $X$? It doesn't seem too difficult. I tried many times but failed.

I'm an adult student... I am now vexed about Gilbert Strang - An Introduction to Linear Algebra. I don't even understand a single word in Wikipedia: Sylvester equation. If you have ever use some nice workable materials or lecture notes? You can generously upload and share the links of the lecture notes and assignments. Different subjects/ topics are welcome, as long as you deem they are nice and workable.

The problem origins from a system of diff equation, using undetermined coefficients (matrix) to find the particular solution. Try $y_p=X\begin{pmatrix} e^{\alpha t} \\ e^{\beta t} \end{pmatrix}$

$\dot{y}+Ay=C\begin{pmatrix} e^{\alpha t} \\ e^{\beta t}\end{pmatrix}$

$\dot{y_p}=X\begin{pmatrix} \alpha & 0 \\ 0 & \beta \end{pmatrix} \begin{pmatrix}e^{\alpha t} \\ e^{\beta t}\end{pmatrix}$

substitute $\dot{y_p}$ and $y_p$ into the original differential equation..

$X\begin{pmatrix} \alpha & 0 \\ 0 & \beta \end{pmatrix}+AX=C$


It seems $AX+XB=[A,I_1]X[I_2,B]^T$, where $I_1$ and $I_2$ are identity matrices and subscript 'T' is transpose of a matrix. Thus, the problem becomes how to solve $[A,I_1]X[I_2,B]^T = C $. Obviously, $X=[A,I_1]^\dagger C {[I_2,B]^T}^\dagger$, where subscript '$\dagger$' means the Pseudo-inverse.


The matrix equation that prompted this post, $$X\begin{pmatrix} \alpha & 0 \\ 0 & \beta \end{pmatrix}+AX=C,$$ actually has a very easy solution.

Let $X$ and $C$ have columns $X_1,X_2$ and $C_1,C_2$, respectively. Then $$X_1=(A+\alpha I)^{-1}C_1,X_2=(A+\beta I)^{-1}C_2.$$

Footnote

A nice feature of this solution is that the condition for the existence and uniqueness of a solution to a Sylvester Equation is self evident in this simple case :-

$A$ and $-B$ must have no common eigenvalue.


Use the superoperator formalism: $$ AXB=C \mapsto ( {B}^T\otimes A)\text{vec} X = C $$ (see here for a definition of $\text{vec}(X)\;$ and here for more information: Kronecker product)

Rewrite your equation (using $AXB\to (B^T\otimes A) \text{vec}\;X$) to $$ AX+XB=C \to (1\otimes A)\text{vec}\;X + (B^T\otimes 1)\text{vec}\;X=\text{vec}\;C\\ \text{vec}\;X=\left((1\otimes A) + (B^T\otimes 1)\right)^{-1}\text{vec}\;C, $$ assuming that the last inverse exists...