
Primality test and primes enumeration using odd numbers indexation WOLF Marc, https://orcid.org/0000-0002-6518-9882 WOLF François, https://orcid.org/0000-0002-3330-6087 Independent researchers; [email protected] ; [email protected] April 5th, 2020 ABSTRACT Odd numbers can be indexed by the map 푘(푛) = (푛 − 3)⁄2 , 푛 ∈ 2ℕ + 3. We first propose a basic primality test using this index function that was first introduced in [8]. Input size of operations is reduced which improves computational time by a constant. We then apply similar techniques to Atkin’s prime-numbers sieve which uses modulus operations and finally to Pritchard’s wheel sieve, in both case yielding similar results. Keywords: odd number index, primality test, primes enumeration, Atkin sieve, composite odd numbers, wheel sieve. CONTENTS 1 INTRODUCTION ............................................................................................................................................. 2 1.1 PRIMALITY TEST AND PRIME ENUMERATION ............................................................................................................ 2 1.2 NOTATION ....................................................................................................................................................... 2 2 BASIC PRIMALITY TEST AND PRIMES ENUMERATION .................................................................................... 3 2.1 TWO FAMILIES OF INFINITE SEQUENCES WITH ARITHMETIC DIFFERENCE ......................................................................... 3 2.2 BASIC PRIMALITY TEST ........................................................................................................................................ 4 2.3 PRIMALITY TEST WITH INDICES .............................................................................................................................. 5 2.4 FIRST ALGORITHMS OF PRIME ENUMERATION .......................................................................................................... 5 2.4.1 Primality test using numbers ................................................................................................................ 5 2.4.2 Primality test using infinite sequences and indices ............................................................................... 8 2.5 PERFOMANCE OF THE ALGORITHMS ..................................................................................................................... 11 3 THE SIEVE OF ATKIN .................................................................................................................................... 13 3.1 ATKIN ALGORITHM ........................................................................................................................................... 13 3.2 ATKIN ALGORITHM WITH INDICES ........................................................................................................................ 16 3.3 PERFORMANCE OF ALGORITHMS ......................................................................................................................... 19 4 WHEEL SIEVE WITH INDICES ........................................................................................................................ 20 4.1 DESCRIPTION OF PRITCHARD’S WHEEL SIEVE ......................................................................................................... 20 4.2 INDEX WHEEL SIEVE .......................................................................................................................................... 21 1 4.3 WHEEL SIEVE ALGORITHMS ................................................................................................................................ 24 4.4 PERFORMANCE OF ALGORITHMS ......................................................................................................................... 25 5 CONCLUSION .............................................................................................................................................. 26 6 REFERENCES ................................................................................................................................................ 26 7 APPENDIX: ALGORITHM OF THE INDEX WHEEL SIEVE ................................................................................. 27 8 APPENDIXES: MAPLE REGRESSIONS ............................................................................................................ 31 1 Introduction 1.1 Primality test and prime enumeration An odd number 푛 is prime when it is not divisble by any prime 푝 lower than or equal to √푛. This basic primality test requires too much computational time for large integers. Faster and more efficient deterministic and probabilistic primality tests have been designed for large numbers [1]. A deterministic polynomial primality test was proposed by M. Agrawal, N. Kayal and N. Saxena in 2002 [2]. Enumeration of primes up to a given limit can be done by using a primality test but prime number sieves are preferred from a performance point of view. A sieve is a type of fast algorithm to find all primes up to a given number. There exists many such algorithms, from the simple Erastosthenes’ sieve (invented more than 2000 years ago), to the wheel sieves of Paul Pritchard ([3], [4], [5]) and the sieve of Atkin [6]. In [7], Gabriel Paillard, Felipe Franca and Christian Lavault present another version of the wheel sieve and give an overview of all the existing prime-numbers sieves. In theory, indices are a way to represent odd numbers. By adapting results from [8], we show how odd number indices may be used in applied mathematics. In the last part, we apply [8] to Pritchard’s wheel sieve, which leads to a 푑푦푛푎푚푖푐푎푙 wheel sieve. Using the linear diophantine equation resolution method first introduced in [9], we introduce an original way of “turning the wheel”. 1.2 Notation We will use the following notations: 1. 퐼 designates the set of odd integers greater than 1, i.e.: 퐼 = {푁푘 = 2푘 + 3|푘 ∈ ℕ}; 2. 푃 the set of prime numbers, 푃푛 the set of prime numbers not greater than 푛; 3. 퐶 the set of composite odd integers, i.e.: 퐶 = 퐼\푃 = {푁푘 ∈ 퐼|∃(푎, 푏) ∈ 퐼, 푁푘 = 푎푏} 푁 −3 The function 푓: 푘 ∈ ℕ ⟼ 푁 ∈ 퐼 is bijective. The inverse function is 푓−1: 푁 ∈ 퐼 ⟼ 푘 = 푘 . 푘 = 푘 푘 2 −1 푓 (푁푘) is the index of 푁푘. The preimage of 퐶 is denoted by 푊: 2 −1 푊 = 푓 (퐶) = {푘 ∈ ℕ| 푁푘 ∈ 퐶} 4. For 푥 and 푦 two integers, we denote by 푥 mod 푦 the remainder of the Euclidean division of 푥 by 푦, which belongs to ⟦0, 푦 − 1⟧. 5. 푁1 and 푁2 are the subsets of 퐼 given by: 푁1 = {푁푘 ∈ 퐼|푁푘 mod 4 = 1} 푁2 = {푁푘 ∈ 퐼|푁푘 mod 4 = 3} Similarly: 퐶1 = 푁1 ∩ 퐶 퐶2 = 푁2 ∩ 퐶 Finally, 푆1 and 푆2 designate the set of indices corresponding to elements of 퐶1 and 퐶2 respectively, i.e. −1 −1 푆1 = 푓 (퐶1) and 푆2 = 푓 (퐶2). 2 Basic primality test and primes enumeration 2.1 Two families of infinite sequences with arithmetic difference [8] shows that 푊 is the union of two families of finite sequences with arithmetic difference. Actually proposition 2-5 says that any composite odd number 푁푘 ∈ 퐶 can be written as a difference of two squares, and more precisely that there exists 푗 ∈ ℕ and 푥 ∈ ⟦0, 푗⟧ such that: 2 2 (ퟏ) 푁푘 ∈ 퐶1 ⇒ 푁푘 = (2푗 + 3) − (2푥) , { 2 2 (ퟐ) 푁푘 ∈ 퐶2 ⇒ 푁푘 = (2푗 + 4) − (2푥 + 1) Corollary 2-1: Let 푘푗(푛) = (2푗 + 3)푛 + 푗. One has: 푊 = 푆1 ∪ 푆2 and: 푆1 = {푘푖(푥) = 푘푖(푖 + 1) + 2(2푖 + 3)푥; 푖 ∈ ℕ, 푥 ∈ ℕ} 푆2 = {푘푖(푥) = 푘푖(푖 + 2) + 2(2푖 + 3)푥; 푖 ∈ ℕ, 푥 ∈ ℕ} Thus 푊 is the union of two families of infinite arithmetic sequences. The indices 푘푖(푖 + 1) of first type reference points (or remarkable points, see[8]) are the initial terms of sequences ranging in 푆1. Similarly, the indices 푘푖(푖 + 2) of second type reference points are the initial terms of sequences ranging in 푆2. Proof: We substitute 푗 by 푖 + 푥 in relations (1) and (2): (2푗 + 3)2 − (2푥)2 = (2푖 + 2푥 + 3)2 − (2푥)2 = (2푖 + 3)(2푖 + 4푥 + 3) = 2[푘푖(푖 + 1) + 2(2푖 + 3)푥] + 3 and similarly: 3 (2푗 + 4)2 − (2푥 + 1)2 = (2푖 + 2푥 + 4)2 − (2푥 + 1)2 = (2푖 + 3)(2푖 + 4푥 + 5) = 2(2푖 + 3)(푖 + 2푥 + 2) + 2푖 + 3 = 2[푘푖(푖 + 2) + 2(2푖 + 3)푥] + 3 Proposition 2-1: For any 푁푘 ∈ 퐶 there exists 푋 ∈ 푃, 푋 ≤ √푁푘 and 푥 ∈ ℕ such that: 푁푘 ∈ 퐶1 ⇒ 푁푘 = 푋(푋 + 4푥) 푁푘 ∈ 퐶2 ⇒ 푁푘 = 푋(푋 + 4푥 + 2) Thus, writing 푋 = 2푖 + 3, we get: ′ ′ 푊 = 푆1 ∪ 푆2 where: ′ 푆1 = {푘푖(푥) = 푘푖(푖 + 1) + 2(2푖 + 3)푥; 푖 ∈ ℕ ∖ 푊, 푥 ∈ ℕ} ′ 푆2 = {푘푖(푥) = 푘푖(푖 + 2) + 2(2푖 + 3)푥; 푖 ∈ ℕ ∖ 푊, 푥 ∈ ℕ} 푁 Proof: Take 푋 the smallest prime dividing 푁 ∈ 퐶. Thus 푋 ∈ 푃 and if 푌 = 푘 then 푌 ≥ 푋 and 푌 − 푋 푘 √푁푘 푋 is even, and we can write it either 4푥 or 4푥 + 2. These two cases clearly correspond respectively to 푁푘 ∈ 퐶1 and 푁푘 ∈ 퐶2. Thus the index 푘 can be decomposed as in corollary 2-1, but with 푖 the index of a prime number, hence in ℕ ∖ 푊. 2.2 Basic primality test In this section, we describe a basic primality test using the previous infinite sequences. Definition 2-2: For any 푝 = 2푖 + 3 ∈ 푃 and 푁 ∈ 퐼 we let: 2 2 1- 퐴(푁, 푝) = 푁 − 푝 and 푓퐴(푝) = 푝 . 2- 퐵(푁, 푝) = 푁 − 푝(푝 + 2) and 푓퐵(푝) = 푝(푝 + 2). Proposition 2-2: 푁 ∈ 푁1 is a prime number when: 퐴(푁, 푝) ∀푝 = 2푖 + 3 ∈ 푃 , mod 푝 ≠ 0 √푁 4 푁 ∈ 푁2 is a prime number when: 퐵(푁, 푝) ∀푝 = 2푖 + 3 ∈ 푃 , mod 푝 ≠ 0 √푁 4 Proof: This follows from the fact that 퐴(푁, 푝) mod 푝 = 푁 mod 푝 and likewise for 퐵(푁, 푝). Remark 2-2: In order to reduce computation of 퐴(푁, 푝) and 퐵(푁, 푝) for two consecutive prime numbers, we only decrement the value. More precisely, if 푝 < 푝′ are two primes, we let 훼(푝, 푝′) = 푝′ − 푝 and we compute: 훥퐴(푁, 푝, 푝′) = 퐴(푁, 푝) − 퐴(푁, 푝′) = 훼(훼 + 2푝) { 훥퐵(푁, 푝, 푝′) = 퐵(푁, 푝) − 퐵(푁, 푝′) = Δ퐴(푁, 푝, 푝′) + 2훼 4 These two expressions
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages32 Page
-
File Size-