3
$\begingroup$

The following is a plot comparing Exp[Derivative[1,0][Zeta][0,x]+1/2Log[2 Pi]] and Gamma[x]:

alt text

In theory the blue and the red graphs should be identical, giving the Gamma function. But in reality we have the blue plot (the plot of Exp[Derivative[1,0][Zeta][0,x]+1/2Log[2 Pi]]) representing the absolute value of the Gamma function instead.

The question is: is this my fault (bad formula); and if so, how then do I correct it? Or it is a Mathematica bug?

  • 0
    Could you try `Plot3D[With[{z = x + I y}, Abs[Sqrt[2 Pi] Exp[npsi[-1, z]] - Gamma[z]]], {x, -3, 3}, {y, -3, 3}, (*whatever options are needed for a pretty plot*)]` and report back?2010-12-05
  • 0
    Of course. Here is it: http://static.itmages.ru/i/10/1205/h_1291522715_d51c810f6a.png2010-12-05
  • 0
    Could you try cranking up `PlotPoints` just to be sure? I suspect that any source of the trouble might be in the zeta derivative, as the other components of your function behave as expected in the left half-plane. Where did you acquire this formula? I suspect that the source of the formula should have said something about arguments in the left half-plane.2010-12-05
  • 0
    Here is it with more points: http://static.itmages.ru/i/10/1205/h_1291525713_4f8d970b7a.png I got the formula from this paper: http://www.math.tulane.edu/~vhm/papers_html/genoff.pdf2010-12-05
  • 0
    The problem is indeed with the derivative of Zeta, because other parts become 0 at x=-1. But what can I do with it? Is it an incorrect definition of Zeta function in Mathematica?2010-12-05
  • 0
    *Mathematica* being a closed-source beastie, it's hard to tell what's going on under the hood, unfortunately... I know they use Euler-Maclaurin and the appropriate reflection formulae for numerically evaluating Hurwitz zeta; for the derivative, however, I am not so sure...2010-12-05
  • 0
    What is the result with other CAS systems?2010-12-05
  • 1
    Anixx: Try replacing `Zeta[]` with `HurwitzZeta[]`, and see if you still have problems...2010-12-14
  • 0
    This seems to work:dzeta[x_] := Derivative[1, 0][Zeta][y, x] Plot[{Exp[dzeta[0, x] + 1/2 Log[2 Pi]] , Gamma[x]}, {x, -3, 3}]2010-12-14
  • 0
    Ignore my previous comment, and just look at my answer below.2010-12-14
  • 0
    @J.M. Great! HurwitzZeta indeed works!2010-12-15
  • 0
    Anixx, I'll write up the details in an answer later, so you can accept it. Briefly, `Zeta[]` and `HurwitzZeta[]` behave differently in the left half-plane. That is why you were observing weird behavior at the left.2010-12-15
  • 0
    Yes. I thought they implemented Hurwitz Zeta as Zeta.2010-12-15

2 Answers 2

3

To expand on the comments I made (and Anixx has confirmed that it works):

The problem, as noted in the Mathematica documentation for Zeta[] and HurwitzZeta[] is that those two functions are defined slightly differently:

$$\mathrm{Zeta}(s,a):=\sum_{j=0}^\infty\frac1{((j+a)^2)^{\frac{s}{2}}}$$

$$\zeta(s,a):=\sum_{j=0}^\infty\frac1{(j+a)^s}$$

Though the two expressions are equivalent for $\Re a > 0$, they behave rather differently in the left half-plane:

N[Zeta[1/3, -1/5], 20]
0.99113858338730120895

N[HurwitzZeta[1/3, -1/5], 20]
0.1361506100489527143 - 1.4808826096823642385 I

and this manifests itself when you use Zeta[] instead of HurwitzZeta[] for your gamma function expression in the left half-plane.

Not knowing how they implemented HurwitzZeta[] internally, however, (it seems to have only been implemented starting with version 7 of Mathematica), I cannot say what, exactly, are the differences in the behavior of those two functions in the left half of the complex plane.

As an aside, a similar issue arises with the Lerch transcendent $\Phi(z,s,a)$, the trivariate generalization of the zeta function and the related polylogarithms; Mathematica from version 7 onwards provides for two different functions, LerchPhi[] and HurwitzLerchPhi[] which also agree for $\Re a > 0$ but behave differently otherwise.

  • 0
    Thank you. It is interesting why they invented non-Hurwitz Zeta. By the way, I've contacted the support and they responded that they created a bugreport following my complain. If I knew about Hurwitz Zeta, I would not contact them.2010-12-15
  • 0
    I'm curious about the need for two different zeta functions myself. If the Wolfram guys reply back @Anixx, could you paste in here what they said?2010-12-15
  • 0
    They did not say anything about Hurwitz Zeta. They asked me to provide source for such formula and after I provided they said they opened a bugreport. They also suggested that Mathematica maybe use a different definition of Zeta function.2010-12-15
  • 0
    They also suggested that the sources which use this formula define Gamma function only for positive reals.2010-12-15
  • 0
    Nah, there's no bug I think... in any event @Anixx, to be sure, try doing a plot in the complex plane, something like `Plot3D[Abs[f[x + I y] - Gamma[x + I y]], {x, ...}, {y, ...}]` where `f` is the expression with `HurwitzZeta[]` .2010-12-15
2

This seems to work:

dzeta[x_] := Derivative[1, 0][Zeta][y, x]

Plot[{Exp[dzeta[0, x] + 1/2 Log[2 Pi]] , Gamma[x]}, {x, -3, 3}]

The derivative of a function returns a function. I think that in your version, maybe Mathematica binds x to specific numerical values during the plot and then tries to take the derivative. The version above computes the derivative once and for all and then does the plot.

EDIT:

Oops, Annix is right. This is not the first time I have been undone by mistaking the graph color for two graphs instead of one. Anyway, I'm sorry for the false starts, but the following code properly displays both functions and the graphs coincide.

Clear[x, y, dzeta]

dzeta[y_, x_] := Derivative[1, 0][HurwitzZeta][y, x]

Plot[{Exp[dzeta[0, x] + 1/2 Log[2 Pi]], Gamma[x]}, {x, -3, 3}]

Changing "Zeta" to "HurwitzZeta" in your original expression also works:

Plot[{Exp[ Derivative[1, 0][HurwitzZeta][0, x] + 1/2 Log[2 Pi]]}, {x, -3, 3}]

  • 1
    Shouldn't it be `dzeta[y_, x_]:=...` ?2010-12-15
  • 0
    Well, you would think so, wouldn't you? But Mathematica doesn't seem to think so, and I really don't know why. If you make the change that you suggest above, it reverts to its old behavior.2010-12-15
  • 0
    Here is a better way to do it: Plot[{Exp[Derivative[1, 0][Zeta][y, x][0, x] + 1/2 Log[2 Pi]] , Gamma[x]}, {x, -3, 3}]2010-12-15
  • 0
    @ castal it only plots Gamma function. Remove the Gamma function, and you'll see no plot.2010-12-15