# Some Properties and Algorithms for Twin Primes
## 2 Twin Primes  
This section is devoted to finding a method to generate twin primes. We start to observe that, except for 2, all prime numbers are odd numbers. For this reason, a prime number is necessarily of the type  
\[2k+1,\ \forall k\in\mathbb{N} \tag{2}\]\[2k-1,\;\forall k\in\mathbb{N}-\{1\}. \tag{3}\]  
From the previous relations (2) and (3), we have the following Table 1.  
It is trivial to observe, in the previous table, that there are values of \(k\) to which a pair of twins is associated. This occurs for values of \(k\) that generate a prime number in both columns. For example, for each value of \(k\) equal to 2, 3, 6, 9, 15, we achieve twin primes. We do not know by what rule \(k\) varies to return a prime number in the two columns, but we can understand when it generates a composite number. Recalling that the composite numbers are the product of two odd numbers different from 1, we have that the composite numbers of (2) are generated by the following product  
\[(2x+1)(2y+1)=2(2 xy+x+y)+1,\;\forall\;x,y\in\mathbb{N}. \tag{4}\]  
It is also possible to consider \((2x-1)(2y-1)\) with \(x,y\in\mathbb{N}-\{1\}\) achieving the same result. Therefore, we obtain a prime number in the second column, if and only if \(k\
eq 2 xy+x+y\). Instead, from (4), we deduce that a composite odd number of the second column of the table is generated by the following values  
\[k=2 xy+x+y,\;\forall\;x,y\in\mathbb{N}. \tag{5}\]  
Now, we consider \(x\) as a row and \(y\) as a column of a matrix. If \(x=1\), from (5) we have  
\[k=3y+1,\;\forall\;y\in\mathbb{N}.\]Therefore, in the first row we have 4, 7, 10, 13, \(\ldots\) and so on. If \(x=2\), the relation (5) is  
\[k=5y+2,\ \forall\ y\in\mathbb{N}.\]  
Therefore, in the second row we have 7, 12, 17, 22, \(\ldots\) and so on. It is easy to verify that the third row is \(k=7y+3\), the fourth is \(k=9y+4\) and so on. In conclusion, we can write the following infinite matrix  
\[A=\left( \begin{array}{cccccccccccc}4&7&10&13&16&19&22&25&28&31&34&\ldots\\ 7&12&17&22&27&32&37&42&47&52&57&\ldots\\ 10&17&24&31&38&45&52&59&66&73&80&\ldots\\ 13&22&31&40&49&58&67&76&85&94&103&\ldots\\ 16&27&38&49&60&71&82&93&104&115&126&\ldots\\ 19&32&45&58&71&84&97&110&123&136&149&\ldots\\ \ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots &\ldots\end{array} \right) \tag{6}\]  
All numbers that are not in \(A\) correspond to values of \(k\) which, when substituted in \(2k+1\), give us a prime number. They are infinite in number since there are infinitely many primes. Now, with the same reasoning, we deduce the law that generates composite odd numbers in the first column of the table. Indeed, the composite numbers will be  
\[(2x-1)(2y+1)=2(2 xy+x-y)-1,\ \forall\ x\in\mathbb{N}-\{1\},\ \forall\ y\in \mathbb{N}. \tag{7}\]  
Therefore, we obtain a prime number, if and only if \(k\
eq 2 xy+x-y\). We obtain a composite odd number if  
\[k=2 xy+x-y,\qquad\forall\ x,y\in\mathbb{N}. \tag{8}\]  
Like before, we built a matrix with \(x\) as row and \(y\) as column. If \(x=2\), the relation (8) becomes  
\[k=3y+2,\qquad\forall\ y\in\mathbb{N},\]  
achieving the sequence 5, 8, 11, 14, \(\ldots\) and so on. If \(x=3\), we have  
\[k=5y+3,\qquad\forall\ y\in\mathbb{N},\]  
obtaining the sequence 8, 13, 18, 23, \(\ldots\) and so on. It is easy to verify that the third row is \(k=7y+4\), the fourth is \(k=9y+5\). In conclusion, we can write the following infinite matrix  
\[B=\left( \begin{array}{cccccccccccc}5&8&11&14&17&20&23&26&29&32&35&\ldots\\ 8&13&18&23&28&33&38&43&48&53&58&\ldots\\ 11&18&25&32&39&46&53&60&67&74&81&\ldots\\ 14&23&32&41&50&59&68&77&86&95&104&\ldots\\ 17&28&39&50&61&72&83&94&105&116&127&\ldots\\ 20&33&46&59&72&85&98&111&124&137&150&\ldots\\ \ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots&\ldots &\ldots\end{array} \right) \tag{9}\]  
All numbers that are not in \(B\) correspond to values of \(k\) which, when substituted in \(2k-1\), give us a prime number. They are infinite in number since there are infinitely many primes.