TITLE: Prove that the Sylvester equation has a unique solution when $A$ and $-B$ share no eigenvalues
QUESTION [10 upvotes]: We are given the Sylvester equation $AX+XB=C$ with complex matrices. I am trying to understand the proof that if $A$ and $-B$ share no eigenvalues, then there is a unique solution $X$ for any $C$. The proof is on Wikipedia and reads like this:

Suppose that $A$ and $-B$ have no common eigenvalues. Then their characteristic polynomials $f(z)$ and $g(z)$ have highest common factor $1$. Hence there exist complex polynomials $p(z)$ and $q(z)$ such that $p(z)f(z)+q(z)g(z)=1$. By the Cayley–Hamilton theorem, $f(A)=0=g(-B)$; hence $g(A)q(A)=I$. Let $X$ be any solution of $S(X)=0$; so $AX=-XB$ and repeating this one sees that $X=q(A)g(A)X=q(A)Xg(-B)=0$. Hence by the rank plus nullity theorem $S$ is invertible, so for all $C$ there exists a unique solution $X$.

Firstly, I don't understand how it concludes that there exist $p(z)$ and $q(z)$ such that $p(z)f(z) + q(z)g(z)=1$. If this follows from the previous statement, I don't see how.
Secondly, I don't understand how it concludes that $q(A)g(A)X=q(A)Xg(-B)$. Again, if it follows from a previous statement, it is not clear how.
If anyone can explain these steps, or provide a different proof, it would be greatly appreciated.

REPLY [2 votes]: In case you don't already know how this works, I think it's very useful to see how eigenvectors/eigenvalues of $A$ and $B$ directly give you eigenvalues of the "Sylvester operator" $X \mapsto AX+XB$. Actually, it is conceptually clearer to work with with the transpose $C=B^t$ instead of $B$, which makes no difference because $B$ and $C$ have the same spectral theory. So the operator is
$$X \mapsto AX+XC^t : M_n(\mathbb{C}) \to M_n(\mathbb{C})$$
The basic idea is revealed in the case where $A$ and $C$ are diagonalizeable. Let $u_1,\ldots, u_n$ be a basis of eigenvectors for $A$ with accompanying eigenvalues $\lambda_1,\ldots,\lambda_n$. Let $w_1,\ldots,w_n$ be a basis of eigenvectors for $C$ with eigenvalues $\mu_1,\ldots,\mu_n$. One can check that the outer products
\begin{align*}
E_{ij} := u_i w_j^t && i,j = 1,\ldots,n 
\end{align*}
are linearly independent in $M_n(\mathbb{C})$ and satisfy
$$ AE_{ij} + E_{ij} C^t = (\lambda_i + \lambda_j)E_{ij}.$$
The linear independence of the $E_{ij}$ is basically an manifestation the tensor product isomorphism $(\bigotimes_i U_i) \oplus (\bigotimes_j W_j) \cong  \bigoplus_{i,j} (U_i \otimes V_i)$ for vector spaces.

Conclusion: If $A$ and $C$ are diagonalizable, then so is $X \mapsto AX+XC^t$. Moreover, the eigenvalues of $X \mapsto AX+XC^t$ are precisely $\lambda_i + \mu_j$, where $\lambda_i$ is an eigenvalue of $A$ and $\mu_j$ is an eigenvalue of $C$. In particular, as long as no eigenvalue of $A$ is the negative of an eigenvalue of $C$, the operator $X \mapsto AX+XC$ is invertible.

By working a bit harder, I guess you should be able to show analogous things about the generalized eigenspaces, leading to the result you're after. I just wanted to make sure this direct connection between the eigenvalues of $A$, $C$ and the operator $X \mapsto AX+XC^t$ was available to you.