Sunday, May 4, 2025

Prime Counting - A Self-correcting Approximation

                                                                                                                           By Vishnu Vinjamuri

Abstract:

The famous prime-counting function, known as p(x) = x/log x  is widely used for most practical purposes but underestimates the number of primes. Several other formulas are available that provide more accurate estimates of the number of primes less than a given positive integer. In this article, a unique approximation is presented using the formula  p(x) = x/log x as the base, which results in a very high degree of accuracy while remaining computationally simple.

Introduction:

The prime counting function is denoted by   p(x)  and has several approximations.

The most popular and widely used such approximation is

      

- Equation (1)


Where x is any given real number greater than 2 and p(x)  is the number of primes less than or equal to n.

It is well known that the above approximation runs asymptotic to the actual total number of primes and is a lower bound approximation.

Many other approximations using this format are of the form:


  - Equation (2)


Where B is a constant, whose value is 1.08366 as proposed first by Legendre and later changed to 1.0. From Wikipedia (source unknown), we see further modifications to these constants between different values of n, for better approximation and these constants seem to be working well.

Pierre Dusart suggested formulas using similar and more complex constants, with lower and upper bounds.

In 2024, Timothy Ganesan proposed the below formula for prime numbers which is a better approximation than 1.1.

 

- Equation (3)


The various approximations coming under the family of Equation (2), provide a very good estimate of the number of primes, but the constants need to be adjusted as the number n increases. Several other equations exist which are complex in nature.

These equations and varying constants make the computation more complex.

In this article, let us approximate the number of primes by looking at the very Equation (1) and closely examining the distribution of primes in large intervals, aiming to keep the solution simple.

From now onward, let us call Equation (1) the Prime Counting Function.

All logarithms in this article are natural logarithms.