10.12.2012 Views

Prime Numbers

Prime Numbers

Prime Numbers

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.2 Monte Carlo methods 231<br />

It is certainly possible for the gcd at Step [Bad seed] to be n itself, and the<br />

chance for this is enhanced if one uses the above idea to put off performing<br />

gcd’s. However, this defect can be mitigated by storing the values U, V at the<br />

last gcd. If the next gcd is n, one can return to the stored values U, V and<br />

proceed one step at a time, performing a gcd at each step.<br />

There are actually many choices for the function F (x). The key criterion is<br />

that the iterates of F modulo p should not have long ρ’s, or as [Guy 1976] calls<br />

them, “epacts.” The epact of a prime p with respect to a function F from Zp to<br />

Zp is the largest k for which there is an s with F (0) (s),F (1) (s),...,F (k) (s) all<br />

distinct. (Actually we have taken some liberty with this definition, originally<br />

Guy defined it as the number of iterates to discover the factor p.)<br />

So a poor choice for a function F (x) isax + b, since the epact for a prime<br />

p is the multiplicative order of a modulo p (when a ≡ 1(modp)), usually a<br />

large divisor of p − 1. (When a ≡ 1(modp) andb ≡ 0(modp), the epact is<br />

p.)<br />

Even among quadratic functions x 2 + b there can be poor choices, for<br />

example b = 0. Another less evident, but nevertheless poor, choice is x2 −2. If<br />

x can be represented as y + y−1 modulo p, then the k-th iterate is y2k + y−2k modulo p.<br />

It is not known whether the epact of x2 +1 forp is a suitably slow-growing<br />

function of p, but Guy conjectures it is O √ p ln p .<br />

If we happen to know some information about the prime factors p of n, it<br />

may pay to use higher-degree polynomials. For example, since all prime factors<br />

of the Fermat number Fk are congruent to 1 (mod 2k+2 )whenk≥2 (see<br />

Theorem 1.3.5), one might use x2k+2 + 1 for the function F when attempting<br />

to factor Fk by the Pollard rho method. One might expect the epact for<br />

a prime factor p of Fk to be smaller than that of x2 + 1 by a factor of<br />

about √ 2k+1 . To see this consider the following probabilistic model. (Note<br />

that a more refined probabilistic model that agrees somewhat better with the<br />

available data is given in [Brent and Pollard 1981]. Also see Exercise 5.2.)<br />

Iterating x2 + 1 might be thought of as a random walk through the set of<br />

squares plus 1, a set of size (p − 1)/2, while using x2k+2 + 1 we walk through<br />

the 2k+2 powers plus 1, a set of size (p − 1)/2k+2 . The birthday paradox says<br />

we should expect a repeat in about c √ m steps in a random walk through a<br />

set of size m, so we see the improved factor of √ 2k+1 . However, there is a<br />

penalty to using x2k+2 + 1, since a typical loop now involves 3(k + 2) modular<br />

squarings and one modular multiplication. For large k the benefit is evident.<br />

In this connection see Exercise 5.24. Such acceleration was used successfully<br />

in [Brent and Pollard 1981] to factor F8, historically the most spectacular<br />

factorization achieved with the Pollard rho method. The work of Brent and<br />

Pollard also discusses a somewhat faster cycle-finding method, which is to save<br />

certain iterate values and comparing future ones with those, as an alternative<br />

to the Floyd cycle-finding method.

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

Saved successfully!

Ooh no, something went wrong!