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.Sat, 03 Aug 2013 12:26:35 +0200Symbolic matrices and "integrity" of their inversehttps://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/I have to solve the following problem:
Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?
Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.
E.g.:
$$\left(\begin{array}{cc}x & 0 \\\\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.
Is there a quick method within Sage to solve that last problem?
Thanks!Mon, 17 Oct 2011 12:44:30 +0200https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/Comment by parzan for <p>I have to solve the following problem:</p>
<p>Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?</p>
<p>Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.</p>
<p>E.g.:
$$\left(\begin{array}{cc}x & 0 \\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.</p>
<p>Is there a quick method within Sage to solve that last problem?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21106#post-id-21106An integer matrix is in GL(n,Z) (i.e., invertible with integer inverse) if and only if its determinant is 1 or -1 (from wikipedia: a square matrix over a commutative ring is invertible if and only if its determinant is a unit in that ring.) This might help you...Tue, 18 Oct 2011 08:28:07 +0200https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21106#post-id-21106Comment by Jesustc for <p>I have to solve the following problem:</p>
<p>Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?</p>
<p>Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.</p>
<p>E.g.:
$$\left(\begin{array}{cc}x & 0 \\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.</p>
<p>Is there a quick method within Sage to solve that last problem?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21103#post-id-21103It does help me indeed, thanks! I should have known that...
My main concern now is how to find out whether a polynomial equation (det=+/-1) has integer roots or not. "assume()" does not the trick :(Tue, 18 Oct 2011 11:51:33 +0200https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21103#post-id-21103Comment by Jesustc for <p>I have to solve the following problem:</p>
<p>Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?</p>
<p>Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.</p>
<p>E.g.:
$$\left(\begin{array}{cc}x & 0 \\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.</p>
<p>Is there a quick method within Sage to solve that last problem?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21009#post-id-21009Thanks a lot for the comments, Parzan and Palmieri!
What do you think about erasing the question? I don't think it is useful for anybody.Fri, 28 Oct 2011 11:22:31 +0200https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21009#post-id-21009Comment by John Palmieri for <p>I have to solve the following problem:</p>
<p>Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?</p>
<p>Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.</p>
<p>E.g.:
$$\left(\begin{array}{cc}x & 0 \\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.</p>
<p>Is there a quick method within Sage to solve that last problem?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21101#post-id-21101"Integrality" would be a better word than "integrity".Tue, 18 Oct 2011 13:55:10 +0200https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21101#post-id-21101Comment by parzan for <p>I have to solve the following problem:</p>
<p>Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?</p>
<p>Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.</p>
<p>E.g.:
$$\left(\begin{array}{cc}x & 0 \\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.</p>
<p>Is there a quick method within Sage to solve that last problem?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21102#post-id-21102This is in general an undecidable question - see http://en.wikipedia.org/wiki/Hilbert%27s_tenth_problem. However, for specific cases you might be able to find a solution.Tue, 18 Oct 2011 12:08:40 +0200https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=21102#post-id-21102Answer by tmonteil for <p>I have to solve the following problem:</p>
<p>Does a matrix $G\in GL(n,\mathbb{Z})$ exists such that
$$
G\times A\times G^{-1}=B
$$
being $A,B$ given matrices in $\mathbb{Q}$?</p>
<p>Doing everything by hand, I finally find myself with a bunch of symbolic matrices. Now I have to check if they can lay inside $GL(n,\mathbb{Z})$, i.e. if there are integer values for the variables in the matrix such that the matrix is integer, invertible and with integer inverse.</p>
<p>E.g.:
$$\left(\begin{array}{cc}x & 0 \\ 0 & y\end{array}\right)$$ does the trick only for $x=y=1$.</p>
<p>Is there a quick method within Sage to solve that last problem?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?answer=15146#post-id-15146A direct approach (not using symbolic solving) could be:
sage: A = matrix(QQ,[[3,1],[2,4]]) ; A
[3 1]
[2 4]
sage: B = matrix(QQ,[[2,4],[0,5]]) ; B
[2 4]
[0 5]
sage: A.is_similar(B)
True
sage: T = A.is_similar(B,transformation=True)[1] ; T
[ 1.000000000000000? 0.?e-18]
[0.2500000000000000? 0.2500000000000000?]
sage: T.change_ring(QQ)
[ 1 0]
[1/4 1/4]
sage: G = T.change_ring(QQ)/det(T) ; G
[4 0]
[1 1]
sage: G * A * G^(-1) == B
True
See `A.is_similar?` for details.
Wed, 26 Jun 2013 18:14:35 +0200https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?answer=15146#post-id-15146Comment by Jesustc for <p>A direct approach (not using symbolic solving) could be:</p>
<pre><code>sage: A = matrix(QQ,[[3,1],[2,4]]) ; A
[3 1]
[2 4]
sage: B = matrix(QQ,[[2,4],[0,5]]) ; B
[2 4]
[0 5]
sage: A.is_similar(B)
True
sage: T = A.is_similar(B,transformation=True)[1] ; T
[ 1.000000000000000? 0.?e-18]
[0.2500000000000000? 0.2500000000000000?]
sage: T.change_ring(QQ)
[ 1 0]
[1/4 1/4]
sage: G = T.change_ring(QQ)/det(T) ; G
[4 0]
[1 1]
sage: G * A * G^(-1) == B
True
</code></pre>
<p>See <code>A.is_similar?</code> for details.</p>
https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=17194#post-id-17194That's a good one, thanks!Sat, 03 Aug 2013 12:26:35 +0200https://ask.sagemath.org/question/8391/symbolic-matrices-and-integrity-of-their-inverse/?comment=17194#post-id-17194