Iterated polynomials modulo $p$ and divisibility properties

109 Views Asked by At

Looking around Math.SE, I found this interesting question about the compositeness of the product of a list of numbers (specifically primes) plus one. As the questioner points out there, this recursive application (starting after the first application) can also be represented by the polynomial $x(x-1)+1 = x^2-x+1$. Furthermore, a user comments that for inputs not congruent to $0,1 \mod 7$, this will always result in a composite number in a finite number of steps. One can easily see that $0$ and $1$ $\mod p$ for any prime $p$ will always be an exception.

An intuitive way to represent this mathematically is a graph structure that maps an input residue to its output residue and checking if there is a path from the input to zero (signalling compositeness for a certain residue class after exactly [path length] iterations). Let's call these residues "good". Let's also call residue systems for that every input ends up at zero "good systems".

Naturally, the first question to ask after looking at the comments is: Can we do "better"?.

Consulting Mathematica${}^*$ and looking at residue systems that maximize the relative amount of starting residues that eventually end up at zero, there is only one example within reasonable search space that hardly does any better ($\mod 139$ with $100$ good residues). I have gone beyond probably $p > 1400$ without having found a "better" prime $p$ with a ratio bigger than $\frac{100}{139}$ and my calculations regularly time out, which is why I am turning to this community in hopes of clever optimizations and bigger crunching power:

Is there a reasonably sized residue system for $x^2-x+1$ that has a larger amount of "good" residues relative to its size than $139$ with $\frac{100}{139}$?

EDIT: This question has been severly edited to split up/remove cluttering extra questions and (currently) unnecessary exposition. Sorry for that.

*Relevant Mathematica code:

PolyModRec[poly_,var_,mod_]:=Table[k \[DirectedEdge] Mod[poly /. var -> k,mod],{k,0,mod-1}]

1

There are 1 best solutions below

5
On BEST ANSWER

A search through the first thousand primes reveals the rock star $p=6469$, for which the proportion of good residues is $6413/6469 \approx 0.991343$. Indeed, the only non-good residues modulo $6469$ are: $\{0,1, 16, 20, 241, 305, 348, 381, 1128, 1135, 1145, 1380, 1658, 1717, 1720, 2019, 2155, 2184, 2264, 2454, 2463, 2562, 2857, 2872, 2977, 2978, 3026, 3137, 3143, 3327, 3333, 3444, 3492, 3493, 3598, 3613, 3908, 4007, 4016, 4206, 4286, 4315, 4451, 4750, 4753, 4812, 5090, 5325, 5335, 5342, 6089, 6122, 6165, 6229, 6450, 6454\}$

Based on this limit data I would certainly conjecture that there are good-residue proportions that are arbitrarily close to $1$. Indeed an optimistic conjecture would be that if we looked at the set of all such proportions, ranging over all primes, then its closure was all of $[0,1]$.

Clearly $0$ and $1$ are never good residues themselves; it's natural to wonder where there is a prime larger than $7$ for which those are the only two non-good residues. On the other hand, one could also conjecture that the number of non-good residues tends to infinity (even if the proportion itself can be close to $1$).