Ask Your Question

Revision history [back]

Use the timeit function.

Use Regarding the timing issue, the timeit function.

function could be a good choice.

sage: def ECM(prec):
....:     print(f'prec = {prec:3d} --', timeit(f'CF = ComplexField({prec}); hurwitz_zeta(s = CF(2), x = CF(0.5))'))
....:
sage: for i in range(0, 4):
....:     ECM(3000)
....:
prec = 3000 -- 25 loops, best of 3: 9.74 ms per loop
prec = 3000 -- 25 loops, best of 3: 9.8 ms per loop
prec = 3000 -- 25 loops, best of 3: 9.76 ms per loop
prec = 3000 -- 25 loops, best of 3: 9.81 ms per loop

See its documentation:

sage: timeit?

Regarding computing in arbitrary precision, using Arb could be a good choice.

Compare using ComplexField vs ComplexBallField (which uses Arb).

With ComplexField:

sage: CF = ComplexField(20)
sage: hurwitz_zeta(s=CF(2), x=CF(0.5))
4.9348

With ComplexBallField, using the zeta method:

sage: CF = ComplexBallField(20)
sage: CF(2).zeta(a=CF(0.5))
[4.93480 +/- 2.40e-6]

Regarding the timing issue, the timeit function could be a good choice.

sage: def ECM(prec):
....:     t = timeit(f'C = ComplexField({prec}); hurwitz_zeta(C(2), C(0.5))')
....:     print(f'prec = {prec:3d} --', timeit(f'CF = ComplexField({prec}); hurwitz_zeta(s = CF(2), x = CF(0.5))'))
t)
....:
sage: for i in range(0, 4):
....:     ECM(3000)
....:
prec = 3000 -- 25 loops, best of 3: 9.74 ms per loop
prec = 3000 -- 25 loops, best of 3: 9.8 ms per loop
prec = 3000 -- 25 loops, best of 3: 9.76 ms per loop
prec = 3000 -- 25 loops, best of 3: 9.81 ms per loop

See its documentation:

sage: timeit?

Regarding computing in arbitrary precision, using Arb could be a good choice.

Compare using ComplexField vs ComplexBallField (which uses Arb).

With ComplexField:

sage: CF C = ComplexField(20)
sage: hurwitz_zeta(s=CF(2), x=CF(0.5))
hurwitz_zeta(C(2), C(0.5))
4.9348

With ComplexBallField, using the zeta method:

sage: CF C = ComplexBallField(20)
sage: CF(2).zeta(a=CF(0.5))
C(2).zeta(a=C(0.5))
[4.93480 +/- 2.40e-6]