Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|cite|improve this question
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? – J. M. Dec 5 '10 at 4:07
Of course. Here is it: – Anixx Dec 5 '10 at 4:18
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. – J. M. Dec 5 '10 at 4:48
Here is it with more points: I got the formula from this paper: – Anixx Dec 5 '10 at 5:08
Anixx: Try replacing Zeta[] with HurwitzZeta[], and see if you still have problems... – J. M. Dec 14 '10 at 17:00
up vote 3 down vote accepted

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:



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]

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.

share|cite|improve this answer
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. – Anixx Dec 15 '10 at 15:25
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? – J. M. Dec 15 '10 at 16:23
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. – Anixx Dec 15 '10 at 16:45
They also suggested that the sources which use this formula define Gamma function only for positive reals. – Anixx Dec 15 '10 at 16:46
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[] . – J. M. Dec 15 '10 at 16:52

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.


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}]

share|cite|improve this answer
Shouldn't it be dzeta[y_, x_]:=... ? – J. M. Dec 15 '10 at 1:29
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. – castal Dec 15 '10 at 4:07
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}] – castal Dec 15 '10 at 4:08
@ castal it only plots Gamma function. Remove the Gamma function, and you'll see no plot. – Anixx Dec 15 '10 at 5:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.