- Rational sieve
In
mathematics , the rational sieve is a generalalgorithm for factoring integers into prime factors. It is essentially a special case of thegeneral number field sieve , and while it is far less efficient than the general algorithm, it is conceptually far simpler. So while it is rather useless as a practical factoring algorithm, it is a helpful first step for those trying to understand how the general number field sieve works.Method
Suppose we are trying to factor the
composite number "n". We choose a bound "B", and identify the "factor base" (which we will call "P") consisting of all primes smaller than "B". Next, we search for positive integers "z" such that both "z" and "z+n" are "B"-smooth -- i.e. all of their prime factors are less than or equal to "B". We can therefore write, for suitable ,and likewise, for suitable , we have
.
But and are congruent modulo , and so each such integer "z" that we find yields a multiplicativerelation (mod "n") among the elements of "P", i.e.
:
(where the "ai" and "bi" are nonnegative integers.)
When we have generated enough of these relations (it's generally sufficient that the number of relations be a few more than the size of "P"), we can use the methods of
linear algebra to multiply together these various relations in such a way that the exponents of the primes are all even. This will give us acongruence of squares of the form a2≡b2 (mod "n"), which can be turned into a factorization of "n", "n"=gcd ("a"-"b","n")×gcd("a"+"b","n"). This factorization might turn out to be trivial (i.e. "n"="n"×1), in which case we have to try again with a different combination of relations; but with luck we will get a nontrivial factorization of "n", and the algorithm will terminate.Example
We will factor the integer "n" = 35 using the rational sieve. We'll arbitrarily try the value "B"=19, giving the factor base "P"={2,3,11,13,17,19}. (We cannot include 5 and 7 since they are actually factors of 35, which renders the algorithm unusable. Of course, if we already know the factors, we do not need to do the algorithm, but we will anyway to show that the algorithm works, i.e. for demonstration purposes.) Next, we search for values of "z" -- the first few are 1, 3, 4, 9, 13, 19, and 22, and we can stop there. The seven values of "z" give seven multiplicative relations (mod 35):
*2030110130190 = 1 ≡ 36 = 2232110130190.............(1)
*2031110130190 = 3 ≡ 38 = 2130110130191.............(2)
*2230110130190 = 4 ≡ 39 = 2031110131190.............(3)
*2032110130190 = 9 ≡ 44 = 2230111130190.............(4)
*2030110131190 = 13 ≡ 48 = 2431110130190.............(5)
*2030110130191 = 19 ≡ 54 = 2133110130190.............(6)
*2130111130190 = 22 ≡ 57 = 2031110130191.............(7)
There are now several essentially different ways to combine these and end up with even exponents:
*(2)×(4)×(7): After multiplying these and canceling out common factors (which we can do since they are coprime with "n"), [Note that common factors cannot "in general" be canceled in a congruence, but they can "in this case", since the primes of the factor base are all required to be
coprime to "n", as mentioned above. Seemodular multiplicative inverse .] this reduces to 32 ≡ 22192, or 32 ≡ 382. The resulting factorization is 35 = gcd(38-3,35) × gcd(38+3,35) = 35×1. The trivial factorization; try again.*(1): This says 62 ≡ 12, which gives the factorization 35 = gcd(6-1,35) × gcd(6+1,35) = 5×7. Success!
Note that there were still other combinations we did not need to use, such as (3)×(5) and (2)×(6).
Limitations of the algorithm
The rational sieve, like the general number field sieve, cannot factor numbers of the form "pm", where "p" is a prime and "m" is an integer. This is not a huge problem, though -- such numbers are statistically rare, and moreover there is a simple and fast process to check whether a given number is of this form.
The bigger problem is finding a sufficient number of "z" such that both "z" and "z"+"n" are "B"-smooth. For any given "B", the proportion of numbers that are "B"-smooth decreases rapidly with the size of the number. So if "n" is large (say, a hundred digits), it will be difficult or impossible to find enough "z" for the algorithm to work. The advantage of the general number field sieve is that one need only search for smooth numbers of order "n"1/"d" for some positive integer "d" (typically 3 or 5), rather than of order "n" as required here.
References
*A. K. Lenstra, H. W. Lenstra, Jr., M. S. Manasse, and J. M. Pollard, "The Factorization of the Ninth Fermat Number," Math. Comp. 61 (1993), 319-349. A draft is available at [http://www.std.org/~msm/common/f9paper.ps www.std.org/~msm/common/f9paper.ps] .
*A. K. Lenstra, H. W. Lenstra, Jr. (eds.) "The Development of the Number Field Sieve," Lecture Notes in Mathematics 1554, Springer-Verlag, New York, 1993.
Footnotes
Wikimedia Foundation. 2010.