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

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

r""" 

The Stein-Watkins table of elliptic curves 

 

Sage gives access to the Stein-Watkins table of elliptic curves, via an 

optional package that you must install. This is a huge database of elliptic 

curves. You can install the database (a 2.6GB package) with the command 

 

:: 

 

sage -i database_stein_watkins 

 

You can also automatically download a small version, which takes much less 

time, using the command 

 

:: 

 

sage -i database_stein_watkins_mini 

 

This database covers a wide range of conductors, but unlike the 

:mod:`Cremona database <sage.databases.cremona>`, this database need not list 

all curves of a given conductor. It lists the curves whose coefficients are not 

"too large" (see [SW2002]_). 

 

 

- The command ``SteinWatkinsAllData(n)`` returns an iterator over the curves 

in the `n`-th Stein-Watkins table, which contains elliptic curves of 

conductor between `n10^5` and `(n+1)10^5`. Here `n` can be between 0 and 

999, inclusive. 

 

- The command ``SteinWatkinsPrimeData(n)`` returns an iterator over the curves 

in the `n^{th}` Stein-Watkins prime table, which contains prime conductor 

elliptic curves of conductor between `n10^6` and `(n+1)10^6`. Here `n` 

varies between 0 and 99, inclusive. 

 

 

EXAMPLES: We obtain the first table of elliptic curves. 

 

:: 

 

sage: d = SteinWatkinsAllData(0) 

sage: d 

Stein-Watkins Database a.0 Iterator 

 

We type ``next(d)`` to get each isogeny class of 

curves from ``d``:: 

 

sage: C = next(d) # optional - database_stein_watkins 

sage: C # optional - database_stein_watkins 

Stein-Watkins isogeny class of conductor 11 

sage: next(d) # optional - database_stein_watkins 

Stein-Watkins isogeny class of conductor 14 

sage: next(d) # optional - database_stein_watkins 

Stein-Watkins isogeny class of conductor 15 

 

An isogeny class has a number of attributes that give data about 

the isogeny class, such as the rank, equations of curves, 

conductor, leading coefficient of `L`-function, etc. 

 

:: 

 

sage: C.data # optional - database_stein_watkins 

['11', '[11]', '0', '0.253842', '25', '+*1'] 

sage: C.curves # optional - database_stein_watkins 

[[[0, -1, 1, 0, 0], '(1)', '1', '5'], 

[[0, -1, 1, -10, -20], '(5)', '1', '5'], 

[[0, -1, 1, -7820, -263580], '(1)', '1', '1']] 

sage: C.conductor # optional - database_stein_watkins 

11 

sage: C.leading_coefficient # optional - database_stein_watkins 

'0.253842' 

sage: C.modular_degree # optional - database_stein_watkins 

'+*1' 

sage: C.rank # optional - database_stein_watkins 

0 

sage: C.isogeny_number # optional - database_stein_watkins 

'25' 

 

If we were to continue typing ``next(d)`` we would 

iterate over all curves in the Stein-Watkins database up to 

conductor `10^5`. We could also type ``for C in d: 

...`` 

 

To access the data file starting at `10^5` do the 

following:: 

 

sage: d = SteinWatkinsAllData(1) 

sage: C = next(d) # optional - database_stein_watkins 

sage: C # optional - database_stein_watkins 

Stein-Watkins isogeny class of conductor 100002 

sage: C.curves # optional - database_stein_watkins 

[[[1, 1, 0, 112, 0], '(8,1,2,1)', 'X', '2'], 

[[1, 1, 0, -448, -560], '[4,2,1,2]', 'X', '2']] 

 

Next we access the prime-conductor data:: 

 

sage: d = SteinWatkinsPrimeData(0) 

sage: C = next(d) # optional - database_stein_watkins 

sage: C # optional - database_stein_watkins 

Stein-Watkins isogeny class of conductor 11 

 

Each call ``next(d)`` gives another elliptic curve of 

prime conductor:: 

 

sage: C = next(d) # optional - database_stein_watkins 

sage: C # optional - database_stein_watkins 

Stein-Watkins isogeny class of conductor 17 

sage: C.curves # optional - database_stein_watkins 

[[[1, -1, 1, -1, 0], '[1]', '1', '4'], 

[[1, -1, 1, -6, -4], '[2]', '1', '2x'], 

[[1, -1, 1, -1, -14], '(4)', '1', '4'], 

[[1, -1, 1, -91, -310], '[1]', '1', '2']] 

sage: C = next(d) # optional - database_stein_watkins 

sage: C # optional - database_stein_watkins 

Stein-Watkins isogeny class of conductor 19 

 

REFERENCE: 

 

- [SW2002]_ 

""" 

 

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

# 

# Sage: 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/ 

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

from __future__ import print_function 

from six.moves import range 

 

import bz2 

import os 

 

from sage.env import SAGE_SHARE 

 

class SteinWatkinsIsogenyClass: 

def __init__(self, conductor): 

self.conductor = conductor 

 

def __repr__(self): 

return "Stein-Watkins isogeny class of conductor %s"%self.conductor 

 

def __len__(self): 

try: 

return len(self.curves) 

except AttributeError: 

return 0 

 

def __iter__(self): 

try: 

for E in self.curves: 

yield E 

except AttributeError: 

return 

 

 

def _lines(s): 

while True: 

i = s.find("\n") 

if i == -1: 

yield "" 

return 

line = s[:i] 

s = s[i+1:] 

yield line 

 

 

class SteinWatkinsAllData: 

""" 

Class for iterating through one of the Stein-Watkins database files 

for all conductors. 

""" 

def __init__(self, num): 

num = int(num) 

self.num = num 

if num < 0: 

raise RuntimeError("num (=%s) must be a nonnegative integer"%num) 

name = str(num) 

name = '0'*(3-len(name)) + name 

self._file = os.path.join(SAGE_SHARE, 'stein_watkins', 'a.%s.bz2'%name) 

self._iter = iter(self) 

 

def __repr__(self): 

""" 

EXAMPLES:: 

 

sage: d = SteinWatkinsAllData(1) 

sage: d 

Stein-Watkins Database a.1 Iterator 

""" 

return "Stein-Watkins Database a.%s Iterator"%self.num 

 

def __iter__(self): 

""" 

EXAMPLES:: 

 

sage: d = SteinWatkinsAllData(0) 

sage: d = d[10:20] # optional - database_stein_watkins; long time 

sage: for C in d: # optional - database_stein_watkins; long time 

....: print(C) 

Stein-Watkins isogeny class of conductor 11 

Stein-Watkins isogeny class of conductor 14 

Stein-Watkins isogeny class of conductor 15 

Stein-Watkins isogeny class of conductor 17 

Stein-Watkins isogeny class of conductor 19 

Stein-Watkins isogeny class of conductor 20 

""" 

try: 

file = bz2.BZ2File(self._file, 'r') 

except IOError: 

raise IOError("The Stein-Watkins data file %s must be installed."%self._file) 

C = None 

for L in file: 

if len(L) == 0: 

continue 

if L[0] != '[': # new curve 

if C is not None: 

yield C 

x = L.split() 

N = int(x[0]) 

C = SteinWatkinsIsogenyClass(N) 

C.rank = int(x[2]) 

C.leading_coefficient = x[3] 

C.isogeny_number = x[4] 

C.modular_degree = x[5] 

C.curves = [] 

C.data = x 

else: 

w = L.split() 

C.curves.append([eval(w[0]), w[1], w[2], w[3]]) 

yield C 

 

def __next__(self): 

return next(self._iter) 

 

next = __next__ 

 

def __getitem__(self, N): 

""" 

Return the curves of conductor N in this table. (Very slow!) 

Return all data about curves between the given levels in this 

database file. 

 

EXAMPLES:: 

 

sage: d = SteinWatkinsAllData(0) 

sage: d[15:18] # optional - database_stein_watkins; long time 

[Stein-Watkins isogeny class of conductor 15, Stein-Watkins isogeny 

class of conductor 17] 

""" 

X = [] 

if isinstance(N, slice): 

min_level, max_level, step = N.indices(len(list(self))) 

for C in self: 

M = C.conductor 

if M >= min_level and M <= max_level: 

X.append(C) 

elif M > max_level: 

return X 

else: 

for C in self: 

M = C.conductor 

if M == N: 

X.append(C) 

elif M > N: 

return X 

return X 

 

def iter_levels(self): 

""" 

Iterate through the curve classes, but grouped into lists by 

level. 

 

EXAMPLES:: 

 

sage: d = SteinWatkinsAllData(1) 

sage: E = d.iter_levels() 

sage: next(E) # optional - database_stein_watkins 

[Stein-Watkins isogeny class of conductor 100002] 

sage: next(E) # optional - database_stein_watkins 

[Stein-Watkins isogeny class of conductor 100005, 

Stein-Watkins isogeny class of conductor 100005] 

sage: next(E) # optional - database_stein_watkins 

[Stein-Watkins isogeny class of conductor 100007] 

""" 

it = iter(self) 

C = [] 

N = 0 

while True: 

try: 

E = next(it) 

except StopIteration: 

if C != []: 

yield C 

return 

if E.conductor != N: 

if C != []: 

yield C 

C = [E] 

N = E.conductor 

else: 

C.append(E) 

yield C 

 

 

class SteinWatkinsPrimeData(SteinWatkinsAllData): 

def __init__(self, num): 

num = int(num) 

self.num = num 

if num < 0: 

raise RuntimeError("num (=%s) must be a nonnegative integer"%num) 

name = str(num) 

name = '0'*(2-len(name)) + name 

self._file = os.path.join(SAGE_SHARE,'stein_watkins', 'p.%s.bz2'%name) 

self._iter = iter(self) 

 

def __repr__(self): 

""" 

EXAMPLES:: 

 

sage: d = SteinWatkinsPrimeData(1) 

sage: d 

Stein-Watkins Prime Conductor Database p.1 Iterator 

""" 

return "Stein-Watkins Prime Conductor Database p.%s Iterator"%self.num 

 

 

def ecdb_num_curves(max_level=200000): 

r""" 

Return a list whose `N`-th entry, for ``0 <= N <= max_level``, is the 

number of elliptic curves of conductor `N` in the database. 

 

EXAMPLES:: 

 

sage: sage.databases.stein_watkins.ecdb_num_curves(100) # optional - database_stein_watkins 

[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 6, 8, 0, 4, 0, 3, 4, 6, 0, 0, 

6, 0, 5, 4, 0, 0, 8, 0, 4, 4, 4, 3, 4, 4, 5, 4, 4, 0, 6, 1, 2, 8, 2, 0, 

6, 4, 8, 2, 2, 1, 6, 4, 6, 7, 3, 0, 0, 1, 4, 6, 4, 2, 12, 1, 0, 2, 4, 0, 

6, 2, 0, 12, 1, 6, 4, 1, 8, 0, 2, 1, 6, 2, 0, 0, 1, 3, 16, 4, 3, 0, 2, 

0, 8, 0, 6, 11, 4] 

""" 

i = 0 

N = 1 

d = SteinWatkinsAllData(i) 

v = [int(0) for _ in range(max_level + 1)] 

while True: 

try: 

C = next(d) 

except StopIteration: 

i += 1 

d = SteinWatkinsAllData(i) 

continue 

N = C.conductor 

if N > max_level: 

break 

v[N] += len(C.curves) 

return v