-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgroup_order.py
87 lines (71 loc) · 2.26 KB
/
group_order.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env sage
# USE:
# ./sagegroup_order.py T D nmax
# where T is the 16-digit bitstring for the matrix
# D is one of E, N, W, S
# and nmax is a positive integer, corresponding to the maximum order of the group to be considered
from sage.all import *
# the 1001010... string
Tstring = sys.argv[1]
# convert that into the matrix
Tlist = [[0 for i in range(4)] for j in range(4)]
for k in range(16):
Tlist[k//4][k%4] = int(Tstring[k])
T = matrix(Tlist)
# some matrices and vectors to start up
IE = diagonal_matrix([0,1,1,1])
IN = diagonal_matrix([1,0,1,1])
IW = diagonal_matrix([1,1,0,1])
IS = diagonal_matrix([1,1,1,0])
I4 = identity_matrix(4)
# variables
t,x,y,X,Y = var('t,x,y,X,Y')
# the version of T with t,x,y
Txy = T*diagonal_matrix([t*x,t*y,t/x,t/y])
D = sys.argv[2]
# 1-B is roughly the same as the kernel for a regular quarter plane model
if D is 'E':
B = ((Txy.T)[0])*(~(I4-IE*(Txy.T))*IE*Txy[0] + (I4-IE)*vector([1,1,1,1]))
elif D is 'N':
B = ((Txy.T)[1])*(~(I4-IN*(Txy.T))*IN*Txy[1] + (I4-IN)*vector([1,1,1,1]))
elif D is 'W':
B = ((Txy.T)[2])*(~(I4-IW*(Txy.T))*IW*Txy[2] + (I4-IW)*vector([1,1,1,1]))
elif D is 'S':
B = ((Txy.T)[3])*(~(I4-IS*(Txy.T))*IS*Txy[3] + (I4-IS)*vector([1,1,1,1]))
else:
raise ValueError
# finding the group
BX = B.subs(x = X)
BY = B.subs(y = Y)
Xsols = solve(B == BX, X)
Ysols = solve(B == BY, Y)
# getting the generators
if (bool(Xsols[0].right() == x)):
xp = Xsols[1].right().factor()
else:
xp = Xsols[0].right().factor()
if (bool(Ysols[0].right() == y)):
yp = Ysols[1].right().factor()
else:
yp = Ysols[0].right().factor()
# the maximum order of the group we are allowing
maxn = int(sys.argv[3])
# trying to find the order of the group
pairs = [(x,y)]
# we have to assume some upper bound at which we give up
# and declare the group to be infinite
finite = False
for n in range(1, maxn+1):
# print('trying', n)
if n%2 == 1:
pairs.append((pairs[n-1][0].subs(x=xp).factor(),pairs[n-1][1].subs(x=xp).factor()))
else:
pairs.append((pairs[n-1][0].subs(y=yp).factor(),pairs[n-1][1].subs(y=yp).factor()))
if bool(pairs[n][0] == x) and bool(pairs[n][1] == y):
finite = True
break
# print the order of the group, or 0 if 'infinite'
if finite:
print(n)
else:
print(0)