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.Thu, 01 Feb 2018 16:25:51 +0100random matrix with determinant +- 1https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/ I want to generate a random 4x4 matrix with integer entries and determinant either 1 or -1. I know that you can use
`random_matrix(ZZ,4,4, algorithm = 'unimodular')`
to generate matrices with determinant 1 (so in the special linear group). However, I'm actually more interested in the matrices with determinant -1.
Is there a 'Sage' way to do this? Or are there other functions/routines out there I should look at?
Thanks!
Thu, 01 Feb 2018 05:15:26 +0100https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/Answer by dan_fulea for <p>I want to generate a random 4x4 matrix with integer entries and determinant either 1 or -1. I know that you can use</p>
<p><code>random_matrix(ZZ,4,4, algorithm = 'unimodular')</code></p>
<p>to generate matrices with determinant 1 (so in the special linear group). However, I'm actually more interested in the matrices with determinant -1. </p>
<p>Is there a 'Sage' way to do this? Or are there other functions/routines out there I should look at?</p>
<p>Thanks!</p>
https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/?answer=40914#post-id-40914Exchanging the first two columns of a random unimodular matrix...Thu, 01 Feb 2018 05:25:57 +0100https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/?answer=40914#post-id-40914Comment by Daniel L for <p>Exchanging the first two columns of a random unimodular matrix...</p>
https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/?comment=40916#post-id-40916Right, that should work!...I'll let you know...Thu, 01 Feb 2018 06:27:00 +0100https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/?comment=40916#post-id-40916Comment by Daniel L for <p>Exchanging the first two columns of a random unimodular matrix...</p>
https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/?comment=40920#post-id-40920This works. Nice simple solution. Thanks Dan.Thu, 01 Feb 2018 16:25:51 +0100https://ask.sagemath.org/question/40912/random-matrix-with-determinant-1/?comment=40920#post-id-40920