0

I am trying to plot Dusart's sum of prime approximation [ref 1]:

enter image description here

However I'm not getting the correct sum but very large incorrect numbers. Some things come to mind:

1) I'm entering the acsii version into c as (N*N*0.5*(log(N)+log(log(N))-(3/2)+1) where the log is natural log.

2) I've not understood correctly that lnlnn is log(log(N))

3) just lost!

Furthermore using Landau's approximation for the same thing:

$$S_n =\frac 12 n^2 \, \log(n) + O\left(n^2 \log(\log(n))\right)$$

I cannot interpret the big O correctly as once again using ascii to compute in c the big O as follows, (NN(log(log(N))) ).

I get very large incorrect numbers for the big O that should be smaller than the main term.

[ref 1] ON THE ASYMPTOTIC EXPANSION OF THE SUM OF THE FIRST n PRIMES Nilotpal Kanti Sinha November 9, 2010

https://ia801009.us.archive.org/13/items/arxiv-1011.1667/1011.1667.pdf

onepound
  • 1,365
  • $o(1)$ is not $1$. $o(1)$ means something which tends to zero as $n\rightarrow\infty$. – Wojowu Oct 07 '17 at 13:54
  • @Wojowu okay thank you for pointing that out also looking carefully it appears to be little o not Big O. In any case even with o(1) removed it still does not work. – onepound Oct 07 '17 at 14:00
  • For $n=10^6$ I got $S_n\approx 7.47\times 10^{12};$ with the Dusart's formula, $S_n\approx 6.9\times 10^{12}$ with Landau's formula, while the actual value is $S_n=7,472,966,967,499$ – Raffaele Oct 07 '17 at 14:17
  • @onepound We can't guess what you're doing wrong if you tell us nothing about what you are seeing... "I'm not getting a sum" is a description devoid of any content. – Erick Wong Oct 07 '17 at 16:05
  • @Erick Wong seeing? I'. talking about the values the ascii formula is producing in c. I think that is quite clear and confirmed by the answer below. Therefore this should not have been voted down otherwise nobody especially non mathematical people will benefit. – onepound Oct 08 '17 at 09:49
  • @onepound Wrong. You didn’t indicate what values of $n$ you tried, and you didn’t give a single example of what you consider to be a “large incorrect number”. That is a completely subjective assessment and you gave us no basis on which to understand what you consider to be a large error in approximation. You didn’t even give us enough information to tell whether your error is due to integer overflow, because one ascii string does not make an implementation. – Erick Wong Oct 08 '17 at 11:27

1 Answers1

2

In C you may have an error in using 3/2 which will always be treated as integer division. This may lead to some error.

Using the expression

N*N*0.5*( log(N) + log(log(N)) - (3.0f/2.0f)  )

for $N = 1, \ldots, 100$

I get the following relative errors between the estimates and the actual values for $\sum_{r\le n} p_r$

enter image description here

E.g. for $n=100$, the estimate I get is 23161.749 for the actual value of 24133.

Paul Aljabar
  • 1,519