# Explicit formula for Riemann zeros counting function

I've often seen it stated (in vague terms) that there's a Fourier duality between the set of prime numbers and the set of nontrivial Riemann zeta zeros.

Because there are various explicit formulae whereby prime counting functions can be expressed as infinite sums of sinusoidal functions over the set of zeta zeros, I had always assumed that the same thing would work in the opposite direction. That is, I imagined there was a well-known formula whereby the nontrivial-zeta-zeros-counting function could be expressed as an infinite sum of sinusoidal functions over the set of primes.

However, I've been unable to find such a formula. The only explicit formula I've found for this counting function looks like this:

$$f(E) = \frac{1}{\pi} \Im(\ln(\Gamma(1/4 + iE/2)) - \frac{E}{2\pi}\ln(\pi) + \frac{1}{\pi} \Im(\ln(\zeta(1/2 + iE)) + 1$$

where there's no explicit involvement of the primes.

Is anyone aware of a formula of the type I'm seeking? I'm quite sure such a thing must exist, since a programmer friend recently looked at this and got curious enough to "illegally" substitute the (truncated) Euler product expression for zeta in the above (it doesn't converge in the critical strip, hence such a substitution is not mathematically valid), just to see what the resulting function would look like. His plots of

$$N_m(E) = \frac{1}{\pi} \Im(\ln(\Gamma(1/4 + iE/2)) - \frac{E}{2\pi}\ln(\pi) - \frac{1}{\pi} \sum_{p < m} \Im(\ln(1-p^{-1/2-iE})) + 1$$

in three colours (corresponding to $m = 100$, $1000$ and $10000$, and where $E$ varies from $4$ to $60$) can be seen here:

The positions of the zeta zeros are clearly visible, so even though this isn't a valid formula, I imagine that there must be something like this which is valid.

• i found the formulas in the Riemann hypothesis confusing to read. The squiggy and chaotic nature is hidden in the equations Commented Jul 3, 2016 at 2:31

It looks like the exact formula being sought here can be found in A.P. Guinand, "A summation formula in the theory of prime numbers", Proceedings of the London Mathematical Society (2) 50 (1948) 107--119. The first page is visible here without subscription:

You can see the explicit formula in the abstract, although hard to see the fine detail without access to the full PDF. This is a general form involving a function $f$ and an integral transform thereof. The abstract mentions "appropriate conditions" on $f$: I can't see what these are, but with an appropriate choice of this function, the formula displayed would presumably reduce to a fairly straightforward relation between a sum over the primes and a sum over the nontrivial zeros.

Assuming the Riemann Hypothesis, you can use a smooth approximation to the characteristic function of an interval in the Guinand-Weil explicit formula to approximately count the number of zeros of the zeta-function in an interval on the critical line. This expresses the approximate number of such zeros in terms of an integral of your test function and a sum over primes, as you seek. In fact, this can be set-up in such a way that the sum over primes is finite. (This method can be used to give upper and lower bounds for the number of zeros, but not an exact formula.)

The details are (essentially) contained in a paper by Goldston & Gonek "A note on S(t) and the zeros of the Riemann zeta function" available on Dan Goldston's webpage: math.sjsu.edu/~goldston/publications.htm

The formula is given by Guinand as said in his answer by Matthew Watkins but it can be found in page 111 of the paper and reads: assuming Riemann Hypothesis and $T>0$ $$\frac12(N(T+0)+N(T-0))=\frac{T}{2\pi}\log\frac{T}{2\pi}-\frac{T}{2\pi}-$$ $$- \frac{1}{\pi}\lim_{N\to\infty}\Bigl[\sum_{n=1}^N\Lambda(n)\frac{\sin(T\log n)}{n^{1/2} \log n}-\int_1^N \frac{\sin(T\log t)}{t^{1/2}\log t}dt-$$ $$-\frac{\sin(T\log N)}{\log N}\Bigl(\sum_{n=1}^N\Lambda(n)n^{-1/2}-2N^{1/2} \Bigr)\Bigr]+$$ $$+\frac{1}{2\pi}\left(\operatorname{\rm am}\Gamma\left(\frac12+iT\right)-T\log T+T\right)+$$ $$+\frac{1}{\pi}\arctan(2T)-\frac{1}{4\pi}\arctan(\sinh(\pi T)),$$ where $\operatorname{\rm am} \Gamma(\frac12+it)$ is defined by making $\operatorname{\rm am} \Gamma(\frac12)=0$ and continuing analytically along any path not meeting the real axis.

Of course the sums where $\Lambda(n)$ appears can be considered sum about primes.

• What is am? argument? Commented Feb 9, 2014 at 11:55
• @MarcPalm Yes, but I maintained the notation in Guinand
– juan
Commented Feb 9, 2014 at 19:54

Guinand's paper is accessible at archive.org (p.111)

Edit 5.2.2014:

Using this as a starting point:

$$\Lambda(n)=\lim\limits_{s \rightarrow 1} \zeta(s)\sum\limits_{d|n} \frac{\mu(d)}{d^{(s-1)}}.$$

Where $$\Lambda(n)$$ is the von Mangoldt function.

Edit 25.3.2018 All of the pictures I posted above are either slightly or almost completely wrong. I deleted the last two. The correct plot starts from the following symbolic relationships:

Let $$\mu(n)$$ be the Möbius function, then:

$$a(n) = \sum\limits_{d|n} d \cdot \mu(d)$$

$$T(n,k)=a(GCD(n,k))$$

$$T = \left( \begin{array}{ccccccc} +1&+1&+1&+1&+1&+1&+1&\cdots \\ +1&-1&+1&-1&+1&-1&+1 \\ +1&+1&-2&+1&+1&-2&+1 \\ +1&-1&+1&-1&+1&-1&+1 \\ +1&+1&+1&+1&-4&+1&+1 \\ +1&-1&-2&-1&+1&+2&+1 \\ +1&+1&+1&+1&+1&+1&-6 \\ \vdots&&&&&&&\ddots \end{array} \right)$$

$$\sum\limits_{k=1}^{\infty}\sum\limits_{n=1}^{\infty} \frac{T(n,k)}{n^c \cdot k^s} = \sum\limits_{n=1}^{\infty} \frac{\lim\limits_{z \rightarrow s} \zeta(z)\sum\limits_{d|n} \frac{\mu(d)}{d^{(z-1)}}}{n^c} \;\;\;\;\;\;\;\;(1)$$ $$\sum\limits_{n=1}^{\infty} \frac{\lim\limits_{z \rightarrow s} \zeta(z)\sum\limits_{d|n} \frac{\mu(d)}{d^{(z-1)}}}{n^c} = \frac{\zeta(s) \cdot \zeta(c)}{\zeta(c + s - 1)} \;\;\;\;\;\;\;\;\;(2)$$

which is part of the limit:

$$\frac{\zeta '(s)}{\zeta (s)}=\lim_{c\to 1} \, \left( \color{Red}{\zeta (c)}-\frac{\zeta (c) \zeta (s)}{\zeta (c+s-1)}\right) \;\;\;\;\;\;\;(3)$$ $$\int \frac{\zeta '(s)}{\zeta (s)} ds = \log(\zeta(s)) \;\;\;\;\;\;\;\;\;\;(4)$$

And the zeta zero counting function is roughly:

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

where $$\vartheta (t)$$ is the Riemann Siegel Theta function.

Since we are looking for the Fourier series like plot we instead write right hand side of $$(3)$$ as:

$$\frac{\zeta '(s)}{\zeta (s)} \approx \sum\limits_{n=1}^{\infty} \left( \color{Red}{\frac{1}{n^c}}-\frac{\lim\limits_{z \rightarrow s} \zeta(z)\sum\limits_{d|n} \frac{\mu(d)}{d^{(z-1)}}}{n^c}\right)\;\;\;\;\;\;\;\;\;\;(6)$$ Integrating $$(6)$$ we achieve:

$$\log(\zeta(s))\approx \int\sum\limits_{n=1}^{\infty} \left( \color{Red}{\frac{1}{n^c}}-\frac{\lim\limits_{z \rightarrow s} \zeta(z)\sum\limits_{d|n} \frac{\mu(d)}{d^{(z-1)}}}{n^c}\right)ds\;\;\;\;\;\;\;\;\;\;(7)$$ The colored $$\color{Red}{\zeta(c)}$$ in $$(3)$$ and $$\color{Red}{\frac{1}{n^c}}$$ in $$(6)$$ is equivalent to the first column in matrix $$T$$.

This integral can be solved symbolically with the Euler-Maclaurin formula for the Riemann zeta function, and combined with Riemann Siegel Theta in $$(5)$$ it is something like:

$$f(t)=\small \frac{\vartheta (t)+\Re\left(\sum _{\text{nn}=1}^{\text{nnn}} \left(\frac{1}{\text{nn}^c}-\frac{\sum _{d=1}^{\text{nn}} \text{If}\left[\text{nn} \bmod d=0,\sum _{r=1}^{q-1} \left(\sum _{i=0}^{r-2} -\frac{B_r d^{1-\left(\frac{1}{2}+i t\right)} k^{-r-\left(\frac{1}{2}+i t\right)} \left|S_r^{(i)}\right| \text{Expand}\left[\sum _{m=0}^i \left(\frac{1}{2}+i t\right)^m (\log (d)+\log (k))^m N\left[\frac{i!}{m!}\right]\right]}{r! (\log (d)+\log (k))^{i+1}}\right)+\mu (d) \sum _{n=1}^k \text{If}\left[n=1\lor (n=1\land d=1),\frac{1}{2}+i t,-\frac{d^{1-\left(\frac{1}{2}+i t\right)}}{n^{\frac{1}{2}+i t} (\log (d)+\log (n))}\right]+\text{Ei}\left(-\left(\left(i t+\frac{1}{2}\right)-1\right) \log (d)-\left(\left(i t+\frac{1}{2}\right)-1\right) \log (k)\right),0\right]}{\text{nn}^c}\right)\right)}{\pi } \;(8)$$ where $$s$$ has been replaced with $$1/2+it$$. $$f(t)$$ in $$(8)$$ is not computationally feasible to evaluate so instead we resort to looking at the numerical integral.

If we instead look at the plot of the numerical integral in the right hand side in $$(9)$$ below, then for $$c=1$$; $$1+\frac{\vartheta (t)+\Im\left(\log \left(\zeta \left(i t+\frac{1}{2}\right)\right)\right)}{\pi } \\ \approx \frac{\vartheta (t)+\Re\left(\int\sum\limits_{n=1}^{\infty} \left( \frac{1}{n^c}-\frac{\lim\limits_{z \rightarrow \frac{1}{2} + it} \zeta(z)\sum\limits_{d|n} \frac{\mu(d)}{d^{(z-1)}}}{n^c}\right)ds\right)}{\pi}\;\;\;\;\;(9)$$

something much more Fourier series like appears:

where there is a jump of size one at every Riemann zeta zero.

The Mathematica program for the plot of the numerical integral in $$(9)$$ is:

(*start*)
Clear[n, s, c, t, nn, delta];
c = 1;
delta = 40;
nn = 60;
a = Sum[1/N[n]^c -
Zeta[1/2 + I*t]*
Total[MoebiusMu[Divisors[n]]/Divisors[n]^(1/2 + I*t - 1)]/
n^c, {n, 1, 600}];
ListLinePlot[(Table[
delta*RiemannSiegelTheta[t], {t, 0, nn, 1/delta}] +
Accumulate[Table[Re[a], {t, 0, nn, 1/delta}]])/delta/Pi,
PlotStyle -> Thickness[0.003], DataRange -> {0, nn}]
(*end*)


Edit 15.8.2018:

The correct way to integrate the Euler-Maclaurin formula is:

$$\boxed{N(t)=\frac{1}{\pi}\left(\vartheta (t)-\Re\left(\sum _{n=1}^{\text{nn}} \frac{1}{n^c} \left(\underset{d \mid n}{\sum\limits_{d=1}^{n}} \left(f(\frac{1}{2}+it, d)-f(\frac{1}{2}+i0, d) \right)\right)\right)\right)}$$

where $$\vartheta (t)$$ is the Riemann-Siegel theta function,

and where:

$$f(s,d)=-i \mu (d) \left(\sum _{n=0}^{q-1} \left(\sum _{i=0}^{2 n+1} -\frac{d B_{2 (n+1)} k^{-2 n-1} \left|S_{2 n+1}^{(i)}\right| \log ^{-i-1}(d k) \Gamma (i+1,s \log (k d))}{(2 (n+1))!}\right)+\sum _{n=2}^k -\frac{d^{1-s} n^{-s}}{\log (d)+\log (n)}+\text{If}\left[d=1 \text{ then } 0\text{ else }-\frac{1^{-s} d^{1-s}}{\log (d)+\log (1)}\right]+\frac{d^{1-s} k^{-s}}{2 (\log (d)+\log (k))}+\text{Ei}(-(s-1) \log (d)-(s-1) \log (k))\right)$$

and where $$\mu (d)$$ is the Möbius function.

As a Mathematica program the symbolic integral is:

(* Integral *)
(*start*)
Clear[k, n, s, i, d, r, q, f, a, b, integral, c, nn, n, k];
nn = 30;
delta = 1/5;
k = 30;
q = 10;
c = 1;
rr = 60;
f[s_, d_] = -I*
MoebiusMu[
d]*(If[d == 1, 0, -((d^(1 - s) 1^-s)/(Log[d] + Log[1]))] +
Sum[-((d^(1 - s) n^-s)/(Log[d] + Log[n])), {n, 2, k}] +
ExpIntegralEi[-(-1 + s) Log[d] - (-1 + s) Log[k]] + (
d^(1 - s) k^-s)/(2 (Log[d] + Log[k])) +
Sum[Sum[-(BernoulliB[2*(n + 1)]/((2*(n + 1))!))*(Abs[
StirlingS1[2*n + 1, i]]) d k^(-2*n - 1)
Gamma[1 + i, s Log[k*d]] Log[k*d]^(-1 - i), {i, 0,
2*n + 1}], {n, 0, q - 1}]);
integral[a_, b_, d_] = f[b, d] - f[a, d];
Print["Counting to ", rr];
Monitor[ListLinePlot[
Table[(RiemannSiegelTheta[t] -
Re[Sum[Sum[
If[Mod[n, d] == 0, integral[1/2 + I*0, 1/2 + I*t, d]/n^c,
0], {d, 1, n}], {n, 1, nn}]])/Pi, {t, 0, rr, delta}],
PlotStyle -> Thickness[0.003], DataRange -> {0, rr},
ImageSize -> Large], Floor[t]]
(* end *)


• Commented Jun 24, 2018 at 11:20

The Riemann zeta zeros counting function as a sum of the von Mangoldt function (or expanded with the Möbius function):

Mathematica program that exports 120 gif images to your Documents folder.

(*Integral*)(*start*)
Clear[k, n, s, i, d, r, q, f, a, b, integral, c, nn, n, k];
nn = 120;
delta = 1/10;
k = 16;
q = 10;
c = 1;
rr = 60;
f[s_, d_] =
N[-I*MoebiusMu[
d]*(If[d == 1, 0, -((d^(1 - s) 1^-s)/(Log[d] + Log[1]))] +
Sum[-((d^(1 - s) n^-s)/(Log[d] + Log[n])), {n, 2, k}] +
ExpIntegralEi[-(-1 + s) Log[d] - (-1 + s) Log[
k]] + (d^(1 - s) k^-s)/(2 (Log[d] + Log[k])) +
Sum[Sum[-(BernoulliB[2*(n + 1)]/((2*(n + 1))!))*(Abs[
StirlingS1[2*n + 1, i]]) d k^(-2*n - 1) Gamma[1 + i,
s Log[k*d]] Log[k*d]^(-1 - i), {i, 0, 2*n + 1}], {n, 0,
q - 1}])];
integral[a_, b_, d_] = f[b, d] - f[a, d];
Print["Counting to ", nn];
rrr = N[Table[RiemannSiegelTheta[t]/Pi, {t, 0, rr, delta}]];
Monitor[iii =
Table[Table[
Re[Sum[integral[1/2 + I*0, 1/2 + I*t, d]/n^c, {d, Divisors[n]}]]/
Pi, {t, 0, rr, delta}], {n, 1, nn}];, n]
Monitor[Table[
Export[StringJoin["image", ToString[i], ".gif"],
Show[Plot[(RiemannSiegelTheta[t] + Im[Log[Zeta[1/2 + I*t]]])/Pi +
1, {t, 0, 60}, PlotStyle -> {Red, Thickness[0.004]},
ImageSize -> Large],
ListLinePlot[rrr - Sum[iii[[j]], {j, 1, i}],
PlotStyle -> Thickness[0.004], DataRange -> {0, rr},
ImageSize -> Large],
Graphics[
Text[Style["Counting Riemann zeta zeros using", Large], {21,
12}]], Graphics[
Text[Style[
StringJoin[ToString[i],
" terms of the von Mangoldt function."], Large], {23,
10}]]]], {i, 1, nn}], i]
(*end*)

• The formula for $\Lambda(n)$ in your 2014 edit is incorrect when $n=1$. For $n>1$ the formula is a disguised version of the formula $\Lambda(n) = -\sum_{d|n} \mu(d)\log d$, which is true for all $n$, including $n=1$, and comes from equating Dirichlet series coefficients on both sides of $-\zeta’(s)/\zeta(s) = (1/\zeta(s))(\zeta’(s))$ for ${\rm Re}(s) > 1$. Commented Jan 30, 2022 at 13:37

This may not help you, but: With Excel I calculated the Discrete Fourier Transform of a function = unit spikes at locations of the logarithms of a few hundred primes. The zeta zeros (imaginary part) show up as spikes. But it only works for small numbers of primes and zeros. For a better approximation, I reversed the explicit formula in Riemann's, making the spike heights = ln(p)/sqrt(p), and included powers of primes at 1/exponent as much, like the Von Mangoldt function. That gave much cleaner results, valid for thousands of primes and zeros. However it does diverge (increasing oscillations) for really big values, because logs of primes get close (more than the zeta zeros in Reimann's formula). I'm leaving out some details. If you or anyone is interested, email me at [email protected] for the spreadsheets or graphs.