There is no simple rule between the prime number p_n and the next prime number p_{n+1} that cannot be predicted. Similarly, the interval between the twin prime number Tp_n and the next twin prime number Tp_{n+1} cannot be predicted. Considering two twin primes as a set of four primes \{p_{m1},p_{p1},p_{m2},p_{p2}\}, it can be described as Tp_1=\{p_{m1},p_{p1}\} and Tp_2=\{p_{m2},p_{p2}\}.
Here, it is assumed that there are no other twin prime numbers between Tp_1 and Tp_2. The difference between p_{m2} and p_{p1} is defined as "{\rm interval}". When the first prime number p_{m1} is specified, the other three prime numbers are defined by equation (1).
Look at the following graph.
The horizontal axis of this graph is the β{\rm interval}β (=p_{m2}-p_{p1}) of the twin prime Tp_1 and the next twin prime Tp_2. The vertical axis is the frequency of occurrence, and the parameter is approximately 61000. What you can see in the graph is the fact that there is a solution only if the β{\rm interval}β is 4,10,16,22,?. In the case of 6,8,12,14,? there is no solution. I will omit the explanation, but this is because one or both of Tp_2 is not a prime number depending on the condition of equation (1). (the sum of odd and odd numbers is even, multiples of 3 are involved)
Here we introduce a variable r representing β{\rm interval}β. In equation (2), r takes an integer value only when β{\rm interval}β is 4,10,16,22, ?.
The purpose of this report is to give r an β{\rm interval}β and search for a set of twin primes that satisfy that condition. Twin prime numbers can be determined by the following four equations.
Give the same integer n to these four equations (3). When there is no integer solution for s and m, a twin prime is born from the integer n.
When there are no integer solutions in s and m, n in equation (3) is written as n_t. Using n_t, twin primes are given by equation (4).
The following program inputs n and r and searches for a set of twin primes that satisfy the specified β{\rm interval}β. Note that β{\rm interval}β=6r-2 from equation (2).
n = 1;
r = 2;
Clear[nt1, nt2, nt3, pm1, pp1, pm2, pp2, pmr, ppr, intr, int1, int2];
n1 = n;
n2 = n + 1;
nr = n + r;
If[n > 0 && IntegerQ[n] && r > 0 && IntegerQ[r],
Do[
Do[func[n1];
If[func[n1] == {{}, {}, {}, {}}, nt1 = n1, nt1 = 0]
If[func[n1] == {{}, {}, {}, {}}, Break[]], {n1, n1, n1 + 100}];
Do[func[n2];
If[func[n2] == {{}, {}, {}, {}}, nt2 = n2, nt2 = 0]
If[func[n2] == {{}, {}, {}, {}}, Break[]], {n2, n2, n2 + 100}];
Do[func[nr];
If[func[nr] == {{}, {}, {}, {}}, nt3 = nr, nt3 = 0]
If[func[nr] == {{}, {}, {}, {}}, Break[]], {nr, nr, nr + 100}];
pm1 = 6*nt1 - 1;
pp1 = 6*nt1 + 1;
pm2 = 6*nt2 - 1;
pp2 = 6*nt2 + 1;
pmr = 6*nr - 1;
ppr = 6*nr + 1;
intr = 6*r - 2;
int1 = pm2 - pp1;
int2 = pmr - pp1;
n1 = n;
n2 = n + 1;
nr = n + r;
If[int1 == intr && int2 == intr, Break[]], {n, n, n + 100}];
Print["====== The calculation results are shown below. ======"];
Print["n= ", n];
Print["r= ", r];
Print["Specified interval(6*r-2)= ", intr];
If[int1 == intr && int2 == intr && nt1 > 0,
Print["n selected= ", nt1], Print["n selected= -- "]];
If[int1 == intr && int2 == intr && nt1 > 0,
Print["Twin prime(1)= ", {6*nt1 - 1, 6*nt1 + 1}],
Print["Twin prime(1)= There are no twin primes in the interval,at \
(n)~(n+100)."]];
If[int1 == intr && int2 == intr && nt2 > 0,
Print["Twin prime(2)= ", {6*nt2 - 1, 6*nt2 + 1}],
Print["Twin prime(2)= There are no twin primes in the interval,at \
(n)~(n+100)."]];
If[int1 == intr && int2 == intr && nt1 > 0 && nt2 > 0,
Print["interval(pm2-pp1)= ", int1], "interval(pm2-pp1)= --"];
If[int1 == intr && int2 == intr && nt1 > 0 && nt2 > 0,
Print["PrimeQ[(1),(2)]= ", {{PrimeQ[6*nt1 - 1],
PrimeQ[6*nt1 + 1]}, {PrimeQ[6*nt2 - 1], PrimeQ[6*nt2 + 1]}}],
Print["PrimeQ[(1),(2)]= {{--,--},{--,--}} "]];
If[int1 == intr && int2 == intr && nt1 > 0 && nt2 > 0,
Print["If you want to find the next twin prime, start with n= ",
nt1 + 1],
Print["If you want to continue, start with n= ", n + 101]],
Print["***** ! Please enter a positive integer. *****"]];
"********************************************************";
func[n_] :=
Module[{dat1, dat2, dat3, dat4},
dat1 = FindInstance[
6*s1^2 + (6*s1 - 1)*(m1 - 1) == n && 0 < s1 && 0 < m1, {s1, m1},
Integers];
dat2 = FindInstance[
6*s2^2 + 6*s2 + 1 + (6*s2 + 1)*(m2 - 1) == n && 0 < s2 &&
0 < m2, {s2, m2}, Integers];
dat3 = FindInstance[
6*s3^2 - 2*s3 + (6*s3 - 1)*(m3 - 1) == n && 0 < s3 && 0 < m3, {s3,
m3}, Integers];
dat4 = FindInstance[
6*s4^2 + 2*s4 + (6*s4 + 1)*(m4 - 1) == n && 0 < s4 && 0 < m4, {s4,
m4}, Integers]; {dat1, dat2, dat3, dat4}]
"********************************************************";
This is an example where n=1 and r=2. Since β{\rm interval}β=6r-2=10. The calculation result is as follows.
====== The calculation results are shown below. ======
n= 1
r= 2
Specified interval(6*r-2)= 10
n selected= 3
Twin prime(1)= {17,19}
Twin prime(2)= {29,31}
interval(pm2-pp1)= 10
PrimeQ[(1),(2)]= {{True,True},{True,True}}
If you want to find the next twin prime, start with n= 4
The calculation result shows the input values n=1 and r=2. It shows that r=2 to {\rm Specified\ interval} \;(6r-2) = 10. The search starts from n=1 and the solution is found with n\; {\rm selected} = 3. This shows that the two twin primes obtained as a solution are {\rm Twin \,prime}\; (1) = \{17,19\} and {\rm Twin \,prime}\; (2) = \{29,31\}. It is judged by {\rm PrimeQ}\; [(1), (2)] that the four numbers are indeed prime numbers. Finally, it indicates the next n to start when continuing the search. One search interval is in the range of n to (n+100). If no solution is obtained within the interval, n for searching beyond is also displayed here.
If r=1 here, β{\rm interval}β = 4. In this case, it will be the same as " Search \;for \;consecutive \;twin \;primes " described in the previous report.
In writing this program, I used {\rm Module}\; [] and {\rm func} [n {\text \_}]: = for the first time. Thanks to Claudio-san and William-san for teaching us.
The following table shows two calculation examples. {\rm Table} \,1 is an example of r = 1, ie β{\rm interval}β = 6r-2 = 4, and {\rm Table} \,2 is an example of r = 5, ie β{\rm interval}β = 6r-2 = 28. In both cases, the search was started from n=1, and 50 sets of the selected n and the two pairs of twin primes that were the solutions were recorded.
.
.
