ArticleslgStudy

computer science

Rational sieve

Rational sieve is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Rational sieve rather than just read about it. In short: In mathematics, the rational sieve is a general algorithm for factoring integers into prime factors. It is a special case of the general number field sieve.

Key takeaways

  • Rational sieve belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Rational sieve to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Rational sieve from memory before moving on to harder problems.

Reference excerpt

In mathematics, the rational sieve is a general algorithm for factoring integers into prime factors. It is a special case of the general number field sieve. While it is less efficient than the general algorithm, it is conceptually simpler. It serves as a helpful first step in understanding 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), the set of all primes less than or equal to 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 in P. We can therefore write, for suitable exponents ai and bi,

z = ∏ p i ∈ P p i a i and z + n = ∏ p i ∈ P p i b i . {\displaystyle z=\prod _{p_{i}\in P}p_{i}^{a_{i}}\qquad {\text{and}}\qquad z+n=\prod _{p_{i}\in P}p_{i}^{b_{i}}.}

But z and z + n {\displaystyle z+n} are congruent modulo n, and so each such integer z that we find yields a multiplicative relation (mod n) among the elements of P, i.e.

∏ p i ∈ P p i a i ≡ ∏ p i ∈ P p i b i ( mod n ) {\displaystyle \prod _{p_{i}\in P}p_{i}^{a_{i}}\equiv \prod _{p_{i}\in P}p_{i}^{b_{i}}{\pmod {n}}}

(where the ai and bi are nonnegative integers.) When we have generated enough of these relations (it is 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 a congruence of squares of the form a2 ≡ b2 (mod n), which can be turned into a factorization of 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 pair of factors of n, and the algorithm will terminate.

Example We will factor the integer n = 187 using the rational sieve. We will arbitrarily try the value B = 7, giving the factor base P = {2,3,5,7}. The first step is to test n for divisibility by each of the members of P; clearly if n is divisible by one of these primes, then we are finished already. However, 187 is not divisible by 2, 3, 5, or 7. Next, we search for suitable values of z; the first few are 2, 5, 9, and 56. These four suitable values of z give four multiplicative relations (mod 187):

There are now several essentially different ways to combine these and end up with even exponents. For example,

(1)×(4): After multiplying these and canceling out the common factor of 7 (which we can do since 7, being a member of P, has already been determined to be coprime with n), this reduces to 24 ≡ 38 (mod n). The resulting factorization is 187 = gcd(34 + 22, 187) × gcd(34 − 22, 187) = 11 × 17. Alternatively, equation (3) is in the proper form already:

(3): This says 32 ≡ 142 (mod n), which gives the factorization 187 = gcd(14 + 3, 187) × gcd(14 − 3, 187) = 11 × 17.

Limitations of the algorithm Like the general number field sieve, the rational 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. Probably the most elegant method is to check whether ⌊n1/b⌋b = n holds for any 1 < b ≤ log2(n) using an integer version of Newton's method for the root extraction. The biggest 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 only needs to search for smooth numbers of order exp(C (log(n))2/3 (log(log(n)))1/3) for some C > 0, 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. Available at [2]. 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

Worked examples

Example 1 — a first encounter with Rational sieve

Start with the simplest possible case. Write down what Rational sieve claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Rational sieve before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Rational sieve ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Rational sieve

In research
Rational sieve appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Rational sieve in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Rational sieve is common in secondary-school and first-year university syllabi. It links to neighbouring topics Integer factorization algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Rational sieve outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Rational sieve” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Rational sieve in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Rational sieve means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Rational sieve out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Rational sieve in simple terms?

In mathematics, the rational sieve is a general algorithm for factoring integers into prime factors. It is a special case of the general number field sieve.

Why does Rational sieve matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Rational sieve?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Rational sieve.

Tags

  • Integer factorization algorithms

Keep exploring