# trying to compute Riemann's prime counting function J(x)

40 views (last 30 days)
Thomas on 15 Sep 2019
Commented: Irene Chen on 1 Aug 2021
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_sum = sum(Li_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 .. ??
Thomas on 6 Oct 2019
Hi , would still greatly appreciate if anyone has an idea on this here:
When calculating the explicit Riemann prime counting function J(x) for x=2,...,1000 using the program below, I get an oscillating term Li_sum that looks like in the diagram (see attachement). The local maxima are in the right place (= at the exact locations of the prime numbers): however Li_sum should not be descending in the way it is doing here, but should be distributed around zero, since it is "only" the error term in the smooth estimation. So there must be a kind of "adjustment"-factor somewhere - maybe resulting from the fact that Li_sum is the truncated version of a conditionally convergent series.
% explicit Riemann Prime Counting function J
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 = 1000;
k = 1:1:maxZero;
Li_sum = sum(Li_term);
J_RiemannPrimeCount_smooth = (logint(x) - logint(2)) - log(2) + integral_term; % prime estimation without oscillating term
J_RiemannPrimeCount = (logint(x) - logint(2)) - log(2) + integral_term - Li_sum; % prime counting with oscillating term
end
Any idea, where the error could be ... ???

Jyothis Gireesh on 18 Sep 2019
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.
Thomas on 30 Mar 2021
I think the approximation becomes better for large x in J2(x) But I did not look into this in detail...

Johannes van Ek on 27 Mar 2021
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.
Irene Chen on 1 Aug 2021
Do you know how to deal with the branch points? This is so confusing......

### Categories

Find more on Number Theory in Help Center and File Exchange

R2019a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!