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.

148 Chapter 3 RECOGNIZING PRIMES AND COMPOSITES<br />

and the “b” number for the second sequence is a square! Thus, if gcd(n, b) =1<br />

and we let A be an integer with A ≡ b −1 V2(a, b) ≡ a 2 b −1 − 2(modn), then<br />

we have<br />

V2m(a, b) ≡ b m Vm(A, 1) (mod n). (3.16)<br />

Similarly, we have<br />

U2m(a, b) ≡ ab m−1 Um(A, 1) (mod n),<br />

so that using (3.13) (with A, 1fora, b, so that “∆” in (3.13) is A 2 − 4), we<br />

have<br />

U2m(a, b) ≡ (a∆) −1 b m+1 2Vm+1(A, 1) − AVm(A, 1) (mod n). (3.17)<br />

We may use the above method of binary Lucas chains to efficiently<br />

compute the pair Vm(A, 1) (mod n), Vm+1(A, 1) (mod n), where n is a number<br />

coprime to b and we view A as an integer modulo n. Thus, via (3.16), (3.17),<br />

we may find V2m(a, b),U2m(a, b) (modn). And from these, with 2m = n− <br />

∆<br />

n ,<br />

we may see whether n is a Lucas pseudoprime or Frobenius pseudoprime with<br />

respect to x2 − ax + b.<br />

We summarize these notions in the following theorem.<br />

Theorem 3.6.8. Suppose that a, b, ∆,A are as above and that n is a<br />

composite number coprime to 2ab∆. Then n is a Lucas pseudoprime with<br />

respect to x 2 − ax + b if and only if<br />

AV 1<br />

2(n−( ∆ (A, 1) ≡ 2V 1<br />

n)) 2(n−( ∆ (A, 1) (mod n). (3.18)<br />

n))+1<br />

Moreover, n is a Frobenius pseudoprime with respect to x 2 −ax+b if and only<br />

if the above holds and also<br />

b (n−1)/2 V 1<br />

2(n−( ∆ (A, 1) ≡ 2(modn). (3.19)<br />

n))<br />

<br />

∆ n −<br />

As we have seen above, for m = 1<br />

2<br />

n<br />

, the pair Vm(A, 1), Vm+1(A, 1)<br />

may be computed modulo n using fewer than 2 lg n multiplications mod n and<br />

lg n additions mod n. Half of the multiplications mod n are squarings mod n.<br />

A Fermat test also involves lg n squarings mod n, and up to lg n additional<br />

multiplications mod n, if we use Algorithm 2.1.5 for the binary ladder. We<br />

conclude from (3.18) that the time to do a Lucas test is at most twice the<br />

time to do a Fermat test. To apply (3.19) we must also compute b (n−1)/2<br />

(mod n), so we conclude that the time to do a Frobenius test (for a quadratic<br />

polynomial) is at most three times the time to do a Fermat test.<br />

As with the Fermat test and the strong Fermat test, we apply the Lucas<br />

test and the Frobenius test to numbers n that are not known to be prime<br />

or composite. Following is pseudocode for these tests along the lines of this<br />

section.<br />

Algorithm 3.6.9 (Lucas probable prime test).<br />

We are given integers n, a, b, ∆, with ∆=a 2 − 4b, ∆ not a square, n>1,

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

Saved successfully!

Ooh no, something went wrong!