ToVector := proc(M) local i,L; L := map(op,convert(M,listlist)); [seq(coeff(i,sqrt(2),0),i=L),seq(coeff(i,sqrt(2),1),i=L)] end: ToMatrix := proc(V) local i,j; Matrix([seq([seq(V[i+2*j] + V[i+2*j+4]*sqrt(2),i=1..2)],j=0..1)]) end: w := 2^(1/2); A1 := Matrix( [[-w , w/2+1],[-2-w,2+w]] ); A2 := Matrix( [[ 1 , 0],[-2 , 1 ]] ); A3 := Matrix( [[2-w,-w/2+1],[-2+w, w ]] ); A4 := Matrix( [[ -1, -1 ],[ 0 ,-1 ]] ); G := map(Matrix,[A1, A2, A3, A4, [[1,0], [0,1]] ] ); B := G: LengthL := proc(L) add( coeff(i,sqrt(2),0)^2 + 2 * coeff(i,sqrt(2),1)^2, i=map(op,L)) end: to 10 do B := {seq(seq( i.j, i=B), j=G)}; # (*) lprint(nops(B)); B := expand(map(convert,B,listlist)); lprint("RED",nops(B)); if nops(B) > 10000 then B := [seq( [i,LengthL(i)], i = B)]: B := sort([op(B)], (i,j) -> i[2] < j[2] )[1..10000]; B := map( i -> i[1], B) fi; B := map(Matrix,B): od: # Now type B[1..100] or B[1..200] to see the smallest 100 (or 200) matrices in the group. # Or view some triangular matrices with 1's on the diagonal: seq(`if`(i[1,1] = 1 and i[2,2] = 1, i, NULL), i=B[1..1000]);