TITLE: Solving matrix equation $XA=AY$ with known $X$ and $Y$
QUESTION [6 upvotes]: I am having problem in solving set of matrix multiplication.
There are three matrices $A,X$ and $Y$, all are non-singular $2\times 2$ matrices. Where matrix $X$ and $Y$ are known and $A$ is unknown. 
$$ X = \begin{bmatrix} x_{11} & x_{12} \\ x_{21} & x_{22} \end{bmatrix} $$
$$ Y = \begin{bmatrix} y_{11} & y_{12} \\ y_{21} & y_{22} \end{bmatrix} $$
$$ A = \begin{bmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{bmatrix} $$
and multiplication is as follows
$$ X\cdot A=A\cdot Y $$
I expanded it and tried to solve it as such I would be able to get elements of matrix $A$ at the end but it end up in homogenous linear equation having trivial solution zero. That makes all calculation meaningless.
$$ X\cdot A - A\cdot Y = 0 $$
What is the better way to compute it as such I can find result of matrix $A$ (in terms of elements of matrics $X$ and $Y$) at the end.

REPLY [3 votes]: I expanded it and tried to solve it as such I would be able to get
  elements of matrix A at the end but it end up in homogenous linear
  equation having trivial solution zero. That makes all calculation
  meaningless.

Why? That's a valid solution, if only trivial. 
To investigate if there are additional
non-trivial solutions, we see that $X A−A Y=0$ is a particular (homogeneus) case of the Sylvester equations. In the link it's explained that the equation can be rewriten as a linear (in our case homogeneus) with a matrix equation of size $n^2 \times n^2 $ ($4 \times 4$ ), which will have non-trivial solutions if its singular -which is equivalent to matrices X and Y having at least one common eigenvalue. Our solution, in vectorial form, is the full null space of that matrix. 
One example in Octave/Matlab
>>> X=[1,2;0,3]  % triangular, eigenvalues: 1 , 3
X=
   1   2
   0   3
>>>  Z=[5,6,7,8]; % arbitrary
>>>    Y=Z*[3,5;0,4]*inv(Z)  % eigenvalues : 3, 4
Y =
   111.500   -77.500
   150.500  -104.500
>>>  D=kron(eye(2),X)-kron(Y',eye(2))  % kronecker products
D =
  -110.50000     2.00000  -150.50000     0.00000
     0.00000  -108.50000     0.00000  -150.50000
    77.50000     0.00000   105.50000     2.00000
     0.00000    77.50000     0.00000   107.50000
>>> a=null(D)   % D is singular, it has in this case a dim-1 null space
a =
   0.57359
   0.57359
  -0.41352
  -0.41352
>>> A=[x(1),x(3);x(2),x(4)];
A =
   0.57359  -0.41352
   0.57359  -0.41352
>>> X*A-A*Y  %  zero, save for rounding errors
ans =
  5.1958e-014  -2.4425e-014
  -2.1094e-014  1.9318e-014

Of course,  $\alpha A$ is also solution