home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math
- Path: sparky!uunet!newsgate.watson.ibm.com!yktnews!admin!yktnews!victor
- From: victor@watson.ibm.com (Victor Miller)
- Subject: Re: nth prime
- Sender: news@watson.ibm.com (NNTP News Poster)
- Message-ID: <VICTOR.92Sep11100049@terse4.watson.ibm.com>
- In-Reply-To: a_rubin@dsg4.dse.beckman.com's message of 10 Sep 92 23:08:38 GMT
- Date: Fri, 11 Sep 1992 14:00:49 GMT
- Reply-To: victor@watson.ibm.com
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- References: <1992Sep10.190905.10741@waikato.ac.nz>
- <1992Sep10.164133.27763@infodev.cam.ac.uk> <a_rubin.716166518@dn66>
- Nntp-Posting-Host: terse4.watson.ibm.com
- Organization: IBM, T.J. Watson Research Center
- Lines: 53
-
- >>>>> On 10 Sep 92 23:08:38 GMT, a_rubin@dsg4.dse.beckman.com (Arthur Rubin) said:
-
- Arthur> In <1992Sep10.164133.27763@infodev.cam.ac.uk> gjm11@cus.cam.ac.uk (G.J. McCaughan) writes:
-
- >In article <1992Sep10.190905.10741@waikato.ac.nz> bill@waikato.ac.nz writes:
-
- >>Sorry to ask such a FAQ, but what's the quickest algorithm to
- >>find the nth prime? Is it O(nlogn) or something else?
-
- >I think there is no way to get p_n exactly that's much better than
- >the good old sieve of Eratosthenes. So in sieving out multiples of 2
- Arthur> ...
-
- Arthur> This isn't quite correct. There is an integral for (the number of primes
- Arthur> <= n) which takes o(n) to evaluate. (I don't know the exact order.) I'm
- Arthur> pretty sure that the time to find the first n primes is about O(n log n),
- Arthur> but you don't have to all n of them in order to find the n_th.
- Arthur> --
- Arthur> Arthur L. Rubin: a_rubin@dsg4.dse.beckman.com (work) Beckman Instruments/Brea
- Arthur> 216-5888@mcimail.com 70707.453@compuserve.com arthur@pnet01.cts.com (personal)
- Arthur> My opinions are my own, and do not represent those of my employer.
- Arthur> My interaction with our news system is unstable; please mail anything important.
-
- This keeps coming up (maybe it should be in the FAQ). There are two
- different methods for evaluation pi(x) (the exact number of primes
- <=x). One is a method based on combinatorial sieving. The latest and
- greatest incarnation of that method is a paper "Calculating pi(x): the
- Meissel-Lehmer Method" by Jeff Lagarias, Victor Miller (that's me),
- and Anrew Odlyzko in Math. Comp. 1985. It gives the history of this
- method. Although it had its genesis in the observation of Legendre
- that one could get an explicit formula for pi(x) only involving primes
- <= sqrt(x), it needed substantial refinements to get to the running
- time of O(x^{2/3 + \epsilon}). I programmed this method and used it
- to calculate the table of values given in the paper (up to x=4*10^16).
- Once one has a method of calculating pi(x) you can use binary search
- to caculate p_n (the n-th prime). This adds a factor of log n. Using
- interpolation search only adds a factor of log log n.
-
- Lagarias and Odlyzko, in "Calculating pi(x): an Analytic Method" in J.
- of Algorithms, 1986, describe a method based on "explicit formulas in
- prime number theory" which has running time O(x^{3/5+\epsilon}) and
- space o(x). Based an a subsequent paper by Odlyzko and Schonhage this
- running time can be gotten down to O(x^{1/2+\epsilon}) with space
- O(x^{1/4+\epsilon}). This method is extremely subtle, and to my
- knowledge has never been implemented.
-
-
- --
- Victor S. Miller
- Bitnet: VICTOR at WATSON
- Internet: victor@watson.ibm.com
- IBM, TJ Watson Research Center
- "Great artists steal; lesser artists borrow" Igor Stravinsky
-