Section 21.2 Some History
ΒΆDefinition 21.2.1.
We say that two functions f(x) and g(x) are asymptotic to each other when
Essentially, in the long run these functions get as close to each other as you like, on a percentage basis.
Subsection 21.2.1 The first really accurate estimate and errors
ΒΆIn fact, Gauss makes this estimate even more precise. Here is the general idea. First, reinterpret the proportion as suggesting that 1/\log(x) integers near x are prime. If we do that, then we can think of 1/\log(x) as a probability density function. What do we do with such functions? We integrate the function to get the cumulative amount! That is, we should expect that \pi(x)\approx \int_2^x\frac{dt}{\log(t)} or equivalentlyDefinition 21.2.2.
We give the name logarithmic integralβ2βThere is also a definition for this integral \(\int_0^x\frac{dt}{\log(t)}\text{,}\) which has a properly defined value (beyond the level of this course) despite the integrand going to negative infinity. The form used for the prime counting function is traditionally the one with lower bound \(2\text{,}\) for reasons clear in the rest of this text. There are no divergence issues at stake. to the (convergent) integral Li(x)=\int_2^x \frac{dt}{\log(t)}\text{.}

xxxxxxxxxx
def _(n=100):
show(plot(prime_pi,3,n,color='black', legend_label=r'$\pi(x)$') + plot(x/log(x),3,n,color='red', legend_label=r'$x/\log(x)$') + plot(Li,3,n, color='green', legend_label='$Li(x)$'))
xxxxxxxxxx
def _(n=[100,1000,1000000,1000000000]):
P = prime_pi(n)
pretty_print(html(r"$\pi(%s)=%s$"%(n,prime_pi(n))))
pretty_print(html(r"The error with $%s/\log(%s)$ is $\approx %s$"%(n,n,P-(n/log(n)).n())))
pretty_print(html(r"The error with $Li(%s)$ is $\approx %s$"%(n,(P-Li(n)).n())))
Subsection 21.2.2 Exploring Li
ΒΆCan we try for some more analysis? Since we saw that x/\log(x) didn't seem to be as good an approximation, we'll leave it out for now. This graphic show two representative 1000-wide stretches, and the following interact allows you to explore more of them.
xxxxxxxxxx
def _(n=1000):
P = plot(prime_pi,3,n, color='black',legend_label=r'$\pi(x)$')
P += plot(Li,3,n, color='green',legend_label='$Li(x)$')
show(P, xmin=max(n-1000,0), ymin=prime_pi(max(n-1000,0)))
Fact 21.2.5.
For any number x\text{,} there is an x'>x such that
Fact 21.2.6.
The first time this happens is no higher than