Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

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

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

r""" 

John Jones's tables of number fields 

 

In order to use the Jones database, the optional database package 

must be installed using the Sage command !sage -i 

database_jones_numfield 

 

This is a table of number fields with bounded ramification and 

degree `\leq 6`. You can query the database for all number 

fields in Jones's tables with bounded ramification and degree. 

 

EXAMPLES: First load the database:: 

 

sage: J = JonesDatabase() 

sage: J 

John Jones's table of number fields with bounded ramification and degree <= 6 

 

List the degree and discriminant of all fields in the database that 

have ramification at most at 2:: 

 

sage: [(k.degree(), k.disc()) for k in J.unramified_outside([2])] # optional - database_jones_numfield 

[(1, 1), (2, -4), (2, -8), (2, 8), (4, 256), (4, 512), (4, -1024), (4, -2048), (4, 2048), (4, 2048), (4, 2048)] 

 

List the discriminants of the fields of degree exactly 2 unramified 

outside 2:: 

 

sage: [k.disc() for k in J.unramified_outside([2],2)] # optional - database_jones_numfield 

[-4, -8, 8] 

 

List the discriminants of cubic field in the database ramified 

exactly at 3 and 5:: 

 

sage: [k.disc() for k in J.ramified_at([3,5],3)] # optional - database_jones_numfield 

[-135, -675, -6075, -6075] 

sage: factor(6075) 

3^5 * 5^2 

sage: factor(675) 

3^3 * 5^2 

sage: factor(135) 

3^3 * 5 

 

List all fields in the database ramified at 101:: 

 

sage: J.ramified_at(101) # optional - database_jones_numfield 

[Number Field in a with defining polynomial x^2 - 101, 

Number Field in a with defining polynomial x^4 - x^3 + 13*x^2 - 19*x + 361, 

Number Field in a with defining polynomial x^5 + x^4 - 6*x^3 - x^2 + 18*x + 4, 

Number Field in a with defining polynomial x^5 + 2*x^4 + 7*x^3 + 4*x^2 + 11*x - 6, 

Number Field in a with defining polynomial x^5 - x^4 - 40*x^3 - 93*x^2 - 21*x + 17] 

""" 

 

#***************************************************************************** 

# Sage: System for Algebra and Geometry Experimentation 

# 

# Copyright (C) 2005 William Stein <wstein@gmail.com> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# 

# This code is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 

# General Public License for more details. 

# 

# The full text of the GPL is available at: 

# 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

 

import os 

 

from sage.rings.all import NumberField, RationalField, PolynomialRing 

from sage.misc.misc import powerset 

from sage.env import SAGE_SHARE 

 

from sage.structure.sage_object import load, save 

 

from sage.misc.package import PackageNotFoundError 

 

JONESDATA = os.path.join(SAGE_SHARE, 'jones') 

 

 

def sortkey(K): 

""" 

A completely deterministic sorting key for number fields. 

 

EXAMPLES:: 

 

sage: from sage.databases.jones import sortkey 

sage: sortkey(QuadraticField(-3)) 

(2, 3, False, x^2 + 3) 

""" 

return K.degree(), abs(K.discriminant()), K.discriminant() > 0, K.polynomial() 

 

 

class JonesDatabase: 

def __init__(self): 

self.root = None 

 

def __repr__(self): 

return "John Jones's table of number fields with bounded ramification and degree <= 6" 

 

def _load(self, path, filename): 

print(filename) 

i = 0 

while filename[i].isalpha(): 

i += 1 

j = len(filename) - 1 

while filename[j].isalpha() or filename[j] in [".", "_"]: 

j -= 1 

S = sorted([eval(z) for z in filename[i:j + 1].split("-")]) 

data = open(path + "/" + filename).read() 

data = data.replace("^", "**") 

x = PolynomialRing(RationalField(), 'x').gen() 

v = eval(data) 

s = tuple(S) 

if s in self.root: 

self.root[s] += v 

self.root[s].sort() 

else: 

self.root[s] = v 

 

def _init(self, path): 

""" 

Create the database from scratch from the PARI files on John Jones's 

web page, downloaded (e.g., via wget) to a local directory, which 

is specified as path above. 

 

INPUT: 

 

 

- ``path`` - (default works on William Stein install.) 

path must be the path to Jones's Number_Fields directory 

http://hobbes.la.asu.edu/Number_Fields These files should have 

been downloaded using wget. 

 

 

EXAMPLES: This is how to create the database from scratch, assuming 

that the number fields are in the default directory above: From a 

cold start of Sage:: 

 

sage: J = JonesDatabase() 

sage: J._init() # not tested 

... 

 

This takes about 5 seconds. 

""" 

from sage.misc.misc import sage_makedirs 

n = 0 

x = PolynomialRing(RationalField(), 'x').gen() 

self.root = {} 

self.root[tuple([])] = [x - 1] 

if not os.path.exists(path): 

raise IOError("Path %s does not exist." % path) 

for X in os.listdir(path): 

if X[-4:] == "solo": 

Z = path + "/" + X 

print(X) 

for Y in os.listdir(Z): 

if Y[-3:] == ".gp": 

self._load(Z, Y) 

sage_makedirs(JONESDATA) 

save(self.root, JONESDATA + "/jones.sobj") 

 

def unramified_outside(self, S, d=None, var='a'): 

""" 

Return all fields in the database of degree d unramified 

outside S. If d is omitted, return fields of any degree up to 6. 

The fields are ordered by degree and discriminant. 

 

INPUT: 

 

- ``S`` - list or set of primes, or a single prime 

 

- ``d`` - None (default, in which case all fields of degree <= 6 are returned) 

or a positive integer giving the degree of the number fields returned. 

 

- ``var`` - the name used for the generator of the number fields (default 'a'). 

 

EXAMPLES:: 

 

sage: J = JonesDatabase() # optional - database_jones_numfield 

sage: J.unramified_outside([101,109]) # optional - database_jones_numfield 

[Number Field in a with defining polynomial x - 1, 

Number Field in a with defining polynomial x^2 - 101, 

Number Field in a with defining polynomial x^2 - 109, 

Number Field in a with defining polynomial x^3 - x^2 - 36*x + 4, 

Number Field in a with defining polynomial x^4 - x^3 + 13*x^2 - 19*x + 361, 

Number Field in a with defining polynomial x^4 - x^3 + 14*x^2 + 34*x + 393, 

Number Field in a with defining polynomial x^5 + x^4 - 6*x^3 - x^2 + 18*x + 4, 

Number Field in a with defining polynomial x^5 + 2*x^4 + 7*x^3 + 4*x^2 + 11*x - 6, 

Number Field in a with defining polynomial x^5 - x^4 - 40*x^3 - 93*x^2 - 21*x + 17] 

""" 

try: 

S = list(S) 

except TypeError: 

S = [S] 

Z = [] 

for X in powerset(S): 

Z += self.ramified_at(X, d=d, var=var) 

return sorted(Z, key=sortkey) 

 

def __getitem__(self, S): 

return self.get(S) 

 

def get(self, S, var='a'): 

""" 

Return all fields in the database ramified exactly at 

the primes in S. 

 

INPUT: 

 

- ``S`` - list or set of primes, or a single prime 

 

- ``var`` - the name used for the generator of the number fields (default 'a'). 

 

EXAMPLES:: 

 

sage: J = JonesDatabase() # optional - database_jones_numfield 

sage: J.get(163, var='z') # optional - database_jones_numfield 

[Number Field in z with defining polynomial x^2 + 163, 

Number Field in z with defining polynomial x^3 - x^2 - 54*x + 169, 

Number Field in z with defining polynomial x^4 - x^3 - 7*x^2 + 2*x + 9] 

sage: J.get([3, 4]) # optional - database_jones_numfield 

Traceback (most recent call last): 

... 

ValueError: S must be a list of primes 

""" 

if self.root is None: 

if os.path.exists(JONESDATA + "/jones.sobj"): 

self.root = load(JONESDATA + "/jones.sobj") 

else: 

raise PackageNotFoundError("database_jones_numfield") 

try: 

S = list(S) 

except TypeError: 

S = [S] 

if not all([p.is_prime() for p in S]): 

raise ValueError("S must be a list of primes") 

S.sort() 

s = tuple(S) 

if s not in self.root: 

return [] 

return [NumberField(f, var, check=False) for f in self.root[s]] 

 

def ramified_at(self, S, d=None, var='a'): 

""" 

Return all fields in the database of degree d ramified exactly at 

the primes in S. The fields are ordered by degree and discriminant. 

 

INPUT: 

 

- ``S`` - list or set of primes 

 

- ``d`` - None (default, in which case all fields of degree <= 6 are returned) 

or a positive integer giving the degree of the number fields returned. 

 

- ``var`` - the name used for the generator of the number fields (default 'a'). 

 

EXAMPLES:: 

 

sage: J = JonesDatabase() # optional - database_jones_numfield 

sage: J.ramified_at([101,109]) # optional - database_jones_numfield 

[] 

sage: J.ramified_at([109]) # optional - database_jones_numfield 

[Number Field in a with defining polynomial x^2 - 109, 

Number Field in a with defining polynomial x^3 - x^2 - 36*x + 4, 

Number Field in a with defining polynomial x^4 - x^3 + 14*x^2 + 34*x + 393] 

sage: J.ramified_at(101) # optional - database_jones_numfield 

[Number Field in a with defining polynomial x^2 - 101, 

Number Field in a with defining polynomial x^4 - x^3 + 13*x^2 - 19*x + 361, 

Number Field in a with defining polynomial x^5 + x^4 - 6*x^3 - x^2 + 18*x + 4, 

Number Field in a with defining polynomial x^5 + 2*x^4 + 7*x^3 + 4*x^2 + 11*x - 6, 

Number Field in a with defining polynomial x^5 - x^4 - 40*x^3 - 93*x^2 - 21*x + 17] 

sage: J.ramified_at((2, 5, 29), 3, 'c') # optional - database_jones_numfield 

[Number Field in c with defining polynomial x^3 - x^2 - 8*x - 28, 

Number Field in c with defining polynomial x^3 - x^2 + 10*x + 102, 

Number Field in c with defining polynomial x^3 - x^2 - 48*x - 188, 

Number Field in c with defining polynomial x^3 - x^2 + 97*x - 333] 

""" 

Z = self.get(S, var=var) 

if d is not None: 

Z = [k for k in Z if k.degree() == d] 

return sorted(Z, key=sortkey)