Prime Numbers
Prime Numbers Prime Numbers
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
- Page 188 and 189: 176 Chapter 4 PRIMALITY PROVING sma
- Page 190 and 191: 178 Chapter 4 PRIMALITY PROVING Sin
- Page 192 and 193: 180 Chapter 4 PRIMALITY PROVING Let
- Page 194 and 195: 182 Chapter 4 PRIMALITY PROVING Rec
- Page 196 and 197: 184 Chapter 4 PRIMALITY PROVING (mo
- Page 198 and 199: 186 Chapter 4 PRIMALITY PROVING pol
- Page 200 and 201: 188 Chapter 4 PRIMALITY PROVING if
- Page 202 and 203: 190 Chapter 4 PRIMALITY PROVING 4.3
- Page 204 and 205: 192 Chapter 4 PRIMALITY PROVING j =
- Page 206 and 207: 194 Chapter 4 PRIMALITY PROVING The
- Page 208 and 209: 196 Chapter 4 PRIMALITY PROVING The
- Page 210 and 211: 198 Chapter 4 PRIMALITY PROVING Rem
- Page 212 and 213: 200 Chapter 4 PRIMALITY PROVING pos
- Page 214 and 215: 202 Chapter 4 PRIMALITY PROVING Alg
- Page 216 and 217: 204 Chapter 4 PRIMALITY PROVING fac
- Page 218 and 219: 206 Chapter 4 PRIMALITY PROVING 196
- Page 220 and 221: 208 Chapter 4 PRIMALITY PROVING The
- Page 222 and 223: 210 Chapter 4 PRIMALITY PROVING Say
- Page 224 and 225: 212 Chapter 4 PRIMALITY PROVING But
- Page 226 and 227: 214 Chapter 4 PRIMALITY PROVING for
- Page 228 and 229: 216 Chapter 4 PRIMALITY PROVING so
- Page 230 and 231: 218 Chapter 4 PRIMALITY PROVING (2)
- Page 232 and 233: 220 Chapter 4 PRIMALITY PROVING hav
- Page 234 and 235: 222 Chapter 4 PRIMALITY PROVING sho
- Page 236 and 237: Chapter 5 EXPONENTIAL FACTORING ALG
- Page 240 and 241: 5.2 Monte Carlo methods 229 That is
- Page 242 and 243: 5.2 Monte Carlo methods 231 It is c
- Page 244 and 245: 5.2 Monte Carlo methods 233 computi
- Page 246 and 247: 5.3 Baby-steps, giant-steps 235 cal
- Page 248 and 249: 5.4 Pollard p − 1 method 237 can
- Page 250 and 251: 5.6 Binary quadratic forms 239 f(jB
- Page 252 and 253: 5.6 Binary quadratic forms 241 so o
- Page 254 and 255: 5.6 Binary quadratic forms 243 equi
- Page 256 and 257: 5.6 Binary quadratic forms 245 is a
- Page 258 and 259: 5.6 Binary quadratic forms 247 In t
- Page 260 and 261: 5.6 Binary quadratic forms 249 of D
- Page 262 and 263: 5.7 Exercises 251 is completely rig
- Page 264 and 265: 5.7 Exercises 253 of each of these
- Page 266 and 267: 5.8 Research problems 255 5.17. Sho
- Page 268 and 269: 5.8 Research problems 257 modulo th
- Page 270 and 271: 5.8 Research problems 259 In judgin
- Page 272 and 273: 262 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 274 and 275: 264 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 276 and 277: 266 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 278 and 279: 268 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 280 and 281: 270 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 282 and 283: 272 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 284 and 285: 274 Chapter 6 SUBEXPONENTIAL FACTOR
- Page 286 and 287: 276 Chapter 6 SUBEXPONENTIAL FACTOR
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