ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 11 Dec 2023 17:11:19 +0100Determine Two quadratic form is integer congruence (rational equivalent)?https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/Fix $n \\geq 2$ and consider $A,B \\in \\operatorname{GL}(n,\\mathbb{Z}).$
We know that we have the Smith normal form.
One can find $U, V \\in \\operatorname{SL}(n,\\mathbb{Z})$ such that $A=UDV.$
Likewise for $B$. The Smith normal form is easy to compute using Mathematica.
We also call two matrices $A,B$ congruent if there exists
$X \\in \\operatorname{PSL}(n,\\mathbb{Z})$ such that $X^TAX=B$.
Now we have the following: if two matrices are congruent, then they have the same $D$.
But now, given two 4 by 4 matrices with same Smith normal form $D$,
how to verify they are congruent?
An if they are, how to find a matrix $X$ such that $X^T A X = B$.
To be more specific, suppose
$A = \\begin{bmatrix}
2 & -1 & -1 & -1 \\\\
-1 & 2 & 0 & 0 \\\\
-1 & 0 & 2 & 0 \\\\
-1 & 0 & 0 & 2 \\\\
\\end{bmatrix}$
and
$B = \\begin{bmatrix}
4 & -6 & 4 & -2 \\\\
-6 & 12 & -8 & 4 \\\\
4 & -8 & 6 & -3 \\\\
-2 & 4 & -3 & 2 \\\\
\\end{bmatrix}.$
I want to ask whether $A,B$ are congruent. Here is how far I got.
$A$, $B$ both have the same Smith normal form
$D = \\begin{bmatrix}
1 & 0 & 0 & 0 \\\\
0 & 1 & 0 & 0 \\\\
0 & 0 & 2 & 0 \\\\
0 & 0 & 0 & 2 \\\\
\\end{bmatrix}.$
So they define the same integer lattices.
But I do not know whether they are congruent.
I suspect they are congruent but I have no idea how to prove it.
Any ideas or comments are really appreciated.
By the way, $A$ is the Cartan matrix of $SO(8).$
I think it will not help.
I used Sage and typed them in as quadratic forms.
But I found that the `is_rationally_isometric` function only works
for number field but not integers ring (if I use integers,
there will be an error like no real_embedding).
The `is_rationally_isometric` is True.
But I do not know whether they are isometric over the integers.
If the answer is true, can I find such X?
sage: A = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: print(A)
sage: A1 = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: print(A1)
sage: A1.is_rationally_isometric(A)
TrueSat, 16 Jan 2021 03:33:07 +0100https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/Comment by slelievre for <p>Fix $n \geq 2$ and consider $A,B \in \operatorname{GL}(n,\mathbb{Z}).$
We know that we have the Smith normal form.
One can find $U, V \in \operatorname{SL}(n,\mathbb{Z})$ such that $A=UDV.$
Likewise for $B$. The Smith normal form is easy to compute using Mathematica.</p>
<p>We also call two matrices $A,B$ congruent if there exists
$X \in \operatorname{PSL}(n,\mathbb{Z})$ such that $X^TAX=B$.</p>
<p>Now we have the following: if two matrices are congruent, then they have the same $D$.</p>
<p>But now, given two 4 by 4 matrices with same Smith normal form $D$,
how to verify they are congruent?
An if they are, how to find a matrix $X$ such that $X^T A X = B$.</p>
<p>To be more specific, suppose
$A = \begin{bmatrix}
2 & -1 & -1 & -1 \\
-1 & 2 & 0 & 0 \\
-1 & 0 & 2 & 0 \\
-1 & 0 & 0 & 2 \\
\end{bmatrix}$
and
$B = \begin{bmatrix}
4 & -6 & 4 & -2 \\
-6 & 12 & -8 & 4 \\
4 & -8 & 6 & -3 \\
-2 & 4 & -3 & 2 \\
\end{bmatrix}.$</p>
<p>I want to ask whether $A,B$ are congruent. Here is how far I got.</p>
<p>$A$, $B$ both have the same Smith normal form
$D = \begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 2 & 0 \\
0 & 0 & 0 & 2 \\
\end{bmatrix}.$
So they define the same integer lattices.
But I do not know whether they are congruent.</p>
<p>I suspect they are congruent but I have no idea how to prove it.
Any ideas or comments are really appreciated.
By the way, $A$ is the Cartan matrix of $SO(8).$
I think it will not help.</p>
<p>I used Sage and typed them in as quadratic forms.
But I found that the <code>is_rationally_isometric</code> function only works
for number field but not integers ring (if I use integers,
there will be an error like no real_embedding).
The <code>is_rationally_isometric</code> is True.
But I do not know whether they are isometric over the integers.
If the answer is true, can I find such X?</p>
<pre><code>sage: A = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: print(A)
sage: A1 = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: print(A1)
sage: A1.is_rationally_isometric(A)
True
</code></pre>
https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?comment=55299#post-id-55299Welcome to Ask Sage!
Thank you for your question!Sat, 16 Jan 2021 10:02:54 +0100https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?comment=55299#post-id-55299Answer by rburing for <p>Fix $n \geq 2$ and consider $A,B \in \operatorname{GL}(n,\mathbb{Z}).$
We know that we have the Smith normal form.
One can find $U, V \in \operatorname{SL}(n,\mathbb{Z})$ such that $A=UDV.$
Likewise for $B$. The Smith normal form is easy to compute using Mathematica.</p>
<p>We also call two matrices $A,B$ congruent if there exists
$X \in \operatorname{PSL}(n,\mathbb{Z})$ such that $X^TAX=B$.</p>
<p>Now we have the following: if two matrices are congruent, then they have the same $D$.</p>
<p>But now, given two 4 by 4 matrices with same Smith normal form $D$,
how to verify they are congruent?
An if they are, how to find a matrix $X$ such that $X^T A X = B$.</p>
<p>To be more specific, suppose
$A = \begin{bmatrix}
2 & -1 & -1 & -1 \\
-1 & 2 & 0 & 0 \\
-1 & 0 & 2 & 0 \\
-1 & 0 & 0 & 2 \\
\end{bmatrix}$
and
$B = \begin{bmatrix}
4 & -6 & 4 & -2 \\
-6 & 12 & -8 & 4 \\
4 & -8 & 6 & -3 \\
-2 & 4 & -3 & 2 \\
\end{bmatrix}.$</p>
<p>I want to ask whether $A,B$ are congruent. Here is how far I got.</p>
<p>$A$, $B$ both have the same Smith normal form
$D = \begin{bmatrix}
1 & 0 & 0 & 0 \\
0 & 1 & 0 & 0 \\
0 & 0 & 2 & 0 \\
0 & 0 & 0 & 2 \\
\end{bmatrix}.$
So they define the same integer lattices.
But I do not know whether they are congruent.</p>
<p>I suspect they are congruent but I have no idea how to prove it.
Any ideas or comments are really appreciated.
By the way, $A$ is the Cartan matrix of $SO(8).$
I think it will not help.</p>
<p>I used Sage and typed them in as quadratic forms.
But I found that the <code>is_rationally_isometric</code> function only works
for number field but not integers ring (if I use integers,
there will be an error like no real_embedding).
The <code>is_rationally_isometric</code> is True.
But I do not know whether they are isometric over the integers.
If the answer is true, can I find such X?</p>
<pre><code>sage: A = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: print(A)
sage: A1 = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: print(A1)
sage: A1.is_rationally_isometric(A)
True
</code></pre>
https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?answer=55318#post-id-55318The method `is_globally_equivalent_to` answers this and provides the matrix:
sage: QA = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: QB = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: X = QA.is_globally_equivalent_to(QB, return_matrix=True); X
[ 0 0 0 1]
[ 0 0 1 0]
[ 0 1 1 -1]
[ 1 1 -1 -1]
sage: X.transpose()*QA.matrix()*X == QB.matrix()
True
This calls the PARI function [qfisom](https://pari.math.u-bordeaux.fr/dochtml/help/qfisom), which implements an algorithm of Plesken and Souvignier.Sun, 17 Jan 2021 16:15:47 +0100https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?answer=55318#post-id-55318Comment by azerbajdzan for <p>The method <code>is_globally_equivalent_to</code> answers this and provides the matrix:</p>
<pre><code>sage: QA = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: QB = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: X = QA.is_globally_equivalent_to(QB, return_matrix=True); X
[ 0 0 0 1]
[ 0 0 1 0]
[ 0 1 1 -1]
[ 1 1 -1 -1]
sage: X.transpose()*QA.matrix()*X == QB.matrix()
True
</code></pre>
<p>This calls the PARI function <a href="https://pari.math.u-bordeaux.fr/dochtml/help/qfisom">qfisom</a>, which implements an algorithm of Plesken and Souvignier.</p>
https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?comment=74791#post-id-74791@rburing: Thanks. Done.Mon, 11 Dec 2023 17:11:19 +0100https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?comment=74791#post-id-74791Comment by rburing for <p>The method <code>is_globally_equivalent_to</code> answers this and provides the matrix:</p>
<pre><code>sage: QA = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: QB = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: X = QA.is_globally_equivalent_to(QB, return_matrix=True); X
[ 0 0 0 1]
[ 0 0 1 0]
[ 0 1 1 -1]
[ 1 1 -1 -1]
sage: X.transpose()*QA.matrix()*X == QB.matrix()
True
</code></pre>
<p>This calls the PARI function <a href="https://pari.math.u-bordeaux.fr/dochtml/help/qfisom">qfisom</a>, which implements an algorithm of Plesken and Souvignier.</p>
https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?comment=74787#post-id-74787@azerbajdzan I don't know, you may want to submit that as a new question (linking to this one).Mon, 11 Dec 2023 14:10:42 +0100https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?comment=74787#post-id-74787Comment by azerbajdzan for <p>The method <code>is_globally_equivalent_to</code> answers this and provides the matrix:</p>
<pre><code>sage: QA = QuadraticForm(QQ, 4, [4, -12, 8, -4, 12, -16, 8, 6, -6, 2])
sage: QB = QuadraticForm(QQ, 4, [2, -2, -2, -2, 2, 0, 0, 2, 0, 2])
sage: X = QA.is_globally_equivalent_to(QB, return_matrix=True); X
[ 0 0 0 1]
[ 0 0 1 0]
[ 0 1 1 -1]
[ 1 1 -1 -1]
sage: X.transpose()*QA.matrix()*X == QB.matrix()
True
</code></pre>
<p>This calls the PARI function <a href="https://pari.math.u-bordeaux.fr/dochtml/help/qfisom">qfisom</a>, which implements an algorithm of Plesken and Souvignier.</p>
https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?comment=74785#post-id-74785Why it only works when matrices are positive definite? Any idea how to solve it if we have quadratic form that its Gram matrix is non-positive definite?Mon, 11 Dec 2023 14:00:32 +0100https://ask.sagemath.org/question/55294/determine-two-quadratic-form-is-integer-congruence-rational-equivalent/?comment=74785#post-id-74785