-
Notifications
You must be signed in to change notification settings - Fork 1
/
dimension.sage
153 lines (127 loc) · 4.2 KB
/
dimension.sage
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
from symbolictetra.py import complement, doublecomplement
def WD_matrix(lengths):
"""
Parameters
List of Edgelengths [12,13,14,23,24,34]
Returns:
The D matrix!
"""
D=Matrix([[0, lengths[0]**2, lengths[1]**2, lengths[2]**2, 1],
[lengths[0]**2, 0, lengths[3]**2, lengths[4]**2, 1],
[lengths[1]**2, lengths[3]**2, 0, lengths[5]**2, 1],
[lengths[2]**2, lengths[4]**2,lengths[5]**2,0,1],
[1,1,1,1,0]])
return D
def lexi(arr):
return [arr[0], arr[2], arr[4], arr[5], arr[3], arr[1]]
def D_3(i,j,k, lengths):
"""
Parameters
lengths:List of Edgelengths [12,13,14,23,24,34]; one or more of which is a symbol (variable).
Distinct i,j,k in {1,2,3,4}
Returns:
D_ijk, as defined in WD's paper
"""
l=complement(i, j, k)
M=WD_matrix(lengths)
M=M.delete_columns([l-1])
M=M.delete_rows([l-1])
return M.det()
def D_2(i,j, lengths):
"""
Parameters
i,j: distinct integers in {1,2,3,4}
lengths: List of Edgelengths [12,13,14,23,24,34]; one or more of which is a symbol (variable).
Returns:
D_ij, as defined in WD's paper
"""
assert i!=j and i in [1,2,3,4] and j in [1,2,3,4]
k,l=doublecomplement(i, j)
M=WD_matrix(lengths)
M=M.delete_columns([k-1])
M=M.delete_rows([l-1])
return (-1)**(k+l)*M.det()
def lengths_to_dihedral_exponentials(lengths):
"""
Parameters:
lengths: List of Edgelengths [12,13,14,23,24,34]
"""
angles={}
for i in range(1,5):
for j in range(1,5):
if i<j:
k,l=doublecomplement(i, j)
real_part=D_2(i,j,lengths)/sqrt( D_3(i,j,k, lengths)* D_3(i,j,l, lengths))
imaginary_part=sqrt(1-real_part**2)
angles[(i,j)]=real_part**2+2*real_part*imaginary_part*I-imaginary_part**2
return angles
def lengths_to_dihedral_exponential_single(lengths):
"""
Parameters:
lengths: List of Edgelengths [12,13,14,23,24,34]
"""
angles={}
for i in range(1,5):
for j in range(1,5):
if i<j:
k,l=doublecomplement(i, j)
real_part=D_2(i,j,lengths)/sqrt( D_3(i,j,k, lengths)* D_3(i,j,l, lengths))
imaginary_part=sqrt(1-real_part**2)
angles[(i,j)]=real_part+imaginary_part*I
return angles
def lengths_to_dihedrals(lengths):
"""
Parameters:
lengths: List of Edgelengths [12,13,14,23,24,34]
"""
angles={}
for i in range(1,5):
for j in range(1,5):
if i<j:
k,l=doublecomplement(i, j)
v=D_2(i,j,lengths)/sqrt( D_3(i,j,k, lengths)* D_3(i,j,l, lengths))
angles[(i,j)]=arccos(v,hold=True)
return angles
def dimensions(v):
exponentials=lengths_to_dihedral_exponentials(v)
D=WD_matrix(v).det()
# print('the value of D is', D)
K = QuadraticField(-2*D)
L = K.ring_of_integers()
A=[]
primes=set()
for edge in exponentials:
for p,e in L.fractional_ideal(exponentials[edge]).factor():
primes.add(p)
for p in primes:
p_valuations=[]
for edge in [(1,2), (1,3), (1,4), (2,3), (2,4), (3,4)]:
valuation=0
# print(edge, L.fractional_ideal(exponentials[edge]).factor())
for q,f in L.fractional_ideal(exponentials[edge]).factor():
if q==p:
valuation=f
p_valuations.append(valuation)
A.append(p_valuations)
val_matrix=matrix(A)
return val_matrix.rank()
def check_dehn_invariant(lengths):
"""
Parameters
lengths: List of integer Edge lengths [12,13,14,23,24,34].
Returns: True if Dehn invariant is zero, False otherwise.
"""
D=WD_matrix(lengths).det()
lengths_to_dihedral_exponential_single
temp=[lengths_to_dihedral_exponential_single(lengths)[edges_ordered[i]]**lengths[i] for i in range(6)]
value = product(temp)
if bool(value**12==1):
return True
return False
def kimi_family(t):
assert t>4
return [t+1, t+1, t, 6, t-1, t-1]
def hill_family_1(a,b):
x=3*b**2-a**2
y=6*a*b
return [x,x,y,x,a**2+3*b**2,a**2+3*b**2]