When we try to evaluate Prime
on big numbers (e.g. 10^13
) we encounter the following issue:
Prime[10^13]
Prime::largp: Argument 10000000000000 in Prime[10000000000000] is too large for this implementation. >> Prime[10000000000000]
Following this message, we can read in the documentation that the largest supported argument in Prime
is typically about $2^{42}$. With a kind of divide and conquer approach, we can figure out that the maximal argument of Prime
is:
OmegaPrime = 7783516045221;
1. What determines this number ? A hardware/software and/or conceptual/mathematical issue or maybe an arbitrary system cut-off ?
The problem seems to be a bit more obscure, since one encounters something like this:
Prime @ {# + 1, #, # + 1} & @ OmegaPrime
Prime::largp: Argument 7783516045222 in Prime[7783516045222] is too large for this implementation. >> {Prime[7783516045222], 249999997909357, 249999997909367}
(It takes more than two minutes to evaluate.)
An analog of OmegaPrime
is OmegaPrimePi
for PrimePi
:
OmegaPrimePi = 25 10^13 -1;
I can find even bigger primes with Prime
if I evaluate for example:
Select[Range[249999997909357, 25 10^13], PrimeQ] // Length
63142
Prime @ ( OmegaPrime + 63142 )
250000000000043
However I cannot evaluate PrimePi
for numbers greater than OmegaPrimePi
. It appears that Prime
has a dynamically extensible domain while PrimePi
does not.
2. How do I detect this property in advance from the system ?
I mean not to play around with e.g. Select[Range[a,b], PrimeQ]
, but for example to read it from Attributes
or anything else.
Primes
tag since M contains quite a good functionality in this field and there could appear many interesting and related questions. $\endgroup$Prime
callsPrimePi
many (namely, 1,013,381) times when given an argument of yourOmegaPrime
:nums = Reap[Internal`InheritedBlock[{PrimePi}, Unprotect[PrimePi]; pp:PrimePi[n_] /; (Sow[n]; True) := pp; Protect[PrimePi]; Prime[7783516045221]]][[2, 1]]; ListLogLogPlot[nums, MaxPlotPoints -> 1000, Joined -> True]
gives nearly a straight line. What this means, if anything, I have no idea, but it shows at least some concrete relationship between the two functions. $\endgroup$