Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Prime Number Counting

  1. Dec 24, 2009 #1
    PI(N) = N /{A * LOG(N)^2 +B * LOG(N) + C}. Note: LOG(N) is the common log.

    This formula works for N up to 10^23. The accuracy depends on the number of digits
    after the decimal point in the coefficients A, B & C. I used a Lotus123 spreadsheet to
    calculate them. My calculated values are;

    A = -0.000223480708389211732
    B = 2.31221822291801513
    C = -1.12554500288863357

    The correct value of PI(10^23) = 1,925,320,391,606,803,968,923. The calculated value is

    Not exact, but within .005%

    I think that better approximations could be attained if the accuracy of the coefficients was
    increased. But I have no way of testing this hypothesis

    Bill J
  2. jcsd
  3. Dec 25, 2009 #2


    User Avatar

    Staff: Mentor

    Almost exactly n/ln(n).
  4. Dec 25, 2009 #3


    User Avatar
    Science Advisor
    Homework Helper

    Borek suggests that (A, B, C) = (0, 1/log e, 0) is a reasonable approximation, which is true. The best values are actually (0, 1/log e, -1/log e) which was proved (as I recall) in the early-mid 1800s. For base-10 logs, that's (0, 2.302585, -2.302585), so your numbers are fairly close.
  5. Dec 27, 2009 #4
    I used the values of PI(N) from the table in the Wikipedia article "Prime Number Theorem" to calculate A, B & C.

    I did a simple data regression analysis of N / PI(N) vs LOG(N) & LOG(N)^2. If the function was truly a straight line; A would be 0.000000000000 .... !

    My results suggest that up to N = 10^23, the ratio N / PI(N) is not exactly a straight
    line; but curves imperceptibly to the right. It may straighten out above 10^23, who

    N / PI(N) is the ideal function; N, PI(N), LOG(N) and LOG(N)^2 can all be exact integers.
    The problem is that N / PI(N), A, B & C cannot be precisely calculated with only 18 digit accuracy.

    Was the early-mid 1800's proof purely theoretical or was it based on empirical data?

    When you calculated PI(N) using the formula I suggested, what sort of errors did
    you get?

  6. Dec 28, 2009 #5

    jim mcnamara

    User Avatar

    Staff: Mentor

  7. Dec 28, 2009 #6


    User Avatar
    Science Advisor
    Homework Helper

    If the function was a line, A and B would be 0. You're free to pick any values you choose, but if you choose anything other than the ones I gave, beyond some (large) N, my function will always be more accurate than yours. But that shouldn't be particularly surprising in your case: it's clear that beyond N = 10^4494 or so, your formula predicts a negative number of primes....


    Hadamard (1896) and de la Vallée-Poussin (1896) proved that it does not.

    It was a proof (hence theoretical), not a conjecture. The original conjecture (late 1700s, I think) was based on empirical evidence, though.
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook