The following vague discussion is meant to motivate a precise way to
measure the number (or percentage) of primes. What percentage of
natural numbers are even?  Answer: Half of them.  What percentage of
natural numbers are of the form  ?  Answer: One fourth of them.
What percentage of natural numbers are perfect squares?  Answer: Zero
percent of all natural numbers, in the sense that the limit of the
proportion of perfect squares to all natural numbers converges to 0
.
More precisely,
?  Answer: One fourth of them.
What percentage of natural numbers are perfect squares?  Answer: Zero
percent of all natural numbers, in the sense that the limit of the
proportion of perfect squares to all natural numbers converges to 0
.
More precisely,
 
since the numerator is roughly
 and
 and 
 .
Likewise, it is an easy consequence of Theorem 1.2.11
below that zero percent of all natural numbers are prime
(see Exercise 1.4).
.
Likewise, it is an easy consequence of Theorem 1.2.11
below that zero percent of all natural numbers are prime
(see Exercise 1.4).
We are thus led to ask another question: How many positive integers
 are perfect squares?  Answer: roughly
 are perfect squares?  Answer: roughly  .  In the
context of primes, we ask,
.  In the
context of primes, we ask,
 are prime?
 are prime?Let
 is a prime
    is a prime 
For example,
 
Some values of
 are given in Table 1.1, 
and Figures 1.1 and 1.2 contain graphs of
 are given in Table 1.1, 
and Figures 1.1 and 1.2 contain graphs of  .
These graphs look like straight lines, which maybe bend down slightly.
.
These graphs look like straight lines, which maybe bend down slightly.
 in SAGE use the command prime_pi(x):
 in SAGE use the command prime_pi(x):
sage: prime_pi(6) 3 sage: prime_pi(100) 25 sage: prime_pi(3000000) 216816We can also draw a plot of
 using the plot command:
 using the plot command:
sage.: show(plot(prime_pi, 1,1000, rgbcolor=(0,0,1)))
Gauss was an inveterate computer:
he wrote in an 1849 letter that there are
 primes less than
 primes less than  (this is wrong but close;
the correct count is
 (this is wrong but close;
the correct count is  ).
).  
Gauss conjectured the following asymptotic formula for  , which was
later proved independently by Hadamard and Vallée
Poussin in 1896 (but will not be proved in
this book):
, which was
later proved independently by Hadamard and Vallée
Poussin in 1896 (but will not be proved in
this book):
We do nothing more here than motivate this deep theorem with a few further observations. The theorem implies that
 
so for any
 ,
, 
 
Thus
 is also asymptotic to
 is also asymptotic to  for
any
 for
any  .  See [#!primenumbers!#, §1.1.5] for a discussion of why
.  See [#!primenumbers!#, §1.1.5] for a discussion of why
 is the best choice.  Table 1.2 compares
 is the best choice.  Table 1.2 compares
 and
 and 
 for several
 for several  .
.
|   |   |  (approx) | 
| 1000 | 168 | 169.2690290604408165186256278 | 
| 2000 | 303 | 302.9888734545463878029800994 | 
| 3000 | 430 | 428.1819317975237043747385740 | 
| 4000 | 550 | 548.3922097278253264133400985 | 
| 5000 | 669 | 665.1418784486502172369455815 | 
| 6000 | 783 | 779.2698885854778626863677374 | 
| 7000 | 900 | 891.3035657223339974352567759 | 
| 8000 | 1007 | 1001.602962794770080754784281 | 
| 9000 | 1117 | 1110.428422963188172310675011 | 
| 10000 | 1229 | 1217.976301461550279200775705 | 
As of 2004, the record for counting primes appears to be
 
The computation of
 reportedly took ten
  months on a 350 Mhz Pentium II (see [#!pixproject!#] for more
  details).
 reportedly took ten
  months on a 350 Mhz Pentium II (see [#!pixproject!#] for more
  details).
For the reader familiar with complex analysis, we mention a
  connection between  and the Riemann Hypothesis.  The
  Riemann zeta function
 and the Riemann Hypothesis.  The
  Riemann zeta function  is a complex analytic function on
 is a complex analytic function on
  
 that extends the function defined on a right
  half plane by
 that extends the function defined on a right
  half plane by 
 .  The Riemann
  Hypothesis is the conjecture that the
  zeros in
.  The Riemann
  Hypothesis is the conjecture that the
  zeros in 
 of
 of  with positive real part lie on the line
 with positive real part lie on the line
  
 . This conjecture is one of the Clay Math Institute
  million dollar millennium prize problems [#!cmi!#].
. This conjecture is one of the Clay Math Institute
  million dollar millennium prize problems [#!cmi!#].
According to [#!primenumbers!#, §1.4.1], the Riemann Hypothesis is equivalent to the conjecture that
 
is a ``good'' approximation to
 , in the following 
precise sense:
, in the following 
precise sense:
If
 , then
, then  and
 and  ,
but
,
but 
 , so the inequality
is not true for
, so the inequality
is not true for  , but
, but  is big enough.
We will do nothing more to explain this conjecture,
and settle for one numerical example.
 is big enough.
We will do nothing more to explain this conjecture,
and settle for one numerical example.
 .  Then
.  Then
|  |  | |
|  |  | |
|  |  | |
|  |  | |
|  |  | 
 ,
,  , and
, and 
 .
.
sage: def Li(x): ... return integral_numerical(lambda t: 1/log(t), 2, x)[0] sage: P = plot(prime_pi, 2,10000, rgbcolor=(1,0,0),plot_points=30) sage: Q = plot(Li, 2,10000, rgbcolor=(0,0,1), plot_points=30) sage: R = plot(lambda x: sqrt(x)*log(x), 2, 10000) sage.: show(P+Q+R,xmin=0)
![\includegraphics[width=0.6\textwidth]{graphics/rh.eps}](img348.png) 
For more on the prime number theorem and the Riemann hypothesis see [#!zagier:primes50!#] and [#!mazur-stein:rh!#].
William 2007-06-01