On the density of primes of the form $X^2+c$

We present a method for finding large fixed-size primes of the form $X^2+c$. We study the density of primes on the sets $E_c = \{N(X,c)=X^2+c,\ X \in (2\mathbb{Z}+(c-1))\}$, $c \in \mathbb{N}^*$. We describe an algorithm for generating values of $c$ such that a given prime $p$ is the minimum of the union of prime divisors of all elements in $E_c$. We also present quadratic forms generating divisors of Ec and study the prime divisors of its terms. This paper uses the results of Dirichlet's arithmetic progression theorem [1] and the article [6] to rewrite a conjecture of Shanks [2] on the density of primes in $E_c$. Finally, based on these results, we discuss the heuristics of large primes occurrences in the research set of our algorithm.


Introduction 1.Density of primes
The prime number theorem states that prime numbers tend to get scarcer as they increase in size.However, the search for large primes, which are useful for cryptography, can be accelerated by reducing the definition set a priori (sieve methods, Mersenne numbers, etc.).
Here we study the density of primes in quadratic progressions.We will extensively use properties proved in [6].Finally, with a reformulated and stronger version of a conjecture by Shanks [2] on the density of primes in   , we describe an algorithm to generate large primes of fixed size, and study it empirically.

𝑥∈𝐸
. We also define the set of prime divisors:   () = () ∩ ℙ. 5-If  ⊂ ℕ * (generally a finite set of prime numbers), we denote the set of integers which are coprime with every element in  by ().6-For any integers (, ) ∈ ℤ × ℕ * we denote by {}  the remainder of the Euclidean division of  by .7-We define, for any  ∈ ℤ, the index () as the quotient of its Euclidean division of  by 2, i.e.:

Linear progression
The prime number theorem can be reformulated as an asymptotic density result.
The search for prime numbers is therefore doubly penalized, first by the fact that prime numbers are getting scarcer as they grow, and second because primality tests get more time-consuming.
It is therefore natural to look to increase this density by searching a smaller set than ℕ.A first approach is to look in arithmetic progressions, i.e. sets of the form  , .For these sets, we have Dirichlet's arithmetic progression theorem [1], generalized by Chebotarev's theorem [3]: Theorem 2.1.2:Let  be Euler's totient function.We have:  ℙ| , () ∼  () . 1 ln() whenever ,  are coprime.
As a result, no arithmetic progression contains only prime numbers, and these tend to get scarcer in  , at the same convergence rate as in ℕ.Nonetheless, it is relatively easy to find arithmetic progressions whose terms are all coprime with a finite subset  of ℙ.To do this, we just need to solve a system of congruences of the form:  ≡   [𝑝] for any  ∈ , with   coprime with .Solutions can be provided by the Chinese remainder theorem or by the normalizer method described in [10].They correspond to ∏ ( − 1) ∈ linear progressions with the common difference   ≔ ∏  ∈ .
Theorem 2.1.2applies to each of these linear progressions and moreover we identify (  ) = ∏ ( − 1) ∈ .The asymptotic density of primes conditional to each of these progressions, hence also conditional on their union (), is therefore: ℎ  ln() with: The asymptotic density given by the prime number theorem therefore increases by the multiplicative factor ℎ  , which can theoretically be chosen as large as desired due to the known divergence of ∑ 1  ∈ℙ , which implies: In ℕ, the asymptotic density of () is 1 ℎ  .Dirichlet's theorem can therefore be formulated as an independence result: It is in this context that « basic » sieving is used to determine primes, i.e., eliminating multiples of primes as they are found.This method will be referred to as « Sieve 1 » in this article.We also notice that primality tests are simplified in this case by the fact that by construction, elements of  cannot be divisors of any element in ().

Remark 2.1.1:
The search for prime numbers of the form  +  and of fixed size  can be performed in two ways: -Either by choosing  of size  and varying  between 0 and    ⁄ .-Or by choosing  and  of size strictly less than  and looking for  of size  − ().
In the first method, as  changes with the desired size , it is difficult to give an asymptotic result.
The second method consists in searching for  ∈ [ −()−ln (10) ,  −() ) thus, according to Dirichlet's theorem, for  ≫ 1 the density in the search interval will be

.
We will only focus on the first method.
The determination of primes in   can be performed with a sieve method based on modular arithmetic as described in [6].The density of residual primes in   is bounded by that of the non-multiples of the primes already known, which can be computed using the following proposition: Proposition 2.2.1b:The asymptotic density of elements in   coprime with  ⊂ ℙ ∖ {2} is given by: Proof: This is a consequence of the number of square roots of − modulo  and the Chinese remainder theorem.It also yields perfect equality for multiples of   : The sieve described in [6] will be referred to as « Sieve 2 » henceforth.Proof: In [6], we showed that for each divisor  1 ∈ (  ), there are at least two arithmetic progressions of indices generating multiples of  1 given by: We also have . By substituting  = 2 +  in  2 + , we get the two quadratic progressions (with the same first term): Finally, as the polynomial  2 +  has no real root, the same applies to  ↦ 4 ( 1  ±   1 , (0)) +   1 , .It therefore corresponds to an irreducible element of ℤ[] if and only if its coefficients are coprime, and since   1 , is odd, this is equivalent to: Proposition 2.2.2b2:Let  ∈ (ℬ  1 ,, ) and  0 the smallest integer such that: For any element  = 4 ( 1  +   1 , (0)) +   1 , of ℬ  1 ,, ∩ ℤ, there exists a divisor  of  and integers ,  ,, (0) and  such that: Proof: Assume that  divides 4 ( 1  +   1 , (0)) +   1 , .We can then write: Thus there is a factorization  =  such that | −  0 and | 1 ( +  0 ) +   1 , (0), i.e.
The system then has solutions if and only if: This can be rewritten as follows: Under these conditions, the remainder of  modulo Proof: The existence conditions of ( ,, ()) are as follows.
For  = , all these conditions are trivially verified, and the common difference of the progression obtained is Equivalently, ℬ ,, contains infinitely many primes for at least one value of .
Below we present some empirical results for  = 1.We take  ≔ 5 ∈  1 .We then obtain  The evolution of the number of elements of ℬ 5,1, in ℙ () is of the same form as those of  1 , i.e.   ,  > 0, which we studied in [6] and subsequently corroborated Landau's conjecture (namely the infinity of ℙ ∩  1 ) and more generally Shanks' conjecture.Here we extend this conjecture; that is, we conjecture that ℬ 5,1,1 ∩ ℙ is infinite.Similar results were obtained for  = −1 as well as for all divisors and all values of  ≥ 1 studied.
In this section, we propose to rewrite Shanks' conjecture [2] with the properties of this article and [6], and more precisely with "Sieve 1" and "Sieve 2".

Explanation:
The proof that the infinite product defining ℎ  converges is given in [9].When  ∈ (), we have   = 1 which gives a factor equal to 1, so we can exclude these values from the calculation of ℎ  .The equality is immediate since the prime divisors of   are the  such that − is a quadratic residue modulo .
We estimated ℎ  for  ∈ {1,3,5} by truncating the product to primes less than 4.10 6 , using the algorithm from [6] to compute   .The estimated values of ℎ  for  ∈ {1,3} are close to those supplied by Shanks [2]: We also know that for any  prime with   , we have: Moreover, () consists of a finite number of arithmetic progressions with common difference   on , so we also have: By conjecturing an "independence" between   and () when  tends towards ℙ, we obtain the following result: This conjecture combines thus both "Sieve 1" (or Dirichlet's arithmetic progression theorem) and "Sieve 2".
According to this conjecture, it would be interesting a priori to look for values of  such that ℎ  is large to increase the asymptotic density of primes in   .Remark 3: A generalized "independence" conjecture would also make it possible to extend Shanks' conjecture to the subsets of   studied in Part 2, for instance to calculate  ℙ|  ∩() (), or as in the following hypothesis: Hypothesis 1: The Shanks hypothesis applies to sets ℬ  1 ,, when it corresponds to an irreducible quadratic progression.
For the rest of the article, we will use a stronger version of Shanks' conjecture: Remark 4: Determining the number of primes of the form  2 +  for  ∈ ⟦0, √⟧ will thus provide an approximation of ℎ  when  is large, uniformly in .Furthermore, in proposition 2.2.1a, we showed that integers  such that  ∩   (  ) = ∅ are given by progression () = 2   + (0).With  ≥ 1 fixed, the size of () is equal to (2  ) which allows us to define the same size for a finite number, equal to , of values of .
With hypothesis 2, we can thus obtain a prime density arbitrarily close to ℎ  /  , over an interval of values of  as large as we wish.

Solving systems of congruences on c
In this section, we present properties around solving a system of linear congruences on c ensuring that  ∩   (  ) = ∅,, where  is a finite set of primes.We will link values of  of opposite parity.These properties will be used in the algorithm determining the set of even and odd values of .We recall that according to the proposition 2.2.1a, there exist infinitely many integers , Proof: This is another consequence of the Chinese remainder theorem.Since   is odd, each congruence class modulo   has exactly one even and one odd representative between 0 and 2  − 1.For any  ∈ ⟦1,   ⟧ there exists a unique  ′ ∈ ⟦1,   ⟧ such that  ,1, =  ,0, ′ +   [2  ].
We now try to impose the smallest prime divisor  1 =   of   .To do this, let  = { 1 …  −1 } and we look for  in  , ∩     .We note that   1 , (0) depends only on the class of  modulo  1 , and can therefore be determined a priori.
which yields the result.
We now explain how to solve the Diophantine equations that determine   and  ̃1 with limited use of the modulo operator.
We focus on the case of   , as the extension to  ̃1 does not present any difficulty.We write  = { 1 …   }.By recurrence, we reduce the problem to the successive solution of the system, for  going from 0 to  − 1: for all values of  ∈   +1  and  ∈   () .
We fix ,  and we set  =  − .If we have (, ) such that: (1.3)  +1  − 2  ()  =  the solution is then: If (, ) is a solution for  = 1 (Bézout coefficients), then we have: This leads to the proposition below, which gives the set of values   .Furthermore, the pre-calculation of ( 0 −   ) modulo  +1 limits the use of the modulo operator in the algorithmic implementation of (3.3).

Presentation of the algorithms
We present a first algorithm that maps  1 ∈ ℙ to values of  such that  1 = min   (  ).
The index   1 , (0) = min is also returned.The results of the previous parts allow us to crucially reduce the number of computations to determine the set of even and odd solutions .In this algorithm, we first compute   () ,0 with the proposition 4.2, for  = 1 … .Then we compute the pairs (,   1 , (0)) for  ∈  ̃1 ,0 .The pairs (,   1 , (0)) for  ∈  ̃1 ,1 are then obtained by the proposition 4.1 and remark 4.1.

ALGORITHM 1 [EL1]:
A general description of the algorithm is given here: ➢ The inputs to the algorithm are  1 and the number of values of  to be returned.➢ The first step initializes the variables and arrays.Then, for each prime   ∈ { 1 , … ,   =  1 }, the second and third steps are performed.
➢ The second step calculates the quadratic residues and nonresidues of   .Then,  is then calculated by solving (1.3) for  = 1.The values of ( 0 −   ) modulo   are then precalculated (Remark 4.2).➢ The third step calculates the elements of   () ,0 by recurrence on  = 1 …  − 1, and finally  ̃1 ,0 .➢ The last step calculates all the pairs (,   1 , (0)) to be returned, with  ∈  ̃1 .Algorithm 1 is exhaustive and thus performs poorly when  1 is large.The search for one or a few pairs for  1 = 115 140 317 requires a faster algorithm, we thus need to relax the exhaustivity target.For this value of  1 , we have  = 6 580 238 primes to process and the number of digits in c is comparable to that of the primorial  1 #, i.e.   is of the order of 50 000 006.We propose a second algorithm that computes just one quadratic nonresidue for each value of  <   , using a seed .

ALGORITHM 2 [EL2]:
A general description of the algorithm is given here: ➢ The inputs to the algorithm are  1 , the number of values of  to be returned, that has to be not greater than , and the seed  for calculating the quadratic residue.
➢ The first step initializes the variables and tables.➢ The second step can be run in parallel.For each prime number   , the primorial   # is calculated, followed by  (Remark 4.1).Then, we search for a quadratic nonresidue ) = −1 and we retain  = −4 2   mod   for the second equation in (  ).When   ≡ 3 [4] we choose   = −1, when   ≡ 5 [8] we choose   = 2 otherwise we test the primes 3 ≤  <   and choose the first quadratic nonresidue.➢ The third step calculates the quadratic residues of  1 and performs the precalculations described in Remark 4.2.

Results
In this section, we fix  1 ∈ ℙ and generate some odd values of  such that  1 = min   (  ).
The primes of   are of the form (, ) =  +  2 ,  ∈ 2ℕ.To obtain a prime of the same size as , we impose  ≤ √.We approximate the value of ℎ  by ℎ  () =   ln(10)  ℙ|  (), which is valid if one admits hypothesis 2 (uniform version of Shanks' conjecture).The asymptotic density of primes in   is denoted by   () =  ℙ|  ().For   the strongest value of  used in a set of results, we let simply ℎ  = ℎ  (  ) and   =   (  ).
We will first present the evolution of the value of ℎ  and   as a function of the three parameters studied: -the value of  1 , -the value of   1 , (0), -the size of .
We will then study the distribution of primes in   in an interval corresponding to  ∈ ⟦0,4  ⟧.Finally, we will show the interest of this method in cryptography for determining large primes.

Logarithmic evolution of hc as a function of q1
Remark 3 in section 3 allows us to estimate the asymptotic density   and the value of ℎ  from the number of primes of   over the interval corresponding to  ∈ ⟦0, √⟧.For practical reasons, we restrict ourselves to the interval  ∈ ⟦0, 4. 10 7 ⟧.
Using Algorithm 1, we have calculated values of  for values of  1 such that 18 ≤   1 # ≤ 2001, yielding √ > 4. 10 7 .We will first present the calculation of the estimated values of ℎ  and   as well as the convergence of ℎ  .We will then show the evolution of ℎ  and   as a function of  1 , which will allow us to estimate the number of primes in a fixed interval regardless of  1 .Next, we show that ℎ  depends only weakly on   1 , (0) and the size of .
The asymptotic density   also depends only weakly on   1 , (0), but decreases with the size of , as per conjecture 2.
Graph 3 presents the evolution of ℎ  and   when  1 varies.More precisely, we used the first value of  such that   1 , (0) = 0 given by Algorithm 1 to calculate ℎ  and   .The numerical results are given in [EL3].
In table 1, the regressions ℎ  ( 1 ) and   ( 1 ) are given for both limit values of   1 , (0) ∈ {0, ( 1 − 1) 2 ⁄ } with the correlation coefficient.The value of ℎ  increases logarithmically with the value of  1 while the density   decreases.We notice that ℎ  is in a relative range of ± 1.5% around its average value.This weak variation of ℎ  = ∏ −  () −1 ∈ℙ∖{2} can be explained by the fact that   (()) =   ((0)) for any  ≤  1 .Although for the primes  >  1 we cannot predict the value of   (()) we note that their cumulated effect on ℎ () seems weak.
The results of this section show that ℎ  mainly depends on  1 while parameters   1 , (0) and   only weakly impact it.

Distribution of primes
In this section, we study the distribution of primes in   for  varying in ⟦0,4  ⟧.The purpose is to heuristically predict the minimal range where a prime number can be found.We use the same notations as in the previous section.The results below were obtained with  1 + 1 pairs, more precisely with 2 different values of  per value of   1 , (0).Furthermore, to have a constant size for all values of  with  1 fixed,  was always chosen between  1 #  ℎ  .
We will first show that for all the pairs, the prime numbers of { 2 + ;  ∈ } are distributed in similar quantities, for intervals  forming a regular subdivision of  1 .Then we will show that   is close to its equivalent value given in remark 5.2.Finally, we will show that the proportion of pairs for which there exists at least one prime number in the interval   increases with the value of  1 .
For  1 = 727, we studied 728 pairs of values verifying   = 301.The value of ℎ  estimated in the previous section of 5.9860 allows us to estimate  1 ≃ 10.39.Table 2 gives the number of primes in a regular partition of ten subdivisions, and the average number of primes.We notice that the prime numbers are distributed approximately uniformly in each interval within a relative tolerance of 9.5%.We define the density of   () as the percentage of pairs of values for which the number of primes is  in the same interval   .The graph 6 shows it for  = 1 and  = 2.For  1 = 727, the densities peak at ⌊ 2 ⌋ = 5 and ⌊ 1 ⌋ = 10.These results generalize experimentally as soon as  1 ≥ 251, even when shifting the interval   .
These results suggest that the density of   over all the pairs is regular.The peak of the distribution is located around the equivalent of   provided by remark 5.2.For all pairs studied, there is at least one prime in  1 .When  > 1, some pairs no longer have one in   .Graph 7 shows, however, that this tends to disappear when  1 increases.The These results suggest that as  1 increases, the search for large primes can be performed in an interval of proportionally smaller size, which can be achieved by selecting a higher value of .Note: As  1 increases, the estimated value of ℎ  depends less and less on the values of  and   1 , (0) used.For example, for  1 varying from 131 to 1193, the deviation from the mean of the estimates goes from ± 6.5%. to ± 1.5%.

Application to cryptography
The main general public cryptography systems use large prime numbers to secure communications and access data through encryption and decryption operations.These operations use a pair of keys generated from two large prime numbers, the binary size of which is given: 2048, 4096, 8192, etc.
Security is based on the existence of many primes and the difficulty of finding the two prime numbers used to generate a pair of keys.
In this article, the method described allows to find many primes of a given size  by calculating values of  with parameters  1 and   : - 1 is chosen so that  1 # has a size comparable to the objective, -one remainder of  modulo  1 # is computed, -the desired size   can then be obtained by adding a multiple of  1 # to that remainder.
For  1 =   fixed, the theoretical number of congruences is . The number of primes in the corresponding sets   , denoted by ( 1 ), can be approximated by the number of congruences multiplied by the asymptotic density given by the conjecture 2: This method therefore seems to meet the requirements of cryptography.
Note: The factor 10   2 is for eliminating redundant primes generated by the method, due to the fact that a prime generally belongs to several sets   .We will not study collisions further in this article.
In table 3, we present the average computation time to obtain 2 primes of a given size in bits.Algorithm 2 was used to compute  congruences.The search was performed for  = 4 using 100 pairs of values (,   1 , (0)).The calculations were performed on a laptop with an Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz, and parallelized over 10 threads.This method is also applicable to the search for very large primes, i.e. numbers much larger than those used in cryptography.With  1 = 115 631 and   1 , (0) = 0, we determined 2 prime numbers with 50 001 digits [EL5] of the form  2 +  such that () <   2 ⁄ .To determine larger primes, the primality tests would have to be spread over a large number of computers or a supercomputer.
We also calculated (0) for  1 = 57 571 307 (respectively  1 = 115 140 317) and   1 , (0) ∈ ⟦0,8⟧, which should allow obtaining primes with more than 25 million digits (respectively 50 million digits).These values are presented in [EL6].The number of primes in   for  = 2, which is estimated with the relation () in table 1, would then be expected around 13 (respectively 14).For one billion digits, we could keep increasing  1 or add 10 95.10 7 . 1 # to the second congruence.In the second case, the number of primes would still be expected to be around 14 in   for  = 2.

CONCLUSION
We have determined a method for obtaining large primes from the study of the density of primes of the form  2 + .To this end, we presented a method that consists in fixing the smallest prime divisor of   .Furthermore, with a uniform version of Shanks' conjecture [2] we showed that the asymptotic density  ℙ|  (√) of primes in   ∩ [0,2] is given by:  ℙ|  (√) ∼ →+∞ 1 ln (10) .
Finally, we showed that ℎ  grows logarithmically with  1 = min   (  ), which allows us to search for primes in   for smaller and smaller values of  relative to   .We have thus shown that quadratic forms can be used in cryptography to determine large primes of a fixed size, as well as very large primes.

Remark:
The pairs (,   1 , (0)) were obtained using the[EL1] or[EL2] algorithm, implemented in C# and compiled with Microsoft Visual Studio 2019.The number of primes in finite subsets of   was counted using the isprime function in Maple 2022.Each value of  1 corresponds to an infinite number of pairs (,   1 , (0)).The pairs with which the results presented in this article were obtained are available in [EL3] and [EL7].The numerical series corresponding to the graphs are available in [EL3] and [EL4].
= (  ) [6]  = 1 − {} 2 .In[6], we characterised multiples in   of the numbers  ∈   (  ) by showing that their index () = ( − ) 2 ⁄ follows one of two arithmetic progressions:As in section 2.1, let  be a subset of ℙ ∖ {2} (we note that by construction, 2 never divides any element in   ).The following proposition characterises the values of  such that   (  ) contains no element of : There exists an infinite number of integers  of fixed parity such that  ∩   (  ) = ∅, which corresponding to ∏ The desired property on  is true if and only if for any  ∈  and  ∈ ℕ,  2 ≢ − [], to which we must add the parity condition.The search for prime numbers of the form  2 +  and of fixed size  can also be performed in two ways:-Either by choosing  of size  and varying  between 0 and √.-Or by choosing  of size less than  and looking for  of size +  In this section, we are interested in the set   = { 2 + ,  ∈ 2ℤ + } where  ∈ ℕ * Proof:
[7]have   (ℬ  1 ,, ) ⊆   (  ) and for any prime divisor  that is not a divisor of  1 , we have as many dual progressions of multiples of  in the set ℬ  1 ,, as in the set   , i.e.   progressions in both sets.Proof: If  prime, there are   dual sequences in   .But if  is prime with  1 , since ℬ  1 ,, corresponds to an arithmetic progression with the common difference  1 on , by the Chinese remainder theorem, it must have the same number of arithmetic sub-progressions with the common difference  (prime with  1 ) corresponding to multiples of .If  1 and  are coprime, any progression ( ,, ( ′ )) of indices of   corresponds to a sequence of ℬ  1 ,, of the same constant asymptotic density.Proof: Since  1 is coprime with , it is also coprime with the common difference of the arithmetic progression  ,, ( ′ ), and as stated in proposition 2.2.2b1,ℬ  1 ,, corresponds to an arithmetic progression of indices with common difference  1 .The Chinese theorem yields that ℬ  1 ,, thus contains terms corresponding to ( ,, ( Since ℬ  1 ,, consists of divisors of elements of   , we clearly have   (ℬ  1 ,, ) ⊆   (  ).Corollary 2.2.2b3 states that, if  ∩   ( 1 ) = ∅, lim  ′ .If  ′ is also disjoint from   ({ 1 }), there are exactly ∏ ( −   ) The terms of ℬ  1 ,, that are multiples of  ∈  ′ are given by an equation of degree 2 on the index, which therefore has at most two solutions.If we assume additionally that  does not divide  1 , corollary 2.2.2b3 yields that the number of solutions is exactly   .We conclude as usual with the Chinese remainder theorem, and the strict inequality comes simply from the observation ∏ ( −   ) It is possible to generalize remark 1 to this case.In[7]it was shown that there are infinitely many pairs of primes (, ) ∈   (  ) ×   (  ) such that (, ) =  ∈   .Below we present a hypothesis on the infinity of pairs of primes (, ) with  fixed.Let  ∈   (  ) such that  not divide .There are infinitely many  ∈   (  ) such that  ∈   .

Table 3 :
Calculation time per couple of primes found.