Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 8 additions & 49 deletions src/sage/categories/number_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def _call_(self, x):
class ParentMethods:
def zeta_function(self, prec=53,
max_imaginary_part=0,
max_asymp_coeffs=40, algorithm='pari'):
algorithm='pari'):
r"""
Return the Dedekind zeta function of this number field.

Expand All @@ -138,17 +138,11 @@ def zeta_function(self, prec=53,

- ``max_imaginary_part`` -- real (default: 0)

- ``max_asymp_coeffs`` -- integer (default: 40)

- ``algorithm`` -- (default: ``'pari'``) either ``'gp'`` or
``'pari'``
- ``algorithm`` -- ignored

OUTPUT: the zeta function of this number field

If algorithm is ``'gp'``, this returns an interface to Tim
Dokchitser's gp script for computing with `L`-functions.

If algorithm is ``'pari'``, this returns instead an interface to Pari's
This returns an interface to Pari's
own general implementation of `L`-functions.

EXAMPLES::
Expand All @@ -166,51 +160,16 @@ def zeta_function(self, prec=53,
sage: Z(5) # needs sage.rings.number_field sage.symbolic
1.00199015670185

Using the algorithm "pari"::

sage: K.<a> = NumberField(ZZ['x'].0^2 + ZZ['x'].0 - 1) # needs sage.rings.number_field
sage: Z = K.zeta_function(algorithm='pari') # needs sage.rings.number_field sage.symbolic
sage: Z(-1) # needs sage.rings.number_field sage.symbolic
0.0333333333333333

sage: x = polygen(QQ, 'x')
sage: L.<a, b, c> = NumberField([x^2 - 5, x^2 + 3, x^2 + 1]) # needs sage.rings.number_field
sage: Z = L.zeta_function(algorithm='pari') # needs sage.rings.number_field sage.symbolic
sage: Z(5) # needs sage.rings.number_field sage.symbolic
1.00199015670185

TESTS::

sage: QQ.zeta_function() # needs sage.symbolic
PARI zeta function associated to Rational Field
"""
if algorithm == 'gp':
from sage.lfunctions.dokchitser import Dokchitser
r1, r2 = self.signature()
zero = [0]
one = [1]
Z = Dokchitser(conductor=abs(self.absolute_discriminant()),
gammaV=(r1 + r2) * zero + r2 * one,
weight=1,
eps=1,
poles=[1],
prec=prec)
s = 'nf = nfinit(%s);' % self.absolute_polynomial()
s += 'dzk = dirzetak(nf,cflength());'
Z.init_coeffs('dzk[k]', pari_precode=s,
max_imaginary_part=max_imaginary_part,
max_asymp_coeffs=max_asymp_coeffs)
Z.check_functional_equation()
Z.rename('Dokchitser Zeta function associated to %s' % self)
return Z

if algorithm == 'pari':
from sage.lfunctions.pari import lfun_number_field, LFunction
Z = LFunction(lfun_number_field(self), prec=prec)
Z.rename('PARI zeta function associated to %s' % self)
return Z

raise ValueError('algorithm must be "gp" or "pari"')
from sage.lfunctions.pari import lfun_number_field, LFunction
Z = LFunction(lfun_number_field(self), prec=prec,
max_im=max_imaginary_part)
Z.rename(f'PARI zeta function associated to {self}')
return Z

def _test_absolute_disc(self, **options):
r"""
Expand Down
53 changes: 17 additions & 36 deletions src/sage/lfunctions/dokchitser.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ class Dokchitser(SageObject):
We compute with the `L`-series of a rank `1` curve. ::

sage: E = EllipticCurve('37a')
sage: L = E.lseries().dokchitser(algorithm='gp'); L
Dokchitser L-function associated to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
sage: L = E.lseries().dokchitser(algorithm='pari'); L
PARI L-function associated to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field
sage: L(1)
0.000000000000000
sage: L.derivative(1)
0.305999773834052
sage: L.derivative(1,2)
0.373095594536324
sage: L.num_coeffs()
48
50
sage: L.taylor_series(1,4)
0.000000000000000 + 0.305999773834052*z + 0.186547797268162*z^2 - 0.136791463097188*z^3 + O(z^4)
sage: L.check_functional_equation() # abs tol 1e-19
sage: L.check_functional_equation() # abs tol 1e-17
6.04442711160669e-18

RANK 2 ELLIPTIC CURVE:
Expand All @@ -121,14 +121,13 @@ class Dokchitser(SageObject):
`L`-series of a rank `2` elliptic curve. ::

sage: E = EllipticCurve('389a')
sage: L = E.lseries().dokchitser(algorithm='gp')
sage: L = E.lseries().dokchitser(algorithm='pari')
sage: L.num_coeffs()
156
163
sage: L.derivative(1,E.rank())
1.51863300057685
sage: L.taylor_series(1,4)
-1.27685190980159e-23 + (7.23588070754027e-24)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4) # 32-bit
-2.72911738151096e-23 + (1.54658247036311e-23)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4) # 64-bit
...e-19 + (...e-19)*z + 0.759316500288427*z^2 - 0.430302337583362*z^3 + O(z^4)

NUMBER FIELD:

Expand All @@ -140,7 +139,7 @@ class Dokchitser(SageObject):
sage: L.conductor
400
sage: L.num_coeffs()
264
313
sage: L(2)
1.10398438736918
sage: L.taylor_series(2,3)
Expand Down Expand Up @@ -235,15 +234,6 @@ def gp(self):
"""
Return the gp interpreter that is used to implement this Dokchitser
`L`-function.

EXAMPLES::

sage: E = EllipticCurve('11a')
sage: L = E.lseries().dokchitser(algorithm='gp')
sage: L(2)
0.546048036215014
sage: L.gp()
PARI/GP interpreter
"""
if self.__gp is None:
self._instantiate_gp()
Expand Down Expand Up @@ -354,13 +344,13 @@ def num_coeffs(self, T=1):
EXAMPLES::

sage: E = EllipticCurve('11a')
sage: L = E.lseries().dokchitser(algorithm='gp')
sage: L = E.lseries().dokchitser(algorithm='pari')
sage: L.num_coeffs()
26
27
sage: E = EllipticCurve('5077a')
sage: L = E.lseries().dokchitser(algorithm='gp')
sage: L = E.lseries().dokchitser(algorithm='pari')
sage: L.num_coeffs()
568
591
sage: L = Dokchitser(conductor=1, gammaV=[0], weight=1, eps=1, poles=[1], residues=[-1], init='1')
sage: L.num_coeffs()
4
Expand Down Expand Up @@ -501,20 +491,11 @@ def __call__(self, s, c=None):
EXAMPLES::

sage: E = EllipticCurve('5077a')
sage: L = E.lseries().dokchitser(100, algorithm='gp')
sage: L = E.lseries().dokchitser(100, algorithm='pari')
sage: L(1)
0.00000000000000000000000000000
sage: L(1+I)
-1.3085436607849493358323930438 + 0.81298000036784359634835412129*I
sage: L(1+I, 1.2)
-1.3085436607849493358323930438 + 0.81298000036784359634835412129*I

TESTS::

sage: L(1+I, 0)
Traceback (most recent call last):
...
RuntimeError
"""
self.__check_init()
s = self.__CC(s)
Expand Down Expand Up @@ -558,7 +539,7 @@ def derivative(self, s, k=1):
EXAMPLES::

sage: E = EllipticCurve('389a')
sage: L = E.lseries().dokchitser(algorithm='gp')
sage: L = E.lseries().dokchitser(algorithm='pari')
sage: L.derivative(1,E.rank())
1.51863300057685
"""
Expand Down Expand Up @@ -599,17 +580,17 @@ def taylor_series(self, a=0, k=6, var='z'):
sage: L.taylor_series(2, 3)
1.64493406684823 - 0.937548254315844*z + 0.994640117149451*z^2 + O(z^3)
sage: E = EllipticCurve('37a')
sage: L = E.lseries().dokchitser(algorithm='gp')
sage: L = E.lseries().dokchitser(algorithm='pari')
sage: L.taylor_series(1)
0.000000000000000 + 0.305999773834052*z + 0.186547797268162*z^2 - 0.136791463097188*z^3 + 0.0161066468496401*z^4 + 0.0185955175398802*z^5 + O(z^6)

We compute a Taylor series where each coefficient is to high
precision. ::

sage: E = EllipticCurve('389a')
sage: L = E.lseries().dokchitser(200, algorithm='gp')
sage: L = E.lseries().dokchitser(200, algorithm='pari')
sage: L.taylor_series(1,3)
...e-82 + (...e-82)*z + 0.75931650028842677023019260789472201907809751649492435158581*z^2 + O(z^3)
...e-63 + (...e-63)*z + 0.75931650028842677023019260789472201907809751649492435158581*z^2 + O(z^3)

Check that :issue:`25402` is fixed::

Expand Down
Loading
Loading