Ask Your Question
0

generation of certain matrices

asked 2017-06-08 19:26:31 +0100

Daniel L gravatar image

I'd like to create a list of roughly 100-1000 $2 \times 2$ matrices $[A_1,A_2,...,A_N]$ that have the following properties:

  1. $\det A_j = 1$

  2. The entries of each $A_j$ are in an imaginary quadratic integer ring, such as $\mathbb{Z}[i]$, or $\mathbb{Z}[\sqrt{-2}]$

For example, the matrix $$\begin{bmatrix} 1&2i \\ 0&1 \end{bmatrix}$$ fits the above specifications when the ring is $\mathbb{Z}[i]$.

I know that I probably want to run some kind of loop over the entries of the matrix, but I'm not sure how to do this. Perhaps I want to initially treat the matrices as lists of length 4, and then run an iterative loop over the lists. Then, when the above specifications are met, that list is stored somewhere else. I think I'd also like to put a bound on the "size" of the matrix entries, but that should be easy to do afterwards.

Thanks!

edit retag flag offensive close merge delete

Comments

Hmm, there is a random_matrix command which might be helpful here.

kcrisman gravatar imagekcrisman ( 2017-06-08 19:35:09 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-06-08 19:36:11 +0100

kcrisman gravatar image

updated 2017-06-09 20:32:44 +0100

Or you could use the algorithm='unimodular' option to random_matrix.

sage: random_matrix(GaussianIntegers(),2,algorithm='unimodular')

[-429*I + 54     -I - 10]
[   43*I - 1           1]
sage: random_matrix(GaussianIntegers(),2,algorithm='unimodular')

[  6*I - 7 -7*I - 12]
[    I - 1    -I - 2]
sage: random_matrix(GaussianIntegers(),2,algorithm='unimodular')

[   -6*I + 29 -221*I - 103]
[       I + 9    -74*I - 9]

You'd need to define your other rings and plop them in the right spot, of course. Edit: such as follows, though there are probably better ways to get this ring. In particular, be careful since the integral closure of $\mathbb{Z}[\sqrt{n}]$ isn't always equal to it, but depends on the residue class of n (mod 4), if I recall correctly.

K = NumberField(x^2 + 2, 's')
OK = K.ring_of_integers()
for n in range(3):
    show(random_matrix(OK,2,algorithm='unimodular'))
edit flag offensive delete link more

Comments

This works well. It is a little bit annoying using the symbol 's' instead of the complex number sqrt(-2). Sage does seem to be able to work with it a little bit. For instance, M; M[1,0]; M[1,0][0]; M[1,0][1]; returns

[ s - 1 4*s + 19]

[ -s - 1 11*s - 12]

-s - 1

-1

-1

Daniel L gravatar imageDaniel L ( 2017-06-08 22:18:03 +0100 )edit
1

There are no problems for me... For instance:

sage: K.<s> = QuadraticField( -2 )
sage: OK    = K.ring_of_integers() 
sage: M = random_matrix( OK, 2, algorithm = 'unimodular' )
sage: M
[  -s + 9 3*s + 10]
[      -s   -s + 1]
sage: M[0,0]
-s + 9
sage: M[0,1]
3*s + 10
sage: M[1,0]
-s
sage: M[1,1]
-s + 1
sage: a = M[0,0]
sage: a.list()
[9, -1]
sage: a[0]
9
sage: a[1]
-1

It seems that the entry $M_{00}=9-s = 9s^0+ (-1)s^1$ is stored as a list / as a vector, and asking for its components, a[0] and a[1], implicitly forces the conversion to a list.

dan_fulea gravatar imagedan_fulea ( 2017-06-09 21:38:50 +0100 )edit

I'm sure there is a way to get the symbol to "look better" but I don't know how to do this as I typically only use the Gaussian integers, for which there is already the built-in symbol I.

kcrisman gravatar imagekcrisman ( 2017-06-09 22:36:07 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-06-08 19:26:31 +0100

Seen: 388 times

Last updated: Jun 09 '17