2

Is there a faster implementation of Prime[] available somewhere, already implemented by someone? (Maybe as a compiled routine?)

The default function in Mathematica is slow for large values, and does not work for very large values (greater than 10^12). I need a faster version that also works on very large values.

I'm aware that there are fast implementations of prime counting function (e.g. kimwalisch, c++) that can be then used to estimate and zero in Prime[n] for very large n. But, I'm wondering if this problem was already efficiently solved for Mathematica in the form of a new prime[n] routine?

Vepir
  • 622
  • 3
  • 11
  • 2
    This question is related to What is so special about Prime? where one can find further details (Prime is based on implementation of PrimePi), however since the version 12.1 these functions have been updated with possible choice of method. I should have update my question too since limits of the functions have changed. – Artes Jul 01 '21 at 14:32
  • Do you need exact answers or are approximations enough? Solve[LogIntegral[x] == 10^12, x] has a fractional error of about $10^{-7}$ compared to the exact answer Prime[10^12]. – Roman Jul 01 '21 at 16:19
  • @Roman Exact answer. – Vepir Jul 01 '21 at 16:26

0 Answers0