Williams' P 1 Algorithm
   HOME

TheInfoList



OR:

In
computational number theory In mathematics and computer science, computational number theory, also known as algorithmic number theory, is the study of computational methods for investigating and solving problems in number theory and arithmetic geometry, including algorithm ...
, Williams's ''p'' + 1 algorithm is an
integer factorization In number theory, integer factorization is the decomposition of a composite number into a product of smaller integers. If these factors are further restricted to prime numbers, the process is called prime factorization. When the numbers are suf ...
algorithm, one of the family of algebraic-group factorisation algorithms. It was invented by Hugh C. Williams in 1982. It works well if the number ''N'' to be factored contains one or more prime factors ''p'' such that ''p'' + 1 is
smooth Smooth may refer to: Mathematics * Smooth function, a function that is infinitely differentiable; used in calculus and topology * Smooth manifold, a differentiable manifold for which all the transition maps are smooth functions * Smooth algebrai ...
, i.e. ''p'' + 1 contains only small factors. It uses
Lucas sequence In mathematics, the Lucas sequences U_n(P,Q) and V_n(P, Q) are certain constant-recursive integer sequences that satisfy the recurrence relation : x_n = P \cdot x_ - Q \cdot x_ where P and Q are fixed integers. Any sequence satisfying this recu ...
s to perform exponentiation in a
quadratic field In algebraic number theory, a quadratic field is an algebraic number field of degree two over \mathbf, the rational numbers. Every such quadratic field is some \mathbf(\sqrt) where d is a (uniquely defined) square-free integer different from 0 an ...
. It is analogous to Pollard's ''p'' − 1 algorithm.


Algorithm

Choose some integer ''A'' greater than 2 which characterizes the
Lucas sequence In mathematics, the Lucas sequences U_n(P,Q) and V_n(P, Q) are certain constant-recursive integer sequences that satisfy the recurrence relation : x_n = P \cdot x_ - Q \cdot x_ where P and Q are fixed integers. Any sequence satisfying this recu ...
: :V_0=2, V_1=A, V_j=AV_-V_ where all operations are performed modulo ''N''. Then any odd prime ''p'' divides \gcd(N,V_M-2) whenever ''M'' is a multiple of p-(D/p), where D=A^2-4 and (D/p) is the
Jacobi symbol Jacobi symbol for various ''k'' (along top) and ''n'' (along left side). Only are shown, since due to rule (2) below any other ''k'' can be reduced modulo ''n''. Quadratic residues are highlighted in yellow — note that no entry with a ...
. We require that (D/p)=-1, that is, ''D'' should be a
quadratic non-residue In number theory, an integer ''q'' is called a quadratic residue modulo ''n'' if it is congruent to a perfect square modulo ''n''; i.e., if there exists an integer ''x'' such that: :x^2\equiv q \pmod. Otherwise, ''q'' is called a quadratic no ...
modulo ''p''. But as we don't know ''p'' beforehand, more than one value of ''A'' may be required before finding a solution. If (D/p)=+1, this algorithm degenerates into a slow version of Pollard's p − 1 algorithm. So, for different values of ''M'' we calculate \gcd(N,V_M-2), and when the result is not equal to 1 or to ''N'', we have found a non-trivial factor of ''N''. The values of ''M'' used are successive factorials, and V_M is the ''M''-th value of the sequence characterized by V_. To find the ''M''-th element ''V'' of the sequence characterized by ''B'', we proceed in a manner similar to left-to-right exponentiation: x := B y := (B ^ 2 − 2) mod N for each bit of ''M'' to the right of the most significant bit do if the bit is 1 then x := (x × y − B) mod N y := (y ^ 2 − 2) mod N else y := (x × y − B) mod N x := (x ^ 2 − 2) mod N V := x


Example

With ''N''=112729 and ''A''=5, successive values of V_M are: : V1 of seq(5) = V1! of seq(5) = 5 : V2 of seq(5) = V2! of seq(5) = 23 : V3 of seq(23) = V3! of seq(5) = 12098 : V4 of seq(12098) = V4! of seq(5) = 87680 : V5 of seq(87680) = V5! of seq(5) = 53242 : V6 of seq(53242) = V6! of seq(5) = 27666 : V7 of seq(27666) = V7! of seq(5) = 110229. At this point, gcd(110229-2,112729) = 139, so 139 is a non-trivial factor of 112729. Notice that p+1 = 140 = 22 × 5 × 7. The number 7! is the lowest factorial which is multiple of 140, so the proper factor 139 is found in this step. Using another initial value, say ''A'' = 9, we get: : V1 of seq(9) = V1! of seq(9) = 9 : V2 of seq(9) = V2! of seq(9) = 79 : V3 of seq(79) = V3! of seq(9) = 41886 : V4 of seq(41886) = V4! of seq(9) = 79378 : V5 of seq(79378) = V5! of seq(9) = 1934 : V6 of seq(1934) = V6! of seq(9) = 10582 : V7 of seq(10582) = V7! of seq(9) = 84241 : V8 of seq(84241) = V8! of seq(9) = 93973 : V9 of seq(93973) = V9! of seq(9) = 91645. At this point gcd(91645-2,112729) = 811, so 811 is a non-trivial factor of 112729. Notice that p−1 = 810 = 2 × 5 × 34. The number 9! is the lowest factorial which is multiple of 810, so the proper factor 811 is found in this step. The factor 139 is not found this time because p−1 = 138 = 2 × 3 × 23 which is not a divisor of 9! As can be seen in these examples we do not know in advance whether the prime that will be found has a smooth p+1 or p−1.


Generalization

Based on Pollard's ''p'' − 1 and Williams's ''p''+1 factoring algorithms, Eric Bach and Jeffrey Shallit developed techniques to factor ''n'' efficiently provided that it has a prime factor ''p'' such that any ''k''th
cyclotomic polynomial In mathematics, the ''n''th cyclotomic polynomial, for any positive integer ''n'', is the unique irreducible polynomial with integer coefficients that is a divisor of x^n-1 and is not a divisor of x^k-1 for any Its roots are all ''n''th primiti ...
Φ''k''(''p'') is
smooth Smooth may refer to: Mathematics * Smooth function, a function that is infinitely differentiable; used in calculus and topology * Smooth manifold, a differentiable manifold for which all the transition maps are smooth functions * Smooth algebrai ...
. The first few cyclotomic polynomials are given by the sequence Φ1(''p'') = ''p''−1, Φ2(''p'') = ''p''+1, Φ3(''p'') = ''p''2+''p''+1, and Φ4(''p'') = ''p''2+1.


References

*


External links


P + 1 factorization method
at Prime Wiki {{number theoretic algorithms Integer factorization algorithms