Lucas pseudoprimes and Fibonacci pseudoprimes are composite integers that pass certain tests which all primes and very few composite numbers pass: in this case, criteria relative to some Lucas sequence.
Baillie and Wagstaff define Lucas pseudoprimes as follows:[1] Given integers P and Q, where P > 0 and
D=P2-4Q
Let n be a positive integer and let
\left(\tfrac{D}{n}\right)
\delta(n)=n-\left(\tfrac{D}{n}\right).
If n is a prime that does not divide Q, then the following congruence condition holds:
If this congruence does not hold, then n is not prime.If n is composite, then this congruence usually does not hold.[1] These are the key facts that make Lucas sequences useful in primality testing.
The congruence represents one of two congruences defining a Frobenius pseudoprime. Hence, every Frobenius pseudoprime is also a Baillie-Wagstaff-Lucas pseudoprime, but the converse does not always hold.
Some good references are chapter 8 of the book by Bressoud and Wagon (with Mathematica code),[2] pages 142–152 of the book by Crandall and Pomerance,[3] and pages 53–74 of the book by Ribenboim.[4]
A Lucas probable prime for a given (P, Q) pair is any positive integer n for which equation above is true (see,[1] page 1398).
A Lucas pseudoprime for a given (P, Q) pair is a positive composite integer n for which equation is true (see,[1] page 1391).
A Lucas probable prime test is most useful if D is chosen such that the Jacobi symbol
\left(\tfrac{D}{n}\right)
If
\left(\tfrac{D}{n}\right)=-1,
If congruence is false, this constitutes a proof that n is composite.
If congruence is true, then n is a Lucas probable prime.In this case, either n is prime or it is a Lucas pseudoprime.If congruence is true, then n is likely to be prime (this justifies the term probable prime), but this does not prove that n is prime.As is the case with any other probabilistic primality test, if we perform additional Lucas tests with different D, P and Q, then unless one of the tests proves that n is composite, we gain more confidence that n is prime.
Examples: If P = 3, Q = -1, and D = 13, the sequence of Us is : U0 = 0, U1 = 1, U2 = 3, U3 = 10, etc.
First, let n = 19. The Jacobi symbol
\left(\tfrac{13}{19}\right)
U20=6616217487\equiv0\pmod{19}.
For the next example, let n = 119. We have
\left(\tfrac{13}{119}\right)
U120\equiv0\pmod{119}.
We will see below that, in order to check equation for a given n, we do not need to compute all of the first n + 1 terms in the U sequence.
Let Q = −1, the smallest Lucas pseudoprime to P = 1, 2, 3, ... are
323, 35, 119, 9, 9, 143, 25, 33, 9, 15, 123, 35, 9, 9, 15, 129, 51, 9, 33, 15, 21, 9, 9, 49, 15, 39, 9, 35, 49, 15, 9, 9, 33, 51, 15, 9, 35, 85, 39, 9, 9, 21, 25, 51, 9, 143, 33, 119, 9, 9, 51, 33, 95, 9, 15, 301, 25, 9, 9, 15, 49, 155, 9, 399, 15, 33, 9, 9, 49, 15, 119, 9, ...
Now, factor
\delta(n)=n-\left(\tfrac{D}{n}\right)
d ⋅ 2s
d
A strong Lucas pseudoprime for a given (P, Q) pair is an odd composite number n with GCD(n, D) = 1, satisfying one of the conditions
Ud\equiv0\pmod{n}
V | |
d ⋅ 2r |
\equiv0\pmod{n}
for some 0 ≤ r < s; see page 1396 of.[1] A strong Lucas pseudoprime is also a Lucas pseudoprime (for the same (P, Q) pair), but the converse is not necessarily true.Therefore, the strong test is a more stringent primality test than equation .
There are infinitely many strong Lucas pseudoprimes, and therefore, infinitely many Lucas pseudoprimes.Theorem 7 in [1] states: Let
P
Q
P2-4Q
c
P
Q
x
c ⋅ logx
x
We can set Q = −1, then
Un
Vn
An extra strong Lucas pseudoprime[6] is a strong Lucas pseudoprime for a set of parameters (P, Q) where Q = 1, satisfying one of the conditions
Ud\equiv0\pmod{n}andVd\equiv\pm2\pmod{n}
V | |
d ⋅ 2r |
\equiv0\pmod{n}
for some
0\ler<s-1
(P,Q)
Before embarking on a probable prime test, one usually verifies that n, the number to be tested for primality, is odd, is not a perfect square, and is not divisible by any small prime less than some convenient limit. Perfect squares are easy to detect using Newton's method for square roots.
We choose a Lucas sequence where the Jacobi symbol
\left(\tfrac{D}{n}\right)=-1
Given n, one technique for choosing D is to use trial and error to find the first D in the sequence 5, −7, 9, −11, ... such that
\left(\tfrac{D}{n}\right)=-1
\left(\tfrac{k}{n}\right)\left(\tfrac{-k}{n}\right)=-1
\left(\tfrac{D}{n}\right)=0
P=1
Q=(1-D)/4
(This search will never succeed if n is square, and conversely if it does succeed, that is proof that n is not square. Thus, some time can be saved by delaying testing n for squareness until after the first few search steps have all failed.)
Given D, P, and Q, there are recurrence relations that enable us to quickly compute
Un+1
Vn+1
O(log2n)
U1=1
V1=P=1
k
2k
U2k=Uk ⋅ Vk
V2k
2-2Q | |
=V | |
k |
| ||||||||||
U2k+1=(P ⋅ U2k+V2k)/2
V2k+1=(D ⋅ U2k+P ⋅ V2k)/2
P ⋅ U2k+V2k
P ⋅ U2k+V2k+n
V2k+1
At each stage, we reduce
U
V
Q
We use the bits of the binary expansion of n to determine which terms in the U sequence to compute. For example, if n+1 = 44 (= 101100 in binary), then, taking the bits one at a time from left to right, we obtain the sequence of indices to compute: 12 = 1, 102 = 2, 1002 = 4, 1012 = 5, 10102 = 10, 10112 = 11, 101102 = 22, 1011002 = 44. Therefore, we compute U1, U2, U4, U5, U10, U11, U22, and U44. We also compute the same-numbered terms in the V sequence, along with Q1, Q2, Q4, Q5, Q10, Q11, Q22, and Q44.
By the end of the calculation, we will have computed Un+1, Vn+1, and Qn+1, (mod n).We then check congruence using our known value of Un+1.
When D, P, and Q are chosen as described above, the first 10 Lucas pseudoprimes are (see page 1401 of [1]):323, 377, 1159, 1829, 3827, 5459, 5777, 9071, 9179, and 10877
The strong versions of the Lucas test can be implemented in a similar way.
When D, P, and Q are chosen as described above, the first 10 strong Lucas pseudoprimes are: 5459, 5777, 10877, 16109, 18971, 22499, 24569, 25199, 40309, and 58519
To calculate a list of extra strong Lucas pseudoprimes, set
Q=1
D=P2-4Q
\left(\tfrac{D}{n}\right)=-1
If we have checked that congruence is true, there are additional congruence conditions we can check that have almost no additional computational cost.If n happens to be composite, these additional conditions may help discover that fact.
If n is an odd prime and
\left(\tfrac{D}{n}\right)=-1
Although this congruence condition is not, by definition, part of the Lucas probable prime test, it is almost free to check this condition because, as noted above, the value of Vn+1 was computed in the process of computing Un+1.
If either congruence or is false, this constitutes a proof that n is not prime.If both of these congruences are true, then it is even more likely that n is prime than if we had checked only congruence .
If Selfridge's method (above) for choosing D, P, and Q happened to set Q = -1, then we can adjust P and Q so that D and
\left(\tfrac{D}{n}\right)
If
Q ≠ \pm1
Recall that
Qn+1
Un+1
Q
Q(n+1)/2
If n is prime, then, by Euler's criterion,
Q(n-1)/2\equiv\left(\tfrac{Q}{n}\right)\pmod{n}
\left(\tfrac{Q}{n}\right)
Therefore, if n is prime, we must have,
The Jacobi symbol on the right side is easy to compute, so this congruence is easy to check.If this congruence does not hold, then n cannot be prime. Provided GCD(n, Q) = 1 then testing for congruence is equivalent to augmenting our Lucas test with a "base Q" Solovay–Strassen primality test.
Additional congruence conditions that must be satisfied if n is prime are described in Section 6 of.[1] If any of these conditions fails to hold, then we have proved that n is not prime.
k applications of the Miller–Rabin primality test declare a composite n to be probably prime with a probability at most (1/4)k.
There is a similar probability estimate for the strong Lucas probable prime test.[8]
Aside from two trivial exceptions (see below), the fraction of (P,Q) pairs (modulo n) that declare a composite n to be probably prime is at most (4/15).
Therefore, k applications of the strong Lucas test would declare a composite n to be probably prime with a probability at most (4/15)k.
There are two trivial exceptions. One is n = 9. The other is when n = p(p+2) is the product of two twin primes. Such an n is easy to factor, because in this case, n+1 = (p+1)2 is a perfect square. One can quickly detect perfect squares using Newton's method for square roots.
By combining a Lucas pseudoprime test with a Fermat primality test, say, to base 2, one can obtain very powerful probabilistic tests for primality, such as the Baillie–PSW primality test.
When P = 1 and Q = -1, the Un(P,Q) sequence represents the Fibonacci numbers.
A Fibonacci pseudoprime is often[2] [3] [4] defined as a composite number n not divisible by 5 for which congruence holds with P = 1 and Q = -1. By this definition, the Fibonacci pseudoprimes form a sequence:
323, 377, 1891, 3827, 4181, 5777, 6601, 6721, 8149, 10877, ... . The references of Anderson and Jacobsen below use this definition.
If n is congruent to 2 or 3 modulo 5, then Bressoud,[2] and Crandall and Pomerance[3] point out that it is rare for a Fibonacci pseudoprime to also be a Fermat pseudoprime base 2. However, when n is congruent to 1 or 4 modulo 5, the opposite is true, with over 12% of Fibonacci pseudoprimes under 1011 also being base-2 Fermat pseudoprimes.
If n is prime and GCD(n, Q) = 1, then we also have[1]
This leads to an alternative definition of Fibonacci pseudoprime:[9] [10]
a Fibonacci pseudoprime is a composite number n for which congruence holds with P = 1 and Q = -1.This definition leads the Fibonacci pseudoprimes form a sequence:
705, 2465, 2737, 3745, 4181, 5777, 6721, 10877, 13201, 15251, ...,which are also referred to as Bruckman-Lucas pseudoprimes.[4] Hoggatt and Bicknell studied properties of these pseudoprimes in 1974.[11] Singmaster computed these pseudoprimes up to 100000.[12] Jacobsen lists all 111443 of these pseudoprimes less than 1013.[13]
It has been shown that there are no even Fibonacci pseudoprimes as defined by equation (5).[14] [15] However, even Fibonacci pseudoprimes do exist under the first definition given by .
A strong Fibonacci pseudoprime is a composite number n for which congruence holds for Q = -1 and all P.[16] It follows[16] that an odd composite integer n is a strong Fibonacci pseudoprime if and only if:
The smallest example of a strong Fibonacci pseudoprime is 443372888629441 = 17·31·41·43·89·97·167·331.
A Pell pseudoprime may be defined as a composite number n for which equation above is true with P = 2 and Q = -1; the sequence Un then being the Pell sequence. The first pseudoprimes are then 35, 169, 385, 779, 899, 961, 1121, 1189, 2419, ...
This differs from the definition in which may be written as:
Un\equiv\left(\tfrac{2}{n}\right)\pmod{n}
with (P, Q) = (2, −1) again defining Un as the Pell sequence. The first pseudoprimes are then 169, 385, 741, 961, 1121, 2001, 3827, 4879, 5719, 6215 ...
A third definition uses equation (5) with (P, Q) = (2, −1), leading to the pseudoprimes 169, 385, 961, 1105, 1121, 3827, 4901, 6265, 6441, 6601, 7107, 7801, 8119, ...