First time here? Check out the FAQ!

Ask Your Question
0

hurwitz_zeta bug?

asked 12 years ago

petropolis gravatar image

updated 2 years ago

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
Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 12 years ago

DSM gravatar image

updated 12 years ago

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')
Preview: (hide)
link

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 ( 12 years ago )

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

Eviatar Bach gravatar imageEviatar Bach ( 11 years ago )
0

answered 11 years ago

tmonteil gravatar image

updated 8 years ago

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

Preview: (hide)
link

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: 12 years ago

Seen: 1,008 times

Last updated: Mar 10 '17