10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

124 Chapter 3 RECOGNIZING PRIMES AND COMPOSITES<br />

63. Thus 12033 is not 10-smooth. However, the entry at 12000 gets changed<br />

sequentially to 2, 4, 8, 16, 32, 96, 480, 2400, and finally 12000. Thus 12000 is<br />

10-smooth.<br />

One important way of speeding this sieve is to do the arithmetic at each<br />

location in the sieve with logarithms. Doing exact arithmetic with logarithms<br />

involves infinite precision, but there is no need to be exact. For example, say we<br />

use the closest integer to the base-2 logarithm. For 12000 this is 14. We also use<br />

the approximations lg 2 ≈ 1 (this one being exact), lg 3 ≈ 2, lg 5 ≈ 2, lg 7 ≈ 3.<br />

The entry now at location 12000 gets changed sequentially to 1, 2, 3, 4, 5, 7,<br />

9, 11, 13. This is close enough to the target 14 for us to recognize that 12000 is<br />

smooth. In general, if we are searching for B-smooth numbers, then an error<br />

smaller than lg B is of no consequence.<br />

One should see the great advantage of working with approximate<br />

logarithms, as above. First, the numbers one deals with are very small. Second,<br />

the arithmetic necessary is addition, an operation that is much faster to<br />

perform on most computers than multiplication or division. Also note that<br />

the logarithm function moves very slowly for large arguments, so that all<br />

nearby locations in the sieve have essentially the same target. For example,<br />

above we had 14 the target for 12000. This same number is used as the target<br />

for all locations between 2 13.5 and 2 14.5 , namely, all integers between 11586<br />

and 23170.<br />

We shall find later an important application for this kind of sieve in<br />

factorization algorithms. And, as discussed in Section 6.4, sieving for smooth<br />

numbers is also crucial in some discrete logarithm algorithms. In these settings<br />

we are not so concerned with doing a perfect job sieving, but rather just<br />

recognizing most B-smooth numbers without falsely reporting too many<br />

numbers that are not B-smooth. This is a liberating thought that allows<br />

further speed-ups in sieving. The time spent sieving with a prime p in the<br />

sieve is proportional to the product of the length of the sieve and 1/p. In<br />

particular, small primes are the most time-consuming. But their logarithms<br />

contribute very little to the sum, and so one might agree to forgo sieving<br />

with these small primes, allowing a little more error in the sieve. In the above<br />

example, say we forgo sieving with the moduli 2, 3, 4, 5. We will sieve by<br />

higher powers of 2, 3, and 5, as well as all powers of 7, to recognize our 10smooth<br />

numbers. Then the running sum in location 12000 is 3, 4, 5, 9, 11.<br />

This total is close enough to 14 to cause a report, and the number 12000 is<br />

not overlooked. But we were able to avoid the most costly part of the sieve to<br />

find it.<br />

3.2.6 Sieving a polynomial<br />

Suppose f(x) is a polynomial with integer coefficients. Consider the numbers<br />

f(1),f(2),...,f(N). Say we wish to find the prime numbers in this list, or to<br />

prepare a factor table for the list, or to find the B-smooth numbers in this<br />

list. All of these tasks can easily be accomplished with a sieve. In fact, we have<br />

already seen a special case of this for the polynomial f(x) =2x +1, when we

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!