Let's consider square matrices $A_{n \times n}$, $B_{n \times n}$ and $X_{n \times n}$ with elements from $\mathbb{R}$. Could you tell me please, what would be the necessary conditions for the existence of solution (may be not unique) of Sylvester equation: $$ AX=XB. $$ As I know, sufficient condition looks like (but probably it is a necessary and sufficient condition) $$ \sigma_p(A) \cap \sigma_p(B) \neq \varnothing, $$ here $\sigma_p(A)$ and $\sigma_p(B)$ are the spectra of matrices $A$ and $B$.

5$\begingroup$ $X = 0$ works. What conditions on $X$ do you want? $\endgroup$ – LSpice Feb 29 at 21:22
This equation always has a solution: $X = O$. I'll assume throughout this answer that you're interested in a nonzero solution.
The equation $AX = XB$ is equivalent to $(A \otimes I  I \otimes B^T)\mathbf{x} = \mathbf{0}$, where $\otimes$ denotes the Kronecker product and $\mathbf{x}$ is the vectorization of $X$. Your question is thus equivalent to asking when the matrix $A \otimes I  I \otimes B^T$ is not invertible (i.e., when $0$ is not an eigenvalue of $A \otimes I  I \otimes B^T$).
Since the eigenvalues of $A \otimes I  I \otimes B^T$ are exactly the sums of the eigenvalues of $A$ and $B$, the condition that you wrote ($\sigma_p(A) \cap \sigma_p(B) \neq \varnothing$) is in fact both necessary and sufficient.


5$\begingroup$ @Randal'Thor  The letter $O$ seems to be a common notation for the zero matrix (to distinguish from the zero vector, for example). $\endgroup$ – mr_e_man Mar 1 at 22:58