Message Boards Message Boards

8
|
8070 Views
|
4 Replies
|
13 Total Likes
View groups...
Share
Share this post:

New Prime Oddity

Posted 8 years ago

Mathematicians Discover Prime Conspiracy mentions that primes with the same last digit tend to not follow each other.

Grid[Prepend[Transpose[Prepend[Partition[Last /@ Sort[Tally[Partition[Mod[Prime[Range[4, 1000000]], 10], 2, 1]]], 
     4], {1, 3, 7, 9}]], {"", 1, 3, 7, 9}]]  

Yep, that seems to be true.

       1     3        7          9
1   42853 58255   64230 84596
3   77475 39668   68595 64371
7   79453 72827   39603 58130
9   50153 79358   77586 42843
POSTED BY: Ed Pegg
4 Replies
Posted 8 years ago

This may or may not be a good place to drop my armchair math question, since it also involves apparent patterns related to primes.

I recently doodled with prime-generating polynomials of form x^2 + x + n. An approximation of these can be computed for odd values of n up to 200000 and checking values of x for each of them up to 20000 with the following piece of code (note that this code is here for reproducibility, not elegance):

ClearAll[abundances];

abundances = 
  ParallelTable[{a, #} &[
    Divide @@ 
     Sum[With[{n = i^2 + i + a}, {Boole@PrimeQ[n] Log[N@n]/2, 1}], {i,
        20000}]], {a, 1, 200000, 2}];

Beware, this code probably takes an hour or so to run. Smaller values may be a good starting point. Here I use Log as an approximation of the prime density function. It should be good enough for values these polynomials take.

How do the values of n and corresponding relative prime abundances plot out?

ListPlot[abundances, 
 PlotStyle -> Directive[PointSize[Small], Opacity[1/3]], 
 PlotRange -> {{0, 200000}, {1/6, 3 + 1/2}}, 
 Prolog -> {Opacity[1/6], 
   Line@Table[{u, v}, {v, 1/2, 3 + 1/2, 1/2}, {u, 0, 200000, 100000}],
    Line@Table[{u, v}, {u, 0, 200000, 1000}, {v, 0, 10, 1/16}]}]

enter image description here

The thing that catches my eye here is that this plot clearly has some structure. What is it? I can't tell.

To make these patterns more visible, I project the data in a rather convoluted manner. Note that the grid is the same:

With[{projection = {Sqrt[#1/#2^1.71], 
     CDF[MaxwellDistribution[0.9420730563157451], #2]} &}, 
 ListPlot[projection @@@ abundances, 
  PlotRange -> {{0, Sqrt[abundances[[-1, 1]]/3.5^1.71]}, {0, 1}}, 
  PlotStyle -> Directive[PointSize[Small], Opacity[1]],
  Ticks -> False, 
  Prolog -> {Opacity[1/3], 
    Line@Table[
      projection[u, v], {v, 1/2, 3 + 1/2, 1/2}, {u, 0, 200000, 
       100000}], 
    Line@Table[
      projection[u, v], {u, 0, 200000, 1000}, {v, 1/16, 3 + 1/2, 
       1/16}]}]]

enter image description here

Now those streaks (or patches) are very much visible. Can anyone explain what causes them? Are they actually artefacts of my approximation of prime abundance, or is there something real into it?

EDIT:

A bit wider plot to show that streaks continue to appear even after the rather narrow projected slice which was shown above:

enter image description here

POSTED BY: Jari Kirma

I am not convinced this is an unlikely distribution. I'll give a heuristic explanation below for why it seems plausible.

Note that in the range in question, the average gap between consecutive primes is 20 or so (at 10^9) and 16 or so at 10^7. Also note that for odd composites not equal to 5 mod 10, the most likely smallest divisors are 3 and 7. Suppose p and q are a pair of consecutive primes. We will look at the residues of p mod 3 and mod 7 to see what putative successors are ruled out due to divisibility by 3 or 7.

For p=1 mod 3, we know p+{2,5,8,11,14,17,20,...} are of necessity composite, since they are automatically divisible by 3. For p=2 mod 3, we similarly see that p+{1,4,7,10,...} are all composite. For p=1 mod 7 we rule out p+{6,13,20,...} from being also prime. p=4 mod 7 likewise rules out p+10 from being prime.

The upshot is that of 2*6=12 possible residue pairs (which I do assume are roughly equally distributed amongst primes), two pairs rule out both p+10 and p+20 due to each being divisible by 3 or 7, and ALL other residue pairs rule out either p+10 or p+20.

What about other possible successors in the expected range, that is p+2 or p+12, p+4 or p+14, p+6 or p+16, p+8 or p+18? The important observation is that none of these pairs are ruled out as frequently on grounds of divisibility by 3 or 7. For example, p+2 is ruled out by p=1 mod 3 and p=5 mod 7, but p+12 is only ruled out for p=2 mod 7 (the only way to eliminate it mod 3 is if p were 0 mod 3, making it composite to begin with). Likewise we have a deficit for p+6 (cannot be ruled out by any residue mod 3, p+18 (same situation), and p+14 (cannot be ruled out by any nonzero p residue mod 7). So there is only one residue pair (instead of two such) that rules out both p+2 and p+12, say. And there are SOME such pairs that do not rule out either one from being prime (p=2 mod 3 and p != 2 or 5 mod 7). A similar situation holds for the other three cases.

The result of this residue pair analysis is that for a given prime p, one or both values p+10 and p+20 are likelier to be divisible by 3 or 7 than is the case for p+{2,12}, p+{4,14}, p+{6,16} and p+{8,18}. This is a heuristic explanation but I think it gives some reason to expect a skew in the distribution of last digits of consecutive prime pairs at least until we hit expected gaps of fairly large size. Which seems to be in accord with actual computations from the literature.

--- edit ---

I include substantially more detail is in slides located here. This includes some amount of analysis that shows reasonable agreement with observed frequencies.

--- end edit ---

POSTED BY: Daniel Lichtblau

Here's some code that facilitates exploration of the ideas. The notion is that perhaps Machine Learning can be used to compute the next prime mod 3 from some sequence of preceding primes mod 3. The optional argument digitToCheck extends the idea to see whether one could predict the nth digit of the a prime from the nth digit of its predecessor primes. (all mod 3)

 cm[predecessors_Integer, trainingRange_: {4, 10000}, 
   testingRange_: {10001, 20000}, digitToCheck_: - 1] := 
  Module[{trainingData = 
     Map[Most@# -> Last@# &, 
      Partition[
       Map[IntegerDigits[#, 3][[digitToCheck]] &, 
        Table[Prime[i], {i, trainingRange[[1]], trainingRange[[2]]}]], 
       predecessors + 1, 1]], c, m},

   c = Classify[trainingData];
   m = ClassifierMeasurements[c, 
     Map[Most@# -> Last@# &, 
      Partition[
       Map[IntegerDigits[#, 3][[digitToCheck]] &, 
        Table[Prime[i], {i, testingRange[[1]], testingRange[[2]]}]], 
       predecessors + 1, 1]]];
   Sow[Association["Classifier" -> c, "ClassifierMeasurements" -> m, 
     "Predecessors" -> predecessors, "TrainingRange" -> trainingRange, 
     "TestingRange" -> testingRange]];
   m["Accuracy"]
   ]

And here are some preliminary experiments you can run:

 cm[1, {10000, 19999}, {50000, 
   59999}, -1](* just use immediate predecessor *)

 cm[2, {10000, 19999}, {50000, 59999}, -1](* two predecessors *)

 cm[3, {10000, 19999}, {50000, 59999}, -1](* three predecessors *)

 cm[1, {10000, 19999}, {50000, 
   59999}, -1](* training and testing data far apart *)

 cm[1, {20000, 29999}, {50000, 
   59999}, -1](* different training data far apart *)

 cm[1, {10000, 19999}, {50000, 
   59999}, -2] (* just use immediate predecessor but check whether the \
 second to last digit predicts *)

 cm[2, {10000, 19999}, {50000, 
   59999}, -2](* two predecessors but check whether the second to last \
 digit predicts*)
POSTED BY: Seth Chandler

Paul Abbott points out Distribution of the units digit of primes. Ko pointed out this behavior in 2002, and it was likely noticed before then.

POSTED BY: Ed Pegg
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract