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, 03 Jun 2013 10:34:18 +0200Lifting matrices to $SL_2(\mathbb{Z})$https://ask.sagemath.org/question/10180/lifting-matrices-to-sl_2mathbbz/Is there a way to lift a matrix in $Sl_2(\mathbb{Z}/N\mathbb{Z})$ to $SL_2(\mathbb{Z})$ for an arbitrary N ?
I found this algorithm : [here](http://trac.sagemath.org/sage_trac/ticket/3313)
But it seems to work only when $N$ is prime. I think that the algorithm described in Shimura (which the implementation cited above is base on) works for arbitrary N. But I don't know how to modify the one above to make it work. Does anyone know how to do it.
Ultimately my goal is to iterate through a list of representatives of $SL_2(\mathbb{Z}/24\mathbb{Z})$ in $SL_2(\mathbb{Z})$ so if anyone knows how to it without the above I would be equally (in fact probably more) grateful.
**edit :** Ok now I see at least one reason why the code mentionned above fails and in fact it isn't because of the arbitrary ring but because the smith normal form function doesn't return elements in $SL_2(\mathbb{Z})$ but only invertible matrices. Anyone knows how to bypass this ?Fri, 31 May 2013 19:29:39 +0200https://ask.sagemath.org/question/10180/lifting-matrices-to-sl_2mathbbz/Answer by Zorn_lemma for <p>Is there a way to lift a matrix in $Sl_2(\mathbb{Z}/N\mathbb{Z})$ to $SL_2(\mathbb{Z})$ for an arbitrary N ?</p>
<p>I found this algorithm : <a href="http://trac.sagemath.org/sage_trac/ticket/3313">here</a></p>
<p>But it seems to work only when $N$ is prime. I think that the algorithm described in Shimura (which the implementation cited above is base on) works for arbitrary N. But I don't know how to modify the one above to make it work. Does anyone know how to do it.</p>
<p>Ultimately my goal is to iterate through a list of representatives of $SL_2(\mathbb{Z}/24\mathbb{Z})$ in $SL_2(\mathbb{Z})$ so if anyone knows how to it without the above I would be equally (in fact probably more) grateful.</p>
<p><strong>edit :</strong> Ok now I see at least one reason why the code mentionned above fails and in fact it isn't because of the arbitrary ring but because the smith normal form function doesn't return elements in $SL_2(\mathbb{Z})$ but only invertible matrices. Anyone knows how to bypass this ?</p>
https://ask.sagemath.org/question/10180/lifting-matrices-to-sl_2mathbbz/?answer=15013#post-id-15013OK I found the solution. In the code I mentioned the error was that smith_form doesn't return matrices in $SL_2(\mathbb{Z})$. It's quite easy to correct by the following snippet that you have to add just after you use smith_form :
D, U, V = A.smith_form()
if det(U) == -1 :
U = matrix(2,2,[-1,0,0,1])* U
if det(V) == -1 :
V = V *matrix(2,2,[-1,0,0,1])
D = U*A*VSat, 01 Jun 2013 08:04:57 +0200https://ask.sagemath.org/question/10180/lifting-matrices-to-sl_2mathbbz/?answer=15013#post-id-15013Comment by tmonteil for <p>OK I found the solution. In the code I mentioned the error was that smith_form doesn't return matrices in $SL_2(\mathbb{Z})$. It's quite easy to correct by the following snippet that you have to add just after you use smith_form : </p>
<pre><code> D, U, V = A.smith_form()
if det(U) == -1 :
U = matrix(2,2,[-1,0,0,1])* U
if det(V) == -1 :
V = V *matrix(2,2,[-1,0,0,1])
D = U*A*V
</code></pre>
https://ask.sagemath.org/question/10180/lifting-matrices-to-sl_2mathbbz/?comment=17588#post-id-17588Thanks for posting it, this may help resolution of the trac ticket you mentionned.Sat, 01 Jun 2013 08:19:40 +0200https://ask.sagemath.org/question/10180/lifting-matrices-to-sl_2mathbbz/?comment=17588#post-id-17588Answer by Marco Streng for <p>Is there a way to lift a matrix in $Sl_2(\mathbb{Z}/N\mathbb{Z})$ to $SL_2(\mathbb{Z})$ for an arbitrary N ?</p>
<p>I found this algorithm : <a href="http://trac.sagemath.org/sage_trac/ticket/3313">here</a></p>
<p>But it seems to work only when $N$ is prime. I think that the algorithm described in Shimura (which the implementation cited above is base on) works for arbitrary N. But I don't know how to modify the one above to make it work. Does anyone know how to do it.</p>
<p>Ultimately my goal is to iterate through a list of representatives of $SL_2(\mathbb{Z}/24\mathbb{Z})$ in $SL_2(\mathbb{Z})$ so if anyone knows how to it without the above I would be equally (in fact probably more) grateful.</p>
<p><strong>edit :</strong> Ok now I see at least one reason why the code mentionned above fails and in fact it isn't because of the arbitrary ring but because the smith normal form function doesn't return elements in $SL_2(\mathbb{Z})$ but only invertible matrices. Anyone knows how to bypass this ?</p>
https://ask.sagemath.org/question/10180/lifting-matrices-to-sl_2mathbbz/?answer=15016#post-id-15016Actually, the question asks only for SL_2, while the trac ticket is more general (SL_m). The case of SL_2 is already in Sage (as long as N <= 2147483647). Try
sage: lift_to_sl2z?
or see [lift_to_sl2z in the reference manual](http://www.sagemath.org/doc/reference/modsym/sage/modular/modsym/p1list.html#sage.modular.modsym.p1list.P1List.lift_to_sl2z)Mon, 03 Jun 2013 10:34:18 +0200https://ask.sagemath.org/question/10180/lifting-matrices-to-sl_2mathbbz/?answer=15016#post-id-15016