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

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

r""" 

Rubinstein's `L`-function Calculator 

 

This interface provides complete 

access to Rubinstein's lcalc calculator with extra PARI 

functionality compiled in 

and is a standard part of Sage. 

 

.. note:: 

 

Each call to ``lcalc`` runs a complete 

``lcalc`` process. On a typical Linux system, this 

entails about 0.3 seconds overhead. 

 

AUTHORS: 

 

- Michael Rubinstein (2005): released under GPL the C++ program lcalc 

 

- William Stein (2006-03-05): wrote Sage interface to lcalc 

""" 

 

######################################################################## 

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

# 

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

# 

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

######################################################################## 

from __future__ import absolute_import, print_function 

 

import os 

 

from sage.structure.sage_object import SageObject 

from sage.misc.all import pager 

import sage.rings.all 

import sage.schemes.elliptic_curves.ell_generic 

 

prec = 32 

 

class LCalc(SageObject): 

r""" 

Rubinstein's `L`-functions Calculator 

 

Type ``lcalc.[tab]`` for a list of useful commands that 

are implemented using the command line interface, but return 

objects that make sense in Sage. For each command the possible 

inputs for the L-function are: 

 

 

- ``"`` - (default) the Riemann zeta function 

 

- ``'tau'`` - the L function of the Ramanujan delta 

function 

 

- elliptic curve E - where E is an elliptic curve over 

`\mathbb{Q}`; defines `L(E,s)` 

 

 

You can also use the complete command-line interface of 

Rubinstein's `L`-functions calculations program via this 

class. Type ``lcalc.help()`` for a list of commands and 

how to call them. 

""" 

def _repr_(self): 

return "Rubinsteins L-function Calculator" 

 

def __call__(self, args): 

cmd = 'lcalc %s'%args 

return os.popen(cmd).read().strip() 

 

def _compute_L(self, L): 

if isinstance(L, str): 

if L == 'tau': 

return '--tau' 

return L 

import sage.schemes.all 

if sage.schemes.elliptic_curves.ell_generic.is_EllipticCurve(L): 

if L.base_ring() == sage.rings.all.RationalField(): 

L = L.minimal_model() 

return '-e --a1 %s --a2 %s --a3 %s --a4 %s --a6 %s'%tuple(L.a_invariants()) 

raise TypeError("$L$-function of %s not known"%L) 

 

def help(self): 

try: 

h = self.__help 

except AttributeError: 

h = "-"*70 + '\n' 

h += " Call lcalc with one argument, e.g., \n" 

h += " sage: lcalc('--tau -z 1000')\n" 

h += " is translated into the command line\n" 

h += " $ lcalc --tau -z 1000\n" 

h += "-"*70 + '\n' 

h += '\n' + self('--help') 

self.__help = h 

pager()(h) 

 

def zeros(self, n, L=''): 

""" 

Return the imaginary parts of the first `n` nontrivial 

zeros of the `L`-function in the upper half plane, as 

32-bit reals. 

 

INPUT: 

 

 

- ``n`` - integer 

 

- ``L`` - defines `L`-function (default: 

Riemann zeta function) 

 

 

This function also checks the Riemann Hypothesis and makes sure no 

zeros are missed. This means it looks for several dozen zeros to 

make sure none have been missed before outputting any zeros at all, 

so takes longer than 

``self.zeros_of_zeta_in_interval(...)``. 

 

EXAMPLES:: 

 

sage: lcalc.zeros(4) # long time 

[14.1347251, 21.0220396, 25.0108576, 30.4248761] 

sage: lcalc.zeros(5, L='--tau') # long time 

[9.22237940, 13.9075499, 17.4427770, 19.6565131, 22.3361036] 

sage: lcalc.zeros(3, EllipticCurve('37a')) # long time 

[0.000000000, 5.00317001, 6.87039122] 

""" 

L = self._compute_L(L) 

RR = sage.rings.all.RealField(prec) 

X = self('-z %s %s'%(int(n), L)) 

return [RR(z) for z in X.split()] 

 

def zeros_in_interval(self, x, y, stepsize, L=''): 

r""" 

Return the imaginary parts of (most of) the nontrivial zeros of the 

`L`-function on the line `\Re(s)=1/2` with positive 

imaginary part between `x` and `y`, along with a 

technical quantity for each. 

 

INPUT: 

 

 

- ``x, y, stepsize`` - positive floating point 

numbers 

 

- ``L`` - defines `L`-function (default: 

Riemann zeta function) 

 

 

OUTPUT: list of pairs (zero, S(T)). 

 

Rubinstein writes: The first column outputs the imaginary part of 

the zero, the second column a quantity related to `S(T)` 

(it increases roughly by 2 whenever a sign change, i.e. pair of 

zeros, is missed). Higher up the critical strip you should use a 

smaller stepsize so as not to miss zeros. 

 

EXAMPLES:: 

 

sage: lcalc.zeros_in_interval(10, 30, 0.1) 

[(14.1347251, 0.184672916), (21.0220396, -0.0677893290), (25.0108576, -0.0555872781)] 

""" 

L = self._compute_L(L) 

RR = sage.rings.all.RealField(prec) 

X = self('--zeros-interval -x %s -y %s --stepsize=%s %s'%( 

float(x), float(y), float(stepsize), L)) 

return [tuple([RR(z) for z in t.split()]) for t in X.split('\n')] 

 

def value(self, s, L=''): 

r""" 

Return `L(s)` for `s` a complex number. 

 

INPUT: 

 

 

- ``s`` - complex number 

 

- ``L`` - defines `L`-function (default: 

Riemann zeta function) 

 

 

EXAMPLES:: 

 

sage: I = CC.0 

sage: lcalc.value(0.5 + 100*I) 

2.69261989 - 0.0203860296*I 

 

Note, Sage can also compute zeta at complex numbers (using the PARI 

C library):: 

 

sage: (0.5 + 100*I).zeta() 

2.69261988568132 - 0.0203860296025982*I 

""" 

L = self._compute_L(L) 

CC = sage.rings.all.ComplexField(prec) 

s = CC(s) 

x, y = self('-v -x %s -y %s %s'%(s.real(), s.imag(), L)).split() 

return CC((float(x), float(y))) 

 

def values_along_line(self, s0, s1, number_samples, L=''): 

r""" 

Return values of `L(s)` at ``number_samples`` 

equally-spaced sample points along the line from `s_0` to 

`s_1` in the complex plane. 

 

INPUT: 

 

 

- ``s0, s1`` - complex numbers 

 

- ``number_samples`` - integer 

 

- ``L`` - defines `L`-function (default: 

Riemann zeta function) 

 

 

OUTPUT: 

 

 

- ``list`` - list of pairs (s, zeta(s)), where the s 

are equally spaced sampled points on the line from s0 to s1. 

 

 

EXAMPLES:: 

 

sage: I = CC.0 

sage: lcalc.values_along_line(0.5, 0.5+20*I, 5) 

[(0.500000000, -1.46035451), (0.500000000 + 4.00000000*I, 0.606783764 + 0.0911121400*I), (0.500000000 + 8.00000000*I, 1.24161511 + 0.360047588*I), (0.500000000 + 12.0000000*I, 1.01593665 - 0.745112472*I), (0.500000000 + 16.0000000*I, 0.938545408 + 1.21658782*I)] 

 

Sometimes warnings are printed (by lcalc) when this command is 

run:: 

 

sage: E = EllipticCurve('389a') 

sage: E.lseries().values_along_line(0.5, 3, 5) 

[(0.000000000, 0.209951303), 

(0.500000000, -...e-16), 

(1.00000000, 0.133768433), 

(1.50000000, 0.360092864), 

(2.00000000, 0.552975867)] 

""" 

L = self._compute_L(L) 

CC = sage.rings.all.ComplexField(prec) 

s0 = CC(s0) 

s1 = CC(s1) 

v = self('--value-line-segment -x %s -y %s -X %s -Y %s --number-samples %s %s'%( 

(s0.real(), s0.imag(), s1.real(), s1.imag(), int(number_samples), L))) 

w = [] 

for a in v.split('\n'): 

try: 

x0,y0,x1,y1 = a.split() 

w.append((CC(x0,y0), CC(x1,y1))) 

except ValueError: 

print('lcalc: {}'.format(a)) 

return w 

 

def twist_values(self, s, dmin, dmax, L=''): 

r""" 

Return values of `L(s, \chi_k)` for each quadratic 

character `\chi_k` whose discriminant `d` satisfies 

`d_{\min} \leq d \leq d_{\max}`. 

 

INPUT: 

 

 

- ``s`` - complex numbers 

 

- ``dmin`` - integer 

 

- ``dmax`` - integer 

 

- ``L`` - defines `L`-function (default: 

Riemann zeta function) 

 

 

OUTPUT: 

 

 

- ``list`` - list of pairs (d, L(s,chi_d)) 

 

 

EXAMPLES:: 

 

sage: lcalc.twist_values(0.5, -10, 10) 

[(-8, 1.10042141), (-7, 1.14658567), (-4, 0.667691457), (-3, 0.480867558), (5, 0.231750947), (8, 0.373691713)] 

""" 

L = self._compute_L(L) 

CC = sage.rings.all.ComplexField(prec) 

Z = sage.rings.all.Integer 

s = CC(s) 

typ = '--twist-quadratic' 

dmin = int(dmin) 

dmax = int(dmax) 

v = self('-v -x %s -y %s %s --start %s --finish %s %s'%( 

(s.real(), s.imag(), typ, dmin, dmax, L))) 

w = [] 

if len(v) == 0: 

return w 

if len(v) == 0: 

return w 

for a in v.split('\n'): 

d,x,y = a.split() 

w.append((Z(d), CC(x,y))) 

return w 

 

def twist_zeros(self, n, dmin, dmax, L=''): 

r""" 

Return first `n` real parts of nontrivial zeros for each 

quadratic character `\chi_k` whose discriminant `d` satisfies 

`d_{\min} \leq d \leq d_{\max}`. 

 

INPUT: 

 

 

- ``n`` - integer 

 

- ``dmin`` - integer 

 

- ``dmax`` - integer 

 

- ``L`` - defines `L`-function (default: 

Riemann zeta function) 

 

 

OUTPUT: 

 

 

- ``dict`` - keys are the discriminants `d`, 

and values are list of corresponding zeros. 

 

 

EXAMPLES:: 

 

sage: lcalc.twist_zeros(3, -3, 6) 

{-3: [8.03973716, 11.2492062, 15.7046192], 5: [6.64845335, 9.83144443, 11.9588456]} 

""" 

L = self._compute_L(L) 

RR = sage.rings.all.RealField(prec) 

Z = sage.rings.all.Integer 

typ = '--twist-quadratic' 

n = int(n) 

v = self('-z %s %s --start %s --finish %s %s'%( 

(n, typ, dmin, dmax, L))) 

w = {} 

if len(v) == 0: 

return w 

for a in v.split('\n'): 

d, x = a.split() 

x = RR(x) 

d = Z(d) 

if d in w: 

w[d].append(x) 

else: 

w[d] = [x] 

return w 

 

def analytic_rank(self, L=''): 

r""" 

Return the analytic rank of the `L`-function at the central 

critical point. 

 

INPUT: 

 

 

- ``L`` - defines `L`-function (default: 

Riemann zeta function) 

 

 

OUTPUT: integer 

 

.. note:: 

 

Of course this is not provably correct in general, since it 

is an open problem to compute analytic ranks provably 

correctly in general. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('37a') 

sage: lcalc.analytic_rank(E) 

1 

""" 

L = self._compute_L(L) 

Z = sage.rings.all.Integer 

s = self('--rank-compute %s'%L) 

i = s.find('equals') 

return Z(s[i+6:]) 

 

 

 

# An instance 

lcalc = LCalc()