# Riemann Prime Counting Function correction/pairing terms by Mathematica

Riemann Prime Counting Function:

$$f(x)=\operatorname{li}(x)-\sum_\rho\operatorname{li}(x^\rho)-\ln 2+\int_x^\infty \frac{\mathrm dt}{t(t^2-1)\ln t}$$

The second correction/paring terms:

$$\sum_\rho\operatorname{li}(x^\rho)=\sum_{I[\rho]>0}[\operatorname{Li}(x^\rho)+\operatorname{Li}(x^{1-\rho})]$$

I tried to use Mathematica function LogIntegral to plot this second correction/paring terms, for example, when I only include the first 2 non-trivial zeros, and plot with range x from 1 to 5:

Plot[Sum[LogIntegral[x^ZetaZero[k]] + LogIntegral[x^(1 - ZetaZero[k])],
{k, 1, 2}], {x, 1, 5}]


However, I got very large value instead of small correction:

I can also use simplified equation provided by reference 1:

$$\operatorname{li}(x^\rho)=\operatorname{li}(e^{\rho \log x})\sim \frac{e^{\rho \log x}}{\rho \log x}$$

Plot[Sum[Exp[ZetaZero[k]*Log[x]]/(ZetaZero[k]*Log[x]), {k, 1, 2}] +
Sum[Exp[(1 -ZetaZero[k])*Log[x]]/((1 - ZetaZero[k])*Log[x]),
{k, 1, 2}], {x, 1, 5}]


Then I got the correct result:

Anyone knows what is wrong for the LogIntegral one?

Thank you!

1: H. Riesel and G Gohl, "Some Calculations Related to Riemann's Prime Number Formula," Mathematics of Computation, 24(112), 1970 pp. 969–983.

• RiemannR is built in so you could always use that. One reason your correction is bad is because $\mathrm{Li}(x)$ is not the same as $\mathrm{li}(x)$. You should code $\mathrm{li}(x)$ as LogIntegral[x], but $\mathrm{Li}(x)$ as LogIntegral[x]-LogIntegral[2] , however there is still something else wrong as the correction is still too large. Jul 26, 2020 at 12:55
• Thanks. yeah, by adding - LogIntegral[2] doesn't give the correct answer. It just shift the trend a little bit down. RiemannR only gives the mobius function of first major prime counting term. It does not contain the correction terms. therefore if you plot RiemannR, only a smooth counting curve could be generated, instead of a "zigzag" curve following the real prime number distribution. Jul 26, 2020 at 20:58

Please see the explanation in this question.

Plot[
Sum[
ExpIntegralEi[ZetaZero[k]*Log[x]] +
ExpIntegralEi[(1 - ZetaZero[k])*Log[x]],
{k, 1, 2}], {x, 1, 5},
Frame -> True]


The corresponding plot matches the one you showed from the "simplified equation".

• Thank you for the explanation! Jul 28, 2020 at 4:04