Ask Your Question
0

hurwitz_zeta bug?

asked 2012-07-17 15:57:50 +0100

petropolis gravatar image

updated 2023-01-10 00:01:10 +0100

tmonteil gravatar image

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 flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-07-17 17:28:48 +0100

DSM gravatar image

updated 2012-07-17 17:29:09 +0100

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')
edit flag offensive delete link more

Comments

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

petropolis gravatar imagepetropolis ( 2012-07-17 18:36:04 +0100 )edit

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

Eviatar Bach gravatar imageEviatar Bach ( 2013-08-29 15:39:32 +0100 )edit
0

answered 2013-06-03 12:34:40 +0100

tmonteil gravatar image

updated 2017-03-10 10:16:39 +0100

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

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-07-17 15:57:50 +0100

Seen: 839 times

Last updated: Mar 10 '17