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.

  • 2
    $\begingroup$ This is called the Sylvester equation. There is actually a closed form equation that has about 32 terms just for the common denominator. Some will be zero due to your zero term, but it is not easy to do by hand, generally. $\endgroup$
    – adam W
    Commented Jan 11, 2013 at 13:23
  • 1
    $\begingroup$ I don't know an answer. Just some thoughts: since $A$ is invertible, $Y=A^{-1}XA$. This implies that $X$ and $Y$ are similar and thus represent the same linear transformation under two different bases, with $A$ being the change of basis matrix. $\endgroup$
    – user9464
    Commented Jan 11, 2013 at 15:02
  • $\begingroup$ See en.wikipedia.org/wiki/Sylvester_equation $\endgroup$
    – leonbloy
    Commented Jan 11, 2013 at 15:37

3 Answers 3


See The theory of matrices, chapter VIII.

  • $\begingroup$ Thanks for reference. I think this reference will be a great help for me. $\endgroup$
    – Salman
    Commented Jan 14, 2013 at 13:25

In attempting to give you my complicated general formula to your question, a curious thing happened. All the zero terms made everything dissapear. This makes sense as $\mathbf{0}$ is obviously a solution. For a non-zero solution, $X$ and $Y$ must be similar matrices $$XA=AY \Rightarrow A^{-1}XA = Y$$

Mainly for reference purposes, and to illustrate the subtle complexity of the equation, here is the $2 \times 2$ general form of the equation along with the solution (I used my own variables as I did not want to translate what I have, and the zeroes are the terms I mentioned): \begin{array}{rcl} \pmatrix{e & f \\ g & h}\pmatrix{q & r \\ s & t}=\pmatrix{q & r \\ s & t}\pmatrix{a & b \\ c & d} \\ \Rightarrow \pmatrix{q & r \\ s & t} &= & \pmatrix{\hat{q}\over {\Delta} & \hat{r}\over {\Delta} \\ \hat{s}\over {\Delta} & \hat{t}\over {\Delta}} \\ \end{array}


$$\Delta = a^2\left(d^2 -de -dh + eh -fg \right) + a\left(-2bcd + bce + bch -d^2e -d^2h + de^2 + 2deh + dh^2 -e^2h + efg -eh^2 + fgh \right) + bc\left( bc + de + dh -e^2 -2fg -h^2 \right) + d\left(deh -dfg -e^2h + efg -eh^2 + fgh \right) + e^2h^2 -2efgh + f^2g^2 $$ $$\hat{q} = 0 $$ $$\hat{r} = 0 $$ $$\hat{s} = 0 $$ $$\hat{t} = 0 $$

The formula for $\Delta$ here is a test for equal eigenvalues - it is zero if $X=\pmatrix{e & f \\ g & h}$ and $Y=\pmatrix{a & b \\ c & d}$ share at least one eigenvalue(not necessarily all eigenvalues).

Therefore, if $\Delta$ is non-zero, there is not a solution to your equation.

tl;dr: If you attempt to solve the equation by looking at the individual terms and getting simultaneous equations, you will be re-inventing a wheel called the Kronecker product. It is the tool you want to learn for this equation.

  • $\begingroup$ And by not a solution I mean not a non-zero solution, when $\Delta \ne 0$. $\endgroup$
    – adam W
    Commented Jan 11, 2013 at 15:31
  • $\begingroup$ Indeed Sylvester Equation and Kronecker Product looks like my point for calculation. Thanks $\endgroup$
    – Salman
    Commented Jan 14, 2013 at 13:28

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
   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 =
>>> 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

  • $\begingroup$ The OP had equations that resulted in $0x=0$ for example, where $x=0$ is not satisfactory. It tells nothing about $x$. That is what OP meant by "all calculations meaningless". $\endgroup$
    – adam W
    Commented Jan 11, 2013 at 16:40
  • $\begingroup$ Thanks for concidering and nice explanation of my problem. I will surely have a look and post my answer $\endgroup$
    – Salman
    Commented Jan 14, 2013 at 13:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .