#2540 Infinite recursion in bfzeta with complex arguments

Rupert Swarbrick

As described in the thread archived at
bfzeta dies horribly when given arguments it doesn't expect. For
complex arguments, it enters into an infinite recursion. For a symbol,
eg bfzeta(x, 10), it returns a hunk of code, which is not
particularly helpful either.

The attached patch doesn't change bfzeta's behaviour for real
arguments that it can deal with, but hopefully behaves more sensibly
otherwise, returning a noun form for complex or symbol arguments (and
inf for 1, which also failed before)


  • Raymond Toy
    Raymond Toy

    Patch looks ok, but I would prefer to fix bfzeta to support complex numbers.

    I'm not 100% sure, but I think the algorithm is using an Euler-MacLaurin seris to evaluate the zeta function. I think all that needs to be done is to fix up the code that is determines where to terminate the finite sum and how many terms are used from the Euler-Maclaurin series.

  • Ok. Can we commit this small fix now? It fixes a rather unpleasant bug and never reports anything incorrect.

    Then I agree that bfzeta should be able to work over the whole of C. But a quick search of Google Scholar etc. shows that there has been quite a lot of work on Chebyshev polynomial approximations etc. to zeta. Is the Euler-MacLaurin series The Right Way to do this?

  • Raymond Toy
    Raymond Toy

    I was trying to prod you to fix it. :-) I'm fine with the patch.

    I don't know what the right way is, but since the existing code appears to use Euler-Maclaurin and I think it works (more or less) over the whole plane, it's a good starting point.

  • I spent a little bit of time reading up on the Euler-Maclaurin formula and how one uses it and now understand a bit more about how this algorithm works. I'm going to push the patch that I posted above as a "stop-gap" (since Maxima dying from an infinite recursion is pretty rubbish behaviour). But I intend to sort out the complex version soonish.

    • status: open --> closed
  • I've just pushed some code that uses an algorithm written up by Peter Borwein (in "An Efficient Algorithm for the Zeta Function") to extend bfzeta to the rest of the plane. I think it's reasonably bullet-proof...