Prime Numbers

Prime Numbers Prime Numbers

thales.doa.fmph.uniba.sk
from thales.doa.fmph.uniba.sk More from this publisher
10.12.2012 Views

5.1 Squares 227 5.1.2 Lehman method But how do we know to try the multiplier 3 in the above example? The following method of R. Lehman formalizes the search for a multiplier. Algorithm 5.1.2 (Lehman method). We are given an integer n>21. This algorithm either provides a nontrivial factor of n or proves n prime. 1. [Trial division] Check whether n has a nontrivial divisor d ≤ n 1/3 , and if so, return d; 2. [Loop] for 1 ≤ k ≤ n 1/3 { for ⌈2 √ kn⌉ ≤a ≤⌊2 √ kn + n 1/6 /(4 √ k)⌋ { if b = √ a 2 − 4kn is an integer return gcd(a + b, n); // Via Algorithm 9.2.11. } } return “n is prime”; Assuming that this algorithm is correct, it is easy to estimate the running time. Step [Trial division] takes O(n 1/3 ) operations, and if Step [Loop] is performed, it takes at most ⌈n 1/3 ⌉ k=1 1/6 n 4 √ k +1 = O(n 1/3 ) calls to Algorithm 9.2.11, each call taking O(ln ln n) operations. Thus, in all, Algorithm 5.1.2 takes in the worst case O(n 1/3 ln ln n) arithmetic operations with integers the size of n. We now establish the integrity of the Lehman method. Theorem 5.1.3. The Lehman method (Algorithm 5.1.2) is correct. Proof. We may assume that n is not factored in Step [Trial division]. If n is not prime, then it is the product of 2 primes both bigger than n 1/3 .That is, n = pq, wherep, q areprimesandn 1/3

228 Chapter 5 EXPONENTIAL FACTORING ALGORITHMS It remains to show that k = uv ≤ n1/3 .Since u v have k = uv = u v v2 < p q v2 + v p q ≤ · B q p n1/3 +1=n 1/3 +1, p 1 < q + vB and v ≤ B, we so the claim is proved. With k, u, v as above, let a = uq + vp, b = |uq − vp|. Then4kn = a2 − b2 . We show that 2 √ kn ≤ a < 2 √ kn + n1/6 4 √ . Since uq · vp = kn, we have k a = uq + vp ≥ 2 √ kn. Seta =2 √ kn + E. Then 4kn +4E √ kn ≤ 2 √ 2 kn + E = a 2 =4kn + b 2 < 4kn + n 2/3 , so that 4E √ kn < n2/3 ,andE< n1/6 4 √ as claimed. k Finally, we show that if a, b are returned in Step [Loop], then gcd(a + b, n) is a nontrivial factor of n. Sincendivides (a + b)(a − b), it suffices to show that a + b

5.1 Squares 227<br />

5.1.2 Lehman method<br />

But how do we know to try the multiplier 3 in the above example? The<br />

following method of R. Lehman formalizes the search for a multiplier.<br />

Algorithm 5.1.2 (Lehman method). We are given an integer n>21. This<br />

algorithm either provides a nontrivial factor of n or proves n prime.<br />

1. [Trial division]<br />

Check whether n has a nontrivial divisor d ≤ n 1/3 , and if so, return d;<br />

2. [Loop]<br />

for 1 ≤ k ≤ n 1/3 {<br />

for ⌈2 √ kn⌉ ≤a ≤⌊2 √ kn + n 1/6 /(4 √ k)⌋ {<br />

if b = √ a 2 − 4kn is an integer return gcd(a + b, n);<br />

// Via Algorithm 9.2.11.<br />

}<br />

}<br />

return “n is prime”;<br />

Assuming that this algorithm is correct, it is easy to estimate the running<br />

time. Step [Trial division] takes O(n 1/3 ) operations, and if Step [Loop] is<br />

performed, it takes at most<br />

⌈n 1/3 ⌉<br />

<br />

k=1<br />

1/6 n<br />

4 √ k +1<br />

<br />

= O(n 1/3 )<br />

calls to Algorithm 9.2.11, each call taking O(ln ln n) operations. Thus, in all,<br />

Algorithm 5.1.2 takes in the worst case O(n 1/3 ln ln n) arithmetic operations<br />

with integers the size of n. We now establish the integrity of the Lehman<br />

method.<br />

Theorem 5.1.3. The Lehman method (Algorithm 5.1.2) is correct.<br />

Proof. We may assume that n is not factored in Step [Trial division]. If n<br />

is not prime, then it is the product of 2 primes both bigger than n 1/3 .That<br />

is, n = pq, wherep, q areprimesandn 1/3

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

Saved successfully!

Ooh no, something went wrong!