I want to write a program that calculates the number of zeros (It is not necessary to identify them, just the number of them) between 0 and x for the Riemann Zeta function, being x the imaginary part of z: 1/2 + ix

Is there an algorithm out there for doing what I need?

I modelled the Riemann-siegel function because I saw that I need it for doing what I want, but I don't know how to go on.

Sorry for my poor english :/

  • 6
    $\begingroup$ The Riemann zeta is defined on the complex plane, so looking for the "number of zeros between $0$ and $x$" doesn't make a whole lot of sense. I think you have a lot of reading to do before you try this. $\endgroup$ – Gyu Eun Lee Jul 12 '13 at 22:57
  • $\begingroup$ I do not think there is a known algorithm for that, but I wish you good luck! $\endgroup$ – AD. Jul 12 '13 at 23:01
  • 1
    $\begingroup$ The zeros of $\zeta(s)$ are the negative even integers and the nontrivial zeros that lie in the so-called critical strip $0<{\rm Re}(s)<1$ (it is conjectured that all the nontrivial zeros in fact lie on the critical line ${\rm Re}(s)=1/2$). There are algorithms that calculate the number of zeros in the strip with imaginary part less than $N$ (and there is current research in the asymptotics and statistics of this counting function in analytic number theory). It is also possible to verify computationally that known zeros have real part exactly (not just approximately) $0.5$. $\endgroup$ – anon Jul 12 '13 at 23:08
  • $\begingroup$ If you are really asking about the real interval $(0,x)$, then this suggests you're not at all familiar with complex analysis and the Riemann zeta function, which begs the question of why you want an algorithm for this purpose. As the content of my previous comment establishes, the answer is "for any $x>0$ there are precisely no zeros of $\zeta(s)$ at all in the interval $(0,x)$." Furthermore if one is unfamiliar with analytic continuation, it won't make sense how $\zeta(s)$ is even defined for $0\le s\le 1$, since the $p$-series doesn't converge there. $\endgroup$ – anon Jul 12 '13 at 23:12
  • $\begingroup$ thanks for the help. I changed the question...i hope it's more understandable now! $\endgroup$ – Perroloco Jul 13 '13 at 1:38

You may appreciate the following '$\zeta$ zeros counting function' if $t$ is the imaginary part : $$f(t) = \frac{1}{\pi} \Im\left(\ln(\Gamma\left(\frac 14 + \frac{i\,t}2\right)\right) - \frac{t}{2\pi}\ln(\pi) + \frac{1}{\pi} \Im\left(\ln\left(\zeta\left(\frac 12 + i\,t\right)\right)\right) + 1$$ Explication : if we multiply this by $\pi$ we note that the first imaginary term combined to the next term returns the actual argument of $\zeta$ (this is the well known Riemann–Siegel theta function) that grows with high regularity while the imaginary term at the right gives the argument of $\zeta$ modulo $2\pi$ which will change sign for every multiple of $\pi$ (that is at every zero of $\zeta$ !).

More about the way this formula was obtained here.

Illustration using the pari/gp code at the end (zoom possible) :

zeros counting function

The first step is between $14.1$ and $14.2$, the second between $21$ and $21.1$ and so on so that we are really counting the zeros of $\zeta$...

The picture is not always so nice and, from time to time (starting after $t=415$ I think), there will be a non-propagating error of $\,\pm 2\,$ when $\,\displaystyle\frac 1{\pi}\rm{Arg}\;\zeta(1/2+it)\;$ crosses the upper bound $+1$ or lower bound $-1$ (so that this appears rather when two consecutive zeros are distant i.e. for large loops as displayed in the other answer).

This formula was in this MO thread with further references to Guinand's article : 'A summation formula in the theory of prime numbers'.

pari/gp code used for the picture :

  • $\begingroup$ math.stackexchange.com/questions/1490908/… $\endgroup$ – Mats Granvik Nov 6 '15 at 13:31
  • $\begingroup$ Raymond, Does your Riemann zeta zero counting plot work also in the interval from t=278 to t=285 ? $\endgroup$ – Mats Granvik Nov 6 '15 at 14:30
  • $\begingroup$ What I mean is this: math.stackexchange.com/questions/1516149/… $\endgroup$ – Mats Granvik Nov 6 '15 at 15:36
  • $\begingroup$ The zero counting formula as written is not perfect and I observe the same jump of $2$ than in your first link. As indicated by Henning Makholm in your recent thread (or in my answer here!) your software uses the principal value to compute the argument of $\zeta$ with the problem that it may shortly go out of $\,(-\pi,\pi]\,$ like for \begin{align}\arg \zeta(1/2+282.45 i)&\approx -3.1326099\\\arg \zeta(1/2+282.46 i)&\approx +3.1315472\end{align} (jump of $2\pi$). If you subtracted $2\pi$ to the values near $+\pi$ you would get instead $\endgroup$ – Raymond Manzoni Nov 6 '15 at 22:46
  • $\begingroup$ $$\arg \zeta(1/2+282.46 i)\approx -3.1516381$$ and the steps would appear perfect with the usual jump of $\pi$ for the next zero : $$\arg \zeta(1/2+282.46511477 i)\approx -0.019777908$$ The point is that the orbit near this zero makes a loop at the left and with the imaginary part shortly positive before crossing the origin (note that the argument is a small negative number) ; this happens from time to time. As indicated this 'graphical error' doesn't propagate for reasons that may become clear from this thread. $\endgroup$ – Raymond Manzoni Nov 6 '15 at 22:47

Check out Andrew Odlyzko's work.His main page is here:


Here is a table of zeros:


Check out this paper for algorithms:


And for large zeros, this one:



Assuming you mean the number n of roots $\rho$ whose imaginary parts lie between 0 and T, Riemann conjectured and von Mangoldt verified that the number is

$$n \approx\frac{T}{2\pi}\log\frac{T}{2\pi} -\frac{T}{2\pi} $$ with relative error of $O(\log T).$

There are no doubt better estimates but this is a rule-of-thumb.


In the spirit of Raymond Manzoni's answer in combination with the Franca-LeClair asymptotic of the zeta zeros here, one can arrive at the following almost identical zeta zero counting function:

$$f(t)=\left\lfloor \frac{t \log \left(\frac{t}{2 e \pi }\right)}{2 \pi }+\frac{7}{8}\right\rfloor +\frac{1}{2} \left(-1+\text{sgn}\left(\Im\left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)\right)$$

where only the singularities are different.

The plot looks like this:

counting function

Mathematica 8 code for the plot:

(*Mathematica 8*)
Plot[(Sign[Im[Zeta[1/2 + I*t]]] - 1)/2 + 
  Floor[t/(2*Pi)*Log[t/(2*Pi*Exp[1])] + 7/8], {t, 0, 60}, 
 Filling -> 0]

Just like Raymonds version also this counting function can be made symmetrical:

Plot[Re[(Sign[Im[Zeta[1/2 + I*t]]] - 1)/2 + 
   Floor[t/(2*Pi)*Log[t/(2*Pi*Exp[1])] + Sign[t]*7/8 + 
     If[t < 0, 2, 0]]], {t, -60, 60}, Filling -> 0]

zeta zero counting symmetry

Update 13.5.2017:

$f(t)=\frac{\Im\left(\text{log$\Gamma $}\left(\frac{1}{4}+\frac{i t}{2}\right)\right)}{\pi }+\frac{\Im\left(\log \left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)}{\pi }-\frac{t \log (\pi )}{2 \pi }+1$

$f(t)=\left\lfloor \frac{\Im\left(\text{log$\Gamma $}\left(\frac{1}{4}+\frac{i t}{2}\right)\right)}{\pi }-\frac{t \log (\pi )}{2 \pi }+1\right\rfloor +\frac{1}{2} \left(-1+\text{sgn}\left(\Im\left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)\right)+1$

$f(t)=\frac{\vartheta (t)+\Im\left(\log \left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)}{\pi }+1$

$f(t)=\left\lfloor \frac{\vartheta (t)}{\pi }+1\right\rfloor +\frac{1}{2} \left(-1+\text{sgn}\left(\Im\left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)\right)+1$

$f(t)=\left\lfloor \frac{t \log \left(\frac{t}{2 \pi \exp (1)}\right)}{2 \pi }+\frac{7}{8}\right\rfloor +\frac{1}{2} \left(-1+\text{sgn}\left(\Im\left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)\right)+1$

$f(t)=\frac{t \log \left(\frac{t}{2 \pi \exp (1)}\right)}{2 \pi }+\frac{\Im\left(\log \left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)}{\pi }+\frac{7}{8}$

Update 25.5.2017:

In the formulas above:
$\Im\left(\log \left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)=\arg \left(\zeta \left(i t+\frac{1}{2}\right)\right)$

I am not sure all of the formulas are correct but they agree for the first few values I have computed.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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