# Solve matrix equation with given matrices $A$, $B$

I am reading Conway and Sloane's book Sphere Packings, Lattice, and Groups. There is a condition on congruence lattices:

given Gram matrices $$A$$ and $$B$$ (which are square, real, symmetric, and positive definite), they describe congruent lattices iff $$A = c^2XBX^{tr}$$ for $$X$$ unimodular (determinant 1 and all integer components) and some constant $$c$$.

I want to be able to check if two lattices are congruent using this equation. How should I go about solving for $$X$$ ?

I understand that t-congruence is given as $$A = XBX^{tr}$$, in general. I have researched methodology to solve for $$X$$ in this t-congruence case, but the solution is not necessarily unique, and hence won't generally return $$X$$ as unimodular even if I know such a unimodular $$X$$ exists. Is there an appropriate algorithm I should consider in solving for the unimodular case?

Let us consider the most natural way to obtain an $$X$$ complying with relationship:

$$A=XBX^T\tag{1}$$

Consider the two eigendecompositions :

$$A=X_1D_1X_1^{-1}=X_1D_1X_1^T \ and \ B=X_2D_2X_2^{-1}=X_2D_2X_2^T\tag{2}$$

Remark: we can write: $$X_1^T=X_1^{-1}$$ and $$X_2^T=X_2^{-1}$$ because the eigenvectors of symmetric matrices can be taken so as to constitute an orthonormal basis, explaining that we can take $$X_1$$ and $$X_2$$ as orthogonal matrices.

Writing $$D_1=\Delta_1^2$$ and $$D_2=\Delta_2^2$$, which is possible because the eigenvalues are $$\ge 0$$, (2) can be written:

$$A=(X_1\Delta_1)(X_1 \Delta_1)^T \ and \ B=(X_2\Delta_2)(X_2 \Delta_2)^T\tag{3}$$

In view of (3)

$$X=(X_1\Delta_1)(X_2 \Delta_2)^{-1}\tag{4}$$

is a solution to (1).

More generaly, if $$Q$$ is any orthogonal matrix:

$$X=(X_1\Delta_1)Q(X_2 \Delta_2)^{-1}\tag{5}$$

is a solution to (1).

I am almost certain that (5) is the general solution to (1), but I am unable to find a thorough reference.

Among the matrices expressed by formula (5), are there unimodular solutions ? By taking for $$Q$$ permutation matrices ?

• No comment ? I could have mentionned that a good image of the transformation I have described (I have been guided by it) is the 3D mapping from an ellipsoid onto another ellipsoid with the up-scaling of the different semiaxes by the square root of their length (eigenvalues) in all directions. Apr 23, 2021 at 14:54
• @user1551 As I appreciate your linear algebra answers, have you seen this issue ? My answer is partial ; I would be happy to know why the general solution of equation $A=XBX^T$ in the set of $n \times n$ orthogonal matrices is as I have indicated it. [Besides the unimodular condition looks to me difficult to reach...] Apr 23, 2021 at 15:20
• This is extremely helpful. Thank you for the response. And yes, now we just need to know how to find if such a $Q$ exists to reach the unimodular condition. Thank you. Apr 23, 2021 at 15:32