# hurwitz_zeta bug?

The doc (reference/sage/combinat/combinat.html) says:

"hurwitz_zeta(s,x,N) returns the value of the zeta(s,x) to N decimals, where s and x are real."

With Sage 5.0 I get:

hurwitz_zeta(3,1,32) = 1.202056903159594285...
hurwitz_zeta(-3,1,32) -> SyntaxError: unexpected EOF while parsing

edit retag close merge delete

Sort by ยป oldest newest most voted

This is a bug, and it's due to an unanticipated behaviour when Maxima returns unevaluated:

maxima.eval('load ("bffac")')
s = maxima.eval("bfhzeta (%s,%s,%s)"%(s,x,N))

#Handle the case where there is a 'b' in the string
#'1.2000b0' means 1.2000 and
#'1.2000b1' means 12.000
i = s.rfind('b')
if i == -1:
return sage_eval(s)
else:
if s[i+1:] == '0':
return sage_eval(s[:i])
else:
return sage_eval(s[:i])*10**sage_eval(s[i+1:])

return s  ## returns an odd string


Unfortunately, Maxima doesn't evaluate these terms:

sage: maxima.eval('bfhzeta (%s,%s,%s)' % (-3,1,32))
'bfhzeta(-3,1,32)'


The rfind then picks up the initial "b" at 0, so sage_eval(s[:i]) is sage_eval(''), which throws the SyntaxError.

This could be hacked around to return unevaluated, but the right solution would be to implement hurwitz_zeta along the lines of some of the new special function implementations. This would give a symbolic front and improved backend evaluation. As a workaround in the short term, mpmath can handle this:

sage: import mpmath
sage: mpmath.mp.dps = 50
sage: mpmath.hurwitz(-3, 1)
mpf('0.0083333333333333333333333333333333333333333333333333319')

more

Thank you DSM! It does not solve my problem, though. from mpmath import * mp.dps = 50 def Mat(m) : M = matrix(QQ, m) for n in range(m) : for k in range(m) : M[n,k] = zeta(k - n, k + 1) ### hurwitz_zeta(k - n,k + 1, 32) if M.det() == 0 : return return M.inverse() Mat(3) # TypeError: could not interpret given arguments

( 2012-07-17 11:36:04 -0500 )edit

http://trac.sagemath.org/ticket/15095 implements a symbolic version of hurwitz_zeta.

( 2013-08-29 08:39:32 -0500 )edit

This has been reported as trac ticket 14679, and actually fixed as trac ticket 15095.

more