Source: cirosantilli/_file/prime-number-theorem

= prime-number-theorem
{file}

Consider this is a study in failed <computational number theory>.

The $n/ln(n)$ approximation converges really slowly, and we can't easy go far enough to see that the ration converges to 1 with only <awk> and <primes (bsdgames)>:
``
sudo apt intsall bsdgames
cd prime-number-theorem
./main.py 100000000
``
Runs in 30 minutes tested on <Ubuntu 22.10> and <ciro santilli s hardware/P51>, producing:

\Image[https://raw.githubusercontent.com/cirosantilli/media/master/prime-number-theorem/pi.png]
{title=Linear $\pi(n)$ vs $n/ln(n)$ approximation plot}
{description=$f(n) = n$ and $f(n) = log(n)$ are added to give a better sense of scale. $log(n)$ is too close to 0 and not visible, and the approximation almost overlaps entirely with $pi$.}

\Image[https://raw.githubusercontent.com/cirosantilli/media/master/prime-number-theorem/pi-minus.png]
{title=$\pi(n) - n/ln(n)$}
{description=It is clear that the difference diverges, albeit very slowly.}

\Image[https://raw.githubusercontent.com/cirosantilli/media/master/prime-number-theorem/pi-over.png]
{title=$\pi(n)/(n/ln(n))$}
{description=We just don't have enough points to clearly see that it is converging to 1.0, the convergence truly is very slow. The <logarithm integral> approximation is much much better, but we can't calculate it in <awk>, sadface.}
{id=image-pi-n-over-n-ln-n}

But looking at: https://en.wikipedia.org/wiki/File:Prime_number_theorem_ratio_convergence.svg we see that it takes way longer to get closer to 1, even at $10^24$ it is still not super close. Inspecting the code there we see:
``
(* Supplement with larger known PrimePi values that are too large for \
Mathematica to compute *)
LargePiPrime = {{10^13, 346065536839}, {10^14, 3204941750802}, {10^15,
     29844570422669}, {10^16, 279238341033925}, {10^17,
    2623557157654233}, {10^18, 24739954287740860}, {10^19,
    234057667276344607}, {10^20, 2220819602560918840}, {10^21,
    21127269486018731928}, {10^22, 201467286689315906290}, {10^23,
    1925320391606803968923}, {10^24, 18435599767349200867866}};
``
so OK, it is not something doable on a <personal computer> just like that.