Jump to content

Meissel–Lehmer algorithm

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by B wik (talk | contribs) at 12:51, 4 February 2022. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Meissel–Lehmer algorithm (after Ernst Meissel and Derrick Henry Lehmer) is an algorithm that computes the prime-counting function.[1][2]

Description

Key functions

Let be the first n primes. For natural number a ≥ 1, define

which counts natural numbers no greater than x with all prime factors greater . Also define for natural number k,

which counts natural numbers no greater than x with exactly k prime factors, all larger than . With these, we have

where the sum only has finitely many nonzero terms, because when . Using the fact that , we get

which prove that one may compute by computing and for k ≥ 2. This is what the Meissel–Lehmer algorithm does.

Formula for Pk(x, a)

For k = 2, we get the following formula for :

For k ≥ 3, the identities for can be derived similarly.[1]

Meissel already found that for if . He used the resulting equation for calculations of for big values of . [1]

Meissel calculated up to , but he narrowly missed the correct result for the biggest value of x.[1]

Expanding 𝜑(x, a)

Using the recurrence

may be expanded. Each summand, in turn, may be expanded in the same way.

Combining the terms

The only thing that remains to be done is evaluating and for k ≥ 2, for certain values of x and a. This can be done by direct sieving and using the above formulas.

Lehmer analyzed especially the calculation of and used already computers to calculate the correct value of .[1]

Modern variants

Jeffrey Lagarias, Victor Miller and Andrew Odlyzko published a realisation of the algorithm which computes in time and space for any .[2] Upon setting , the tree of has leaf nodes.[2]

This extended Meissel-Lehmer algorithm needs less computing time than the algorithm developed by Meissel and Lehmer, especially for big values of x.

Further improvements are given by M. Deleglise and J. Rivat in 1996.[3]

References

  1. ^ a b c d e Lehmer, Derrick Henry (April 1, 1958). "ON THE EXACT NUMBER OF PRIMES LESS THAN A GIVEN LIMIT". Illinois J. Math. 3 (3): 381–388. Retrieved February 1, 2017.
  2. ^ a b c Lagarias, Jeffrey; Miller, Victor; Odlyzko, Andrew (April 11, 1985). "Computing : The Meissel–Lehmer method" (PDF). Mathematics of Computation. 44 (170): 537–560. doi:10.1090/S0025-5718-1985-0777285-5. Retrieved September 13, 2016.
  3. ^ Deleglise, Marc; Rivat, Joël (January 15, 1996). "Computing : The Meissel, Lehmer, Lagarias, Miller, Odlyzko method". Mathematics of Computation. 65 (213): 235–245. doi:10.1090/S0025-5718-96-00674-6.