trying to compute Riemann's prime counting function J(x)
Show older comments
I am trying to compute Riemann's prime counting function J(x):

J(x) should approximate the numbers of primes <= x using this code:
function J_RiemannPrimeCount = J(x)
if x < 2
error("x must be >= 2");
end
integral_fun = @(t) (1 ./ (t.*(t.^2-1).*log(t)));
integral_term = integral(integral_fun,x,Inf);
zetaZeros = 0.5 + csvread("first 100k zeros of the Riemann zeta.txt") .* i;
maxZero = 35;
k = 1:1:maxZero;
Li_term = logint(x.^zetaZeros(k)) - logint(2);
Li_sum = sum(Li_term);
J_RiemannPrimeCount = (logint(x) - logint(2)) - Li_sum - log(2) + integral_term;
end
The file "first 100k zeros of the Riemann zeta.txt" contains the Imag-values of the Riemann-zeta-function for Re = 0.5 (example: 14.134725142, 21.022039639, 25.010857580, 30.424876126, 32.935061588, ....) . I am using the first maxZero=35 of these to approximate J(x).
The periodic term "Li_sum = sum(Li_term)" is not correct - everything else should be fine. ( I am somewhat worried, that I am doing a super-stupid mistake here... )
Can anyone help nonetheless .. ??
1 Comment
Thomas
on 6 Oct 2019
Answers (2)
Jyothis Gireesh
on 18 Sep 2019
0 votes
Here are a few pointers which may help with resolving the issue:
- The second term in the Reimann’s function is computed by taking the logarithmic integral over x raised to non-trivial zeros of the zeta function.
- Since the sum is ‘conditionally convergent’, the summation should be done by taking the zeros of zeta function in a pair-wise fashion (taking ρ and 1-ρ) as follows
In the code given above, by restricting the zeros to the first 35 entries in the "first 100k zeros of the Riemann zeta.txt" file you may be violating the pair-wise summation condition causing the sum to diverge. So for ρ value in the first 35 entries you may add the corresponding 1-ρ value as well so that the sum term converges.
7 Comments
Thomas
on 18 Sep 2019
Miguel Camarasa
on 29 Mar 2021
I have the same problem! The term Li_sum goes doesn't converge. Did you solve this? :/
Thomas
on 29 Mar 2021
Miguel Camarasa
on 29 Mar 2021
Thank you very much Thomas. I was trying to solve the previous one, but it diverges anyway, maybe because of the precision? I don't think so.
Thomas
on 29 Mar 2021
Miguel Camarasa
on 29 Mar 2021
I see, I don't understand why. Anyway, when I run the J2 function, it doesn't seem to get a nice approximation between the number of primes in [2,100] with 100 roots of the Zeta Function. Maybe something is missing?

Thomas
on 30 Mar 2021
Johannes van Ek
on 27 Mar 2021
0 votes
Very interesting. I have the same problem. Did you manage to resolve this issue?
I do the summation over the conjugate pairs and it diverges.
I found a paper in Cantor's Paradise on this and it quotes converging results with 35 roots (and 100 roots), and it presents nice graphs of J(x). I do not know how the author got these results.
I also tried the cos(alpa(ln(x)) formulation from riemann's original paper. No success either. Puzzled.
6 Comments
Thomas
on 29 Mar 2021
Thomas
on 29 Mar 2021
Johannes van Ek
on 30 Mar 2021
https://www.cantorsparadise.com/the-riemann-hypothesis-explained-fa01c1f75d3f?source=collection_home---4------2-----------------------
The author closely follows Derbyshire's 'Prime obsession'. In the notes on chapter 21
Derbyshire mentions that het uses Ei[rho ln(x)] rather than Li(x^rho) because of details
in Riemann's original paper.
When I use the exponential integral in mpmath everything works beatifully.
I still need to look into why Li(x^rho) does not work.
Thomas
on 30 Mar 2021
Johannes van Ek
on 30 Mar 2021
It is because of branch points of li(x^rho) at 0 an 1 that care needs to ve taken. Anyway, it works now. On to the million dollars!
Irene Chen
on 1 Aug 2021
Do you know how to deal with the branch points? This is so confusing......
Categories
Find more on Time Series Events in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
