58

9

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.

14I love the questions people come up with. +1 – Mr.Wizard – 2012-03-21T22:53:50.983

1@Mr.Wizard Thanks for your support. I really have many questions but not too much time to formulate them. – Artes – 2012-03-21T22:57:21.213

2Really a nice question. I doubt any answer (and I have none) will deserve more upvotes than the question. – Dr. belisarius – 2012-03-22T00:36:39.517

1@belisarius Thank You ! I believe there is a need for

`Primes`

tag since M contains quite a good functionality in this field and there could appear many interesting and related questions. – Artes – 2012-03-22T00:48:03.670One should certainly not expect

`Attributes`

to answer such a question, as that function deals with various general-type properties. My guess is that the only possibility beyond experimentation is looking at the documentation. And if that doesn't help, ask Wolfram tech support. – murray – 2012-03-22T00:55:12.163@murray I gave

`Attributes`

here only for instance of what one could expect since I had checked this before and it hadn't enlightened me more. – Artes – 2012-03-22T01:01:38.1607An interesting observation is that

`Prime`

calls`PrimePi`

many (namely, 1,013,381) times when given an argument of your`OmegaPrime`

:`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. – Oleksandr R. – 2012-03-22T03:19:17.850@OleksandrR. There is an obvious mathematical relationship between these functions : they are "almost" inverse, I mean e.g. :

`Prime@PrimePi@Range[101, 105]`

returns 'Range[101, 105]`, i.e. identity, but not`

PrimePi@Prime`. There are also some issues of their internal implementations which are certainly more obscure. – Artes – 2012-03-22T09:11:54.770