Dear Mathematica experts,
Given two square matrices, A and B, how do we use Mathematica to solve a matrix T such that T satisfies this matrix equation? (Here we have A,B,T $\in$ general linear matrix GL($N,\mathbb{Z}$) with integer coefficient.)
Transpose[T]. A . T = B
Roughly we want to solve T by given A and B by some Mathematica command line:
Solve[Transpose[T]. A . T == B, T]
But this won't work.
Conditions:
-
- We can focus on A and B are symmetric integer matrices, but A and B are not necessarily diagonal. $A_{ij}=A_{ji}, B_{ij}=B_{ji} \in \mathbb{Z}$.
-
- T is an integer matrix but may not be symmetric. $T_{ij} \in \mathbb{Z}$.
-
- All of matrices, including the given A and B, and the solution T have determinant det $= \pm 1$. Namely, $\det A = \det B = \det T =\pm 1$ (either 1 or $-1$). This shall be called unimodular.
(p.s. Ideally it is good to impose T is not only general linear matrix GL($N,\mathbb{Z}$) but special linear matrix SL($N,\mathbb{Z}$) such that the determinant det(T) =1 is better.)
As a test example, let us try two rank-10 matrices which indeed have solutions satisfy the above 3 conditions:
A = ({ {2, -1, 0, 0, 0, 0, 0, 0, 0, 0}, {-1, 2, -1, 0, 0, 0, 0, 0, 0, 0}, {0, -1, 2, -1, 0, 0, 0, -1, 0, 0}, {0, 0, -1, 2, -1, 0, 0, 0, 0, 0}, {0, 0, 0, -1, 2, -1, 0, 0, 0, 0}, {0, 0, 0, 0, -1, 2, -1, 0, 0, 0}, {0, 0, 0, 0, 0, -1, 2, 0, 0, 0}, {0, 0, -1, 0, 0, 0, 0, 2, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, -1} });
B = ({ {1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, -1} });
How do we solve T? that satisfies Transpose[T]. A . T = B? Please give a rank-10 T matrix so we can compare.
I saw related questions, but none of them give a complete answer:
Matrix equivalence over the integers
Finding an Integer, Unimodular Matrix that connects two given matrices
https://mathematica.stackexchange.com/a/115905/95437
This answer uses Smith normal form to solve: T'. A . T = B but not Transpose[T]. A . T = B because T' $\neq$ Transpose[T] in general.
Edit: Nasser asked a smaller rank test example, here:
- A = {{0, 1}, {1, 0}}. B= {{0,1},{1,2}}.
Ans: T={{1, 1},{0, 1}}.
- A = {{0, 1}, {1, 0}}. B = {{2,5},{5,12}}.
Ans: T= {{1, 2}, {1, 3}}
(These T are in both GL($2,\mathbb{Z}$) and also SL($2,\mathbb{Z}$))
Thanks a lot! Zeta
EDIT to response to who absent-minded closing my question and falsely claiming the response to How to solve for $\mathbf{X}$ in a matrix equation $\mathbf{X A} \mathbf{X}^\top = \mathbf{B}$? solve my question.
I require that all A, B, T are integer matrices. The approach that given in the cited answer there does not produce integer matrix T.
Here I require symmetric integer A and symmetric integer B, and possibly generic non-symmetric integer T. (There is no diagonal matrix as the cited question.)
In fact I require UNIMODULAR determinant = 1 for A, B, T matrices in all my examples.
For those who closed this question, please use my toy rank-10 example to give me a Mathematica solution to it. Just to test that your answer really solves this.