In mathematics, the Legendre sieve, named after Adrien-Marie Legendre, is the simplest method in modern sieve theory. It applies the concept of the Sieve of Eratosthenes to find upper or lower bounds on the number of primes within a given set of integers. Because it is a simple extension of Eratosthenes' idea, it is sometimes called the Legendre–Eratosthenes sieve.[1]
The central idea of the method is expressed by the following identity, sometimes called the Legendre identity:
S(A,P)=\suma\in\sumd\mid\mu(d)=\sumd\mid\mu(d)|Ad|,
where A is a set of integers, P is a product of distinct primes,
\mu
Ad
S(A,P)=|\{n:n\inA,\gcd(n,P)=1\}|
i.e. S(A, P) is the count of numbers in A with no factors common with P.
Note that in the most typical case, A is all integers less than or equal to some real number X, P is the product of all primes less than or equal to some integer z < X, and then the Legendre identity becomes:
\begin{align} S(A,P)={}&\sumd\mid\mu(d)\left\lfloor
X | |
d |
\right\rfloor\\[6pt] ={}&\lfloorX\rfloor-
\sum | \left\lfloor | |
p1\lez |
X | |
p1 |
\right\rfloor+
\sum | |
p1<p2\lez |
\left\lfloor
X | |
p1p2 |
\right\rfloor\\[4pt] &{}-
\sum | \left\lfloor | |
p1<p2<p3\lez |
X | |
p1p2p3 |
\right\rfloor+ … +\mu(P)\left\lfloor
X | |
P |
\right\rfloor \end{align}
(where
\lfloorX\rfloor
2\pi(z)
\pi(z)
Once S(A, P) has been calculated for this special case, it can be used to bound
\pi(X)
S(A,P)\geq\pi(X)-\pi(z)+1,
which follows immediately from the definition of S(A, P).
The Legendre sieve has a problem with fractional parts of terms accumulating into a large error, which means the sieve only gives very weak bounds in most cases. For this reason it is almost never used in practice, having been superseded by other techniques such as the Brun sieve and Selberg sieve. However, since these more powerful sieves are extensions of the basic ideas of the Legendre sieve, it is useful to first understand how this sieve works.