Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Thanks for all of those answers. I suspected there was something fairly simple like that, but I couldn't find it at the time. I've done a bit more research too.</p> <p>As I want it for a <a href="http://en.wikipedia.org/wiki/Template:Number-theoretic_algorithms" rel="nofollow noreferrer">sieve</a> to generate the first <em>n</em> prime numbers, I want the approximation to be greater than or equal to the <em>n</em>th prime. (Therefore, I want the upper bound of the <em>n</em>th prime number.)</p> <p><a href="http://en.wikipedia.org/wiki/Prime_number_theorem#Approximations_for_the_nth_prime_number" rel="nofollow noreferrer">Wikipedia</a> gives the following upper bound for <code>n &gt;= 6</code></p> <pre><code>p_n &lt;= n log n + n log log n (1) </code></pre> <p>where <code>p_n</code> is the <em>n</em>th prime, and <code>log</code> is the natural logarithm. This is a good start, but it can overestimate by a not inconsiderable amount. <a href="https://www.maa.org/sites/default/files/jaroma03200545640.pdf" rel="nofollow noreferrer">This article</a> in <a href="http://www.maa.org/pubs/cmj.html" rel="nofollow noreferrer">The College Mathematics Journal</a> gives a tighter upper bound for <code>n &gt;= 7022</code></p> <pre><code>p_n &lt;= n log n + n (log log n - 0.9385) (2) </code></pre> <p>This is a much tighter bound as the following table shows</p> <pre><code>n p_n approx 1 error% approx 2 error% 1 2 10 29 31 6.90 100 541 613 13.31 1000 7919 8840 11.63 10000 104729 114306 9.14 104921 0.18 100000 1299709 1395639 7.38 1301789 0.16 1000000 15485863 16441302 6.17 15502802 0.11 10000000 179424673 188980382 5.33 179595382 0.10 </code></pre> <p>I implemented my <em>n</em>th prime approximation function to use the second approximation for <code>n &gt;= 7022</code>, the first approximation for <code>6 &lt;= n &lt; 7022</code>, and an array lookup for the first 5 prime numbers.</p> <p>(Although the first method isn't a very tight bound, especially for the range where I use it, I am not concerned as I want this for a sieve, and a sieve of smaller numbers is computationally cheap.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload