Tutorial on 3 Common Primality Tests

  • MHB
  • Thread starter mathbalarka
  • Start date
  • Tags
    Tutorial
In summary, there are three main primality tests discussed in this conversation: Pocklington's Test, Brillhart-Lehmer-Selfridge Test, and Konyagin-Pomerance Test. Pocklington's Test is a generalization of a factor of n-1 and covers more prime numbers, while the other two tests require specific knowledge of factors of n-1 and are more specialized. Miller-Rabin is considered the "gold standard" for general-purpose primality testing, but the AKS algorithm is gaining popularity and can be done without knowledge of factors of n-1. There are also other fast algorithms like ECPP and fastECPP, but they may not be practical for manual calculations.
  • #1
mathbalarka
456
0
Here are three $n-1$ primality test I would like to describe in this thread. The first one works for the 60% of the cases, the second is usually used when the first fails and the third if first and second both fails.

Pocklington's Test

Suppose q divides n - 1 and \(\displaystyle q > \sqrt{n}-1\). If there exists an \(\displaystyle a\) such that \(\displaystyle a^{n-1} = 1 \pmod{n}\) and \(\displaystyle \mathrm{gcd}(a^{(n-1)/q} - 1, n)\) then n is a certified prime.

There is a generalization of Pocklington which uses a factor of n - 1 and covers more prime numbers, but I never needed it so I wouldn't post it now.

Brillhart-Lehmer-Selfridge Test

Suppose \(\displaystyle n - 1 = F \cdot R\) and there exists an \(\displaystyle a\) such that \(\displaystyle a^{n-1} = 1 \pmod{n}\) and \(\displaystyle \mathrm{gcd}(a^{(n-1)/q} - 1, n)\) for each prime q dividing F where \(\displaystyle n^{1/3} \le F < \sqrt{n}\). If n can be expressed in base F as \(\displaystyle c_2 F^2 + c_1 F + 1\) where both of the co-efficients are in the interval \(\displaystyle [0, F-1]\) then n is a certified prime if and only if \(\displaystyle c_1 ^2 - 4 c_2\) is not a perfect square.

Konyagin-Pomerance Test

Suppose \(\displaystyle n - 1 = F \cdot R\) and there exists an \(\displaystyle a\) such that \(\displaystyle a^{n-1} = 1 \pmod{n}\) and \(\displaystyle \mathrm{gcd}(a^{(n-1)/q} - 1, n)\) for each prime q dividing F where \(\displaystyle n^{3/10} \le F < n^{1/3}\). If n can be expressed in base F as \(\displaystyle c_3 F^3 + c_2 F^2 + c_1 F + 1\) and let \(\displaystyle c_4 = c_3 F + c_2\) then n is a certified prime if and only if \(\displaystyle (c_1 + t \cdot F)^2 + 4t - 4 c_4\) is not a perfect square and the polynomial \(\displaystyle v x^3 + (u \cdot F - c_1 v) x^2 + (c_4 v - d \cdot F + u) x - d\) over \(\displaystyle \mathbb{Z}[x]\) has no rational root a such that a * F + 1 is a non-trivial factor of n where \(\displaystyle u/v\) is a continued fraction convergent to \(\displaystyle c_1 /F\) such that v is maximal subject to \(\displaystyle v < F^2 / \sqrt{n}\) and \(\displaystyle d = \left \lfloor c_4 ^2 /F + 0.5 \right \rfloor\).
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
re: Commentary for "Primality Tests"

Of course, the last two algorithms presented by Mathbalarka require the knowledge of factors of $n - 1$, which puts them in the "special purpose" category. I messed around with Pocklington's myself a few months ago, quite an interesting algorithm, and I didn't know group theory at the time I tried to find out how it worked (fun fun fun).

Of course the "gold standard" in terms of speed/accuracy is Miller-Rabin, for general-purpose primality testing (knowledge of the factorization of $n - 1$ allows one to certify primality rather easily, as noted by Mathbalarka). The AKS algorithm makes it possible to do so even without such knowledge, and is actually getting quite practical with the recent algorithmic improvements uncovered, but is still pretty unpopular.​
 
  • #3
re: Commentary for "Primality Tests"

First things first, I want to thank MarkFL for creating a commentary thread for the topic I made.

Now, for Bacterius :

Yes, the last two algorithms are for special purposes but still are useful if Pocklington fails because of the bounds on the factors issues. Miller-Rabin isn't very handy for manual calculations because of the large congruences. And I doubt whether AKS can be done manually. However, currently the best algorithm for general-purpose primality test are ECPP and fastECPP. I even considered about adding the algorithms in my post since there are a few cases where it can be manually used!

Balarka
.
 

FAQ: Tutorial on 3 Common Primality Tests

1. What is a primality test?

A primality test is a mathematical algorithm used to determine whether a given number is a prime number or not. Prime numbers are numbers that are only divisible by 1 and itself, making them important in many areas of math and computer science.

2. What are the three common primality tests?

The three common primality tests are the trial division method, the Fermat primality test, and the Miller-Rabin primality test. These tests use different approaches to determine the primality of a given number.

3. How does the trial division method work?

The trial division method checks if a number is prime by dividing it with all the numbers between 2 and the square root of the given number. If none of the numbers evenly divide the given number, it is considered a prime number.

4. How does the Fermat primality test work?

The Fermat primality test uses Fermat's Little Theorem to check if a number is prime. It picks a random number between 2 and the given number, and if the remainder of the random number raised to the power of the given number is equal to the random number itself, the given number is considered to be prime.

5. How does the Miller-Rabin primality test work?

The Miller-Rabin primality test is an improved version of the Fermat test. It uses a probabilistic approach to check if a number is prime by repeatedly picking random numbers and checking if they satisfy the conditions of the test. This test is more efficient and accurate than the Fermat test, making it a commonly used primality test in cryptography.

Similar threads

Replies
16
Views
3K
Replies
4
Views
643
Replies
5
Views
1K
Replies
2
Views
1K
Replies
8
Views
1K
Replies
2
Views
1K
Replies
1
Views
12K
Back
Top