# Prime Number Counting

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
1,925,400,258,044,147,870,000

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

Borek
Mentor
Almost exactly n/ln(n).

CRGreathouse
Homework Helper
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

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.

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.
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
knows?

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?

p

CRGreathouse
Homework Helper
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 .... !

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....

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.

Correct.

It may straighten out above 10^23, who
knows?

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

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

It was a proof (hence theoretical), not a conjecture. The original conjecture (late 1700s, I think) was based on empirical evidence, though.