# Linear algebra equation with swapped unknown

Consider the following linear equation

$A X + X B = C$

where $A$, $B$, $C$, are known real $n \times n$ square matrices, and where $X$ is an unknown real $n \times n$ square matrix. I want to have an analytical expression for the matrix $X$ that solves the above linear problem.

-
What you have there is a Sylvester equation. –  Ｊ. Ｍ. Sep 9 '11 at 13:30
Which you can solve in Matlab via X = lyap(A,B,C) –  user13838 Sep 9 '11 at 13:34
But should you need to write your own solver: see this and this. –  Ｊ. Ｍ. Sep 9 '11 at 13:43
@ J.M.: thank you for the references. I was looking for a analytical solution, but from what I see that does exist in simple form (not at least one where X is not reshaped in vector form). –  Marco Lombardi Sep 9 '11 at 14:41
Yeah, you'll need the Kronecker product and the $\mathrm{vec}$ operator for an "analytical solution". –  Ｊ. Ｍ. Sep 9 '11 at 16:04

What I have in a course of mine is a formula for the solution of the problem $AX-XB=C$ with $\sigma(A)\cap \sigma(B)=\emptyset$ and $A,B,C$ operators on the same Banach space. $R(\lambda;A)=(A-\lambda I)^{-1}$, etc.

The solution has the formula

$$X=-\frac{1}{4\pi^2} \int_{\Gamma_1} \int_{\Gamma_2}\frac{R(\lambda;A)CR(\mu;B)}{\lambda-\mu}d\mu d\lambda$$

Where $\Gamma_1,\Gamma_2$ are contours which contain $\sigma(A),\sigma(B)$, respectively.

I remember checking this once using functional calculus, but I don't know if I can still do it now. :)

-
This looks interesting, I would like to read more about this. Do you have any reference suggestions? –  Calle Sep 9 '11 at 19:18
You can find more details in Dunford, Schwarz, Linear operators Part I, starting from page 566. –  Beni Bogosel Sep 9 '11 at 19:30