I want to solve matrix equation A*X=X*B
using LeastSquares method, but it is suited for equation like A*X=B.
All matrices are 3x3
A = {{a11, a12, a13}, {a21, a22, a23}, {a31, a32, a33}}
B = {{b11, b12, b13}, {b21, b22, b23}, {b31, b32, b33}}
X = {{x11, x12, x13}, {x21, x22, x23}, {x31, x32, x33}}
a33=b33=x33=1, a31=0,a32=0.
How can I do this?
Update: I figure out that it's special type of equation
I'm trying to solve a special case of Sylvester equation in my case it looks like $$A*X=X*B$$ so it can be write in form $$A*X+X*(-B)=C$$ where C consist of all 0 items.
I tried to solve it in Mathematica with LyapunovSolve but it gives me a all-zero trivial solution.
So I want to check if a non-trivial solution exists. It seems I find out how to test matrices A,B for non-trivial solution (but I'm not sure) if resultant equals to 0, then such solution exist.$$\mathrm{resultant}(\mathrm{det}(A-λE),\mathrm{det}(B-λE),λ)=0$$ I tried real matrices for example A = {{0 -1 300}, {1 0 0}, {0 0 1}}
, B = {{-0.4009 -1.0787 446.1463}, {1.6180 0.8875 -159.2272}, { 0.0003 0.0029 1}}
but there is maybe a problem because B matrix was defined experimentally and it has some small errors, with these matrices I have resultant -6.79 , but due to erorrs I don't know may be it close enough to 0?
My question is: Can you write condition of existence of non-trivial solution of Sylvester equation not in abstract form but in particular formula, preferably in Mathematica.
Also I don't understand why Mathematica gives me only trivial solution, when I try to solve this equation with parameters. For example I tried
am = {{a11, a12, a13}, {a21, a22, a23}, {a31, a32, a33}}
bm = {{b11, b12, b13}, {b21, b22, b23}, {b31, b32, b33}}
cm = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}
LyapunovSolve[am,bm,cm]
which gives me all 0. Also I tried to multiply matrices and get 9 equations and solve them with function Solve which also give me all 0.