Download Note on Representing a Prime as a Sum of Two Squares

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Wieferich prime wikipedia , lookup

Elliptic curve primality wikipedia , lookup

Mersenne prime wikipedia , lookup

Prime number theorem wikipedia , lookup

Sieve of Eratosthenes wikipedia , lookup

List of prime numbers wikipedia , lookup

Transcript
MATHEMATICS OF COMPUTATION, VOLUME 26, NUMBER 120, OCTOBER 1972
Note on Representing a Prime as a Sum
of Two Squares
By John Brillhart
Abstract.
An improvement is given to the method of Hermite for finding a and b in p =
a1 + b2, where p is a prime m 1 (mod 4).
In a one-page note, Hermite [1] published the following efficient method for
representing a given prime p = 1 (mod 4) as a sum of squares (see Lehmer [2]):
(i) Find the solution x0 of x2 = —1 (mod p), where 0 < x0 < p/2.
(ii) Expand x0/p into a simple continued fraction to the point where the denominators of its convergents A'JB'n satisfy the inequality B'k+l < y/p < B'k+2.Then
p = (x0B'k+i - pAUif
+ (B'k+l)2.
This method, which was the best method known for computing a and b (see
Shanks [5]), appeared simultaneously with a paper of Serret [4] on the same subject.
Hermite's method, however, is superior, in that it contains a criterion for ending
the algorithm at the right place, while Serret's does not.
It is the purpose of this note to point out that the calculation of the convergents
in (ii) can be dispensed with, since the values needed for the representation are already
at hand in the continued fraction expansion itself. Thus, the shortened algorithm is:
(i) The same.
(ii) Carry out the Euclidean algorithm on p/x0 (not x0/p), producing the sequence
of remainders Ru R2, • ■• , to the point where Rk is first less than y/p. Then
Proof.
p = Rl + Rt+u
if Ri > 1,
- 4 + i,
if Ri = i.
Assume Rx > I. Since 0 < x0 < p/2 andp | (x2Q+ 1), then, from Perron
[3], the following properties hold:
(1) The continued fraction expansion of p/x0 has an even number of partial
quotients and is palindromic, i.e.,
p/x0
=
[<7o, <7ir • " • > <?*, Qk, ■ ■ ■ , <7i, <7o] =
A2k+1/B2k + 1,
k ^ 0. (Observe that the convergents A'n+1/Bn+1 for the expansion
reciprocals of the convergents A„/B„ for p/x0.)
(2)
_
A2k+l = p and
of x0/p are the
A2k = x0.
(3) P = Al + A\_x.
Received February 17, 1972.
AMS 1969 subject classifications. Primary 1003, 1009.
Key words and phrases. Algorithm,
sum of two squares.
Copyright © 1972, American
1011
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
Mathematical
Society
1012
JOHN BRILLHART
(4) From (2), the recursion formula for the numerators A„ gives the following
set of equations:
P ~
(]t>Xo ~\~ A2k-\,
x0 =
tjlA2k-i
~\~ A2k-2,
••• .
The equations in (4) are clearly identical with those in the Euclidean algorithm
for p/x0.
Hence,
A2k_x = Rl9 A2k-2 = R2, ■■■ , Ak+i = Rk-i,
Ak = Rk, Ak_\
= Rk+1,
• • ■ . Using these equations with (3), gives p = R\ + R2k+1.Certainly, then, Rk < \/p.
If k = I, then Rk is the first Rk < \/p. If k > 1, then from the observation in (1),
Rk-i = Ak+1 = B'k+2. But, from Hermite's
development,
B'k+2 > \/p,
so Rk is the
first remainder less than y/p.
If Ri = 1, then p = q„x0 + 1 and p/x0 = [q0, q„]. Together, these imply q0 = x0,
sop = xl + 1. Q.E.D.
Remark. The solution x0 of x2 = —1 (mod /?) can be obtained by computing
x0 = c("'1)/i (mod p), where c is a quadratic nonresidue of p. (Observe that c = 2
and c = 3 can be used when p == 5 (mod 8) and p = \1 (mod 24), respectively. In
the remaining case, p m 1 (mod 24), c can be found by using the quadratic reciprocity
law.)
Example.
Let p = 10006721 = 17 (mod 24). Then c = 3 and x0 = 32501680=
2555926(mod p). Then
10006721 = 3-2555926 + 2338943
2555926 = 1-2338943 +
216983
2338943 = 10-216983 +
169113
216983 = 1 -169113 +
47870
169113 = 3-47870
+
25503
47870 = 1-25503
+
22367
25503 = 1-22367
+
3136
22367 = 7-3136
+
415
Hence, since 223672 > p and 31362 < p,
p = 31362 + 4152.
Remark. Some primes of special form can be expressed as a sum of two squares
without much calculation. For example, the number TV= (2691 — 2346 + l)/5 has
recently been shown to be prime by the author and J. L. Selfridge. Hence, we can
write N = [(3-2345 -
l)/5]2 + [(2345 - 2)/5]2. Also, the identity
U2k,l = V\ + I72+i,
where Un is the nth Fibonacci number, provides such a representation
primes in terms of the Fibonacci numbers themselves.
Department of Mathematics
University of Arizona
Tucson, Arizona 85721
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use
for Fibonacci
REPRESENTING A PRIME AS A SUM OF TWO SQUARES
1013
1. C. Hermite,
"Note au sujet de l'article precedent," /. Math. Pures
15; also: "Note sur un theoreme relatif aux nombres entieres," Oevres. Vol.
2. D. H. Lehmer, "Computer technology applied to the theory of
in Number Theory, Math. Assoc. Amer. (distributed by Prentice-Hall,
Appl., v. 1848, p.
1, p. 264.
numbers," Studies
Englewood Cliffs,
N.J.), 1969, pp. 117-151. MR 40 #84.
3. O. Perron,
Die Lehre
pp. 32-34. MR 12, 254.
4.
J. A. Serret,
v. 1848, pp. 12-14.
5. D. Shanks,
von den Kettenbrüchen,
2nd ed., Chelsea,
New York,
1950,
"Sur un theoreme relatif aux nombres entieres," /. Math. Pures Appl.,
Review of "A table of Gaussian primes," by L. G. Diehl and J. H.
Jordan, Math. Comp., v. 21, 1967, pp. 260-262.
License or copyright restrictions may apply to redistribution; see http://www.ams.org/journal-terms-of-use