I have two symmetric, integer matrices, $K$ and $K_2$ which have the same determinant and the same signature (number of positive - number of negative eigenvalues). I want to find an integer valued matrix, $X$, such that $$X^T K X= K_2$$ and determinant of $X = \pm 1$.

For example,

K = {{0, 2, 1, 1}, {2, 0, 0, 0}, {1, 0, 1, 0}, {1, 0, 0, -1}};
K2 = {{0, 2, 0, 0}, {2, 0, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, -1}};

Is there a way to approach this besides using FindInstance (which doesn't seem to work in finite time for even a $4\times4$ matrix)? The system is under constrained since the matrices are symmetric, but I'm just looking for a way to find even one such $X$ for a given pair, $K$ and $K_2$, which could be as large as $8\times8$.


1 Answer 1


Using Smith Normal Form you can get two integer matrices with determinant 1 that would satisfy the equation

$$X1.K.X2 = K_2$$

May be this is a good start you can use...

resK = SmithDecomposition[K];
MatrixForm /@ resK

resK2 = SmithDecomposition[K2];
MatrixForm /@ resK2

resK[[2]] == resK2[[2]]
(* True *)

K2 == 
(* True *)

X1 = Inverse[resK2[[1]]].resK[[1]];

X2 = resK[[3]].Inverse[resK2[[3]]];

X1.K.X2 == K2
(* True *)

Det /@ {X1, X2}
(* {1, 1} *)

MatrixForm /@ {X1, X2}

enter image description here

  • $\begingroup$ Yes, both the Smith and Hermite decompositions do involve unimodular factors, but I don't see a straightforward way to derive a congruence transformation from them, which is what the OP apparently seeks. $\endgroup$ May 25, 2016 at 14:48
  • $\begingroup$ @J.M. Well the OP asks for two matrices satisfying four conditions, and apparently two matrices satisfying three of them for the matrices provided can be found not using FindInstance. This might be good enough or a good start... $\endgroup$ May 25, 2016 at 15:20
  • $\begingroup$ Hmm, the OP already has $k$ and $k_2$, and is only looking for one matrix that does the required congruence. I'm just saying it does not seem to look straightforward to do with those two decompositions. $\endgroup$ May 25, 2016 at 15:26
  • 1
    $\begingroup$ Hi @AntonAntonov, I wanted to solve the same problem as the OP (cf. here), and I was directed here. I'm not sure if this answer really solves the problem though: what you did was to find two matrices $X_1,X_2$ such that $X_1KX_2=K_2$; but these matrices do not satisfy $X_1=X_2^T$, which is what the OP (and I) wanted. This answer was marked as solved, but the problem is actually still open, right? $\endgroup$ Oct 9, 2018 at 16:27
  • 1
    $\begingroup$ see this mathematica.stackexchange.com/q/293896/95437 if any new thoughts. $\endgroup$
    – zeta
    Dec 10, 2023 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.