Вы находитесь на странице: 1из 13

Pythagorean Triples Modulo a Prime

Bernard M. Moore

H. Joseph Straight

December 8, 2013
Abstract
In this article, we discuss the existence and number of solutions to the
equation x2 + y2 z 2 (mod p) for a prime p with p 7. We first prove
the existence of such solutions and that there are at least (p 1)/2 nonequivalent solutions. As a corollary, we show that every square can be written as the sum of two distinct squares modulo p. We introduce the p (c)function and discuss our investigation of it using WolframMathematica.
This function counts the number of sibling solutions for a given value of
the hypotenuse, c, and plays a pivotal role in determining the exact
number of solutions. Finally, we give an explicit formula for the number
of non-equivalent solutions for a given prime p, the form of which depends
on the value of p mod 8.

Introduction

For starters, modulo arithmetic can be thought of, and perhaps is best explained,
as clock algebra. For example, we typically use the 12 hour clock, and when
the hour-hand passes 12 oclock we dont say that its 13 oclock, we say its 1
oclock. Well, thats the same idea as working with the set of integers modulo 12.
When we talk about a prime modulus, we just mean that we want to consider
clocks with a prime number of hours, such as 7, 11, 13, 17, 19, and any other
integer greater than 1 which has no positive factors other than 1 and itself. As
it happens, many interesting properties hold for a prime modulus.
Consider p to be a prime number. We define the set Zp = {0, 1, ..., p 1},
which is the set of integers modulo p. Throughout this paper, we are primarily
interested in the set Z#
p = Zp {0}. Our interest lies in studying the following
equation:
x2 + y2 z 2 (mod p),
(1)
where x, y, and z Z#
p , and, unless stated otherwise, x 6= y.
In number theory, this equation is known as a congruence. If, for example,
we let p = 11, we can find that 22 + 42 32 . This is because
22 + 42 = 4 + 16 4 + 5 = 9 = 32
Stony
SUNY

Brook University
Fredonia

(mod 11)

We are interested in finding solutions (a, b, c) to equation (1). These are what
we call Pythagorean triples modulo p. It is a simple exercise to verify that, if
(a, b, c) solves (1), then all of the following triples solve (1):
(a, b, c)
(p a, p b, c)

(a, b, p c)
(p a, b, p c)

(a, p b, c)
(a, p b, p c)

(p a, b, c)
(p a, p b, p c)

We consider all the solutions listed above to be equivalent. Our goal in this
paper is to count the number of non-equivalent solutions to (1).
It is easy to check that there are no solutions to (1) for the cases when p = 3
or p = 5. When p = 7 there are three non-equivalent solutions:
22 + 52 12

32 + 42 22

12 + 62 32

When p = 11 there are five non-equivalent solutions:


32 + 52 12

12 + 52 22

12 + 22 42

22 + 42 32

32 + 42 52

We observe that, for some values of p, there can be more than one solution
of the form (a, b, c) to (1) for a given c; the first instance of this occurs when
p = 17. In this case, there are two non-equivalent solutions:
32 + 42 52

and

22 + 22 52

In the second equation, we have the triple (2, 2, 5). Sometimes, we may prefer
to avoid solutions of the form (a, b, c) with a b. Moving on to the case p = 19,
we have the two non-equivalent solutions
22 + 82 72

and

52 + 92 72

The same phenomena occurs when working with positive integers. For example,
consider the triples (16, 63, 65) and (33, 56, 65), with 162 +632 = 652 = 332 +562 .
Triples of this form are commonly referred to as siblings. Later, in Sections 3
and 4, we provide results on the existence and the number of siblings in the
context of (1).

Existence of Solutions

For an integer x Z#
p we let ord(x) denote the multiplicative order of x, that
is, the least positive integer t such that xt 1, and hxi denote the subgroup
generated by x. For example, consider the element 3 Z#
7 . We can compute
h3i as the set {31 , 32 , 33, 34 , 35 , 36 } = {3, 2, 6, 4, 5, 1}. Fermats Little Theorem
states that, for a prime number p and any positive integer a,
ap1 1

(mod p)
2

So, when working in Z#


p , it is redundant to take element powers greater than
p 1, for, after that power, the same elements simply repeat over and over.
A related result is known as Lagranges Theorem. It tells us that the number
of elements in a subgroup must be a factor of the total number of elements in
the group. So, if we consider again the set Z#
7 , which has 6 elements, we know
that any subgroup must contain 1, 2, 3, or 6 elements.
If the multiplicative order of the element x in Z#
p is equal to p 1, which
is the number of elements in Z#
,
then
we
say
that
x is a generator of Z#
p
p . A
#
generator for Zp is also called a primitive root modulo p, and it is known that
a primitive root always exists for any prime p.
At the other extreme, 1 is the identity element of Z#
p , and it is the unique
element x such that ord(x) = 1. In fact, given an odd prime p and any positive
factor t of p 1, the number of elements with multiplicative order t in Z#
p is
(t), that is, the number of integers between 1 and t that are relatively prime
to t.
In order to prove our main results on the number of solutions to (1), we need
the following lemma.
Lemma 1: For x, y Z#
p , if hxi hyi = {1} then
ord(xy) = lcm(ord(x), ord(y))
That is, if the subgroup generated by x and the subgroup generated by y intersect only in the identity element 1, then the order of the product of x and y is
given by the least common multiple of the order of x and the order of y.
Proof: Let x, y Z#
p , and let n1 = ord(x), n2 = ord(y), and m = lcm(n1 , n2 )
with k1 = m/n1 and k2 = m/n2 . Notice that
(xy)m = xm ym = xk1 n1 yk2 n2 = (xn1 )k1 (yn2 )k2 = (1)k1 (1)k2 = 1
Let t be a positive integer and suppose (xy)t = 1. Divide t by m, obtaining
the quotient q and remainder r. Then
1 = (xy)t = xt yt = xmq+r ymq+r = (xm )q xr (ym )q yr = xr yr
Since hxi hyi = {1}, it must be that r = 0. Thus, t is a multiple of m, and it
follows that
ord(xy) = m = lcm(n1 , n2 ) = lcm(ord(x), ord(y))
QED
Were now ready to state and prove our main results.
Theorem 2: Let p be a prime with p 7. Then there exist distinct elements
x, y Z#
p such that
x2 + y2 1 (mod p)

Proof: Let p be a prime with p 7, and let (a, b, c) be a particular solution


to (1) with a 6= b; for example, (3, 4, 5) is always a solution. The proof has two
cases, depending on the parity of the order of c.
Case 1: ord(c) is even, say, ord(c) = 2k + 2, with 0 k (p 3)/2. Then,
mod p:
a2 + b2 c2 c2k (a2 + b2 ) c2k (c2 )
(ck a)2 + (ck b)2 1
Notice that ck a and ck b are distinct elements of Z#
p .
Case 2: ord(c) is odd. In this case, we replace the solution (a, b, c) with the
equivalent solution (a, b, c) (a, b, p c). Next, we employ the lemma, with
x = 1 and y = c, to obtain that
ord(c) = ord((1)(c)) = lcm(ord(1), ord(c)) = lcm(2, ord(c))
It follows that ord(c) is even. Hence, the second case reduces to the first case,
and the proof is complete.
QED
Corollary 3: For any prime p 7, every square mod p can be written as the
sum of two distinct squares mod p. Furthermore, there are at least (p 1)/2
non-equivalent solutions to equation (1).
Proof: Let p be a prime with p 7. By Theorem 1, there exist a, b Z#
p
such that
a2 + b2 1 (mod p)
2
For a given c Z#
p , multiply both sides of the above equation by c to obtain

c2 (a2 + b2 ) c2

(mod p)

or
(ca)2 + (cb)2 c2

(mod p)

Thus, equation (1) has at least one solution for any square, c2 , in Z#
p . The
result follows since there are (p 1)/2 distinct squares (quadratic residues)
mod p.
QED
Example 1: In the case p = 31, consider the solution 32 + 42 52 to (1).
Starting with this solution, we show how to obtain a solution for every square
mod 31.
Notice that (mod 31) ord(5) = 3 and ord(5) = ord(26) = 6. We modify
the solution 32 + 42 52 to the equivalent solution
32 + 42 262
We substitute 26 for 5 because we wish to have a hypotenuse of even multiplicative order in Z#
31 . Since ord(26) = 6, we multiply both sides of the above
congruence by 264 , yielding:
(3 262 )2 + (4 262 )2 132 + 72 1
4

Hence, (13, 7, 1) is a Pythagorean triple mod 31.


Using this, we can easily obtain (p 1)/2 = 15 non-equivalent solutions by
multiplying both sides of the identity 132 + 72 1 by any one of the 15 non2
2
equivalent square elements in Z#
31 . For example, using c = 14 10, we obtain
the solution
(14 13)2 + (14 7)2 142
or
272 + 52 142
or
42 + 52 142
We encourage the reader to find other solutions.

Counting Solutions

Let N = N (p) denote the total number of non-equivalent Pythagorean triples


modulo p. For a fixed c Z#
p , two non-equivalent solutions (a1 , b1 , c) and
(a2 , b2 , c) to (1) are called siblings for c modulo p, and we denote the number of
siblings by p (c). (Lets consider any given Pythagorean triple modulo p to be
a sibling of itself, so that the relation is a sibling of is reflexive.) Thus,
(p1)/2

N (p) =

p (c)

c=1

For example, here is a complete list of non-equivalent solutions for p = 19:


(2, 4, 1)
(3, 8, 4)
(2, 8, 7)

(3, 7, 1)
(7, 9, 4)
(5, 9, 7)

(4, 8, 2)
(1, 9, 5)
(1, 5, 8)

(5, 6, 2)
(3, 4, 5)
(3, 6, 8)

(2, 9, 3)
(1, 4, 6)
(1, 2, 9)

(6, 7, 3)
(5, 7, 6)
(6, 8, 9)

Note that there are precisely 2 non-equivalent Pythagorean triples modulo 19


for each c, 1 c 9; that is, 19 (c) = 2 for each c, 1 c 9. Knowing this, we
can compute N (19) as follows:
(191)/2

N (19) =

19 (c) =

c=1

9
X

2 = 9(2) = 18

c=1

Theorem 4: For any prime p 7, p (c) is constant for 1 c (p 1)/2.


Proof: Let p be a prime with p 7, and fix c, 1 < c (p 1)/2. To prove
the result, it suffices to show that p (c) = p (1).
Essentially, we use the idea of the proof of Corollary 1. If (a1 , b1 , 1) and
(a2 , b2 , 1) are siblings for 1, then (ca1 , cb1 , c) and (ca2 , cb2 , c) are siblings for c.
5

Conversely, if (d1 , e1 , c) and (d2 , e2 , c) are siblings for c, then (c1 d1 , c1 e1 , 1)


and (c1 d2 , c1 e2 , 1) are siblings for 1. It follows that there is a bijection between the set of siblings for 1 and the set of siblings for c, and, thus, p (c) =
p (1).
QED
Theorem 4 has the following immediate corollary.
Corollary 5: For any prime p 7,
N (p) =

p1
p (1)
2

Looking at the list of Pythagorean triples modulo 19 above, note that there
is no triple of the form (a, b, c) with a2 b2 (mod 19). On the other hand,
consider the analogous list for p = 17:
(3, 3, 1) (3, 14, 1)
(1, 5, 3)
(2, 2, 5) (2, 15, 5)
(4, 4, 7) (4, 13, 7)

(4, 6, 1)
(8, 8, 3) (8, 9, 3)
(3, 4, 5)
(6, 8, 7)

(5, 8, 2)
(1, 7, 4)
(1, 1, 6) (1, 16, 6)
(2, 3, 8)

(6, 6, 2) (6, 11, 2)


(5, 5, 4) (5, 12, 4)
(2, 7, 6)
(7, 7, 8) (7, 10, 8)

Note that, for each c, 1 c 8, there is one sibling for c of the form (a, b, c)
with a2 b2 (mod 17).
Lets call a Pythagorean triple (a, b, c) modulo p an isosceles triple provided
a2 b2 (mod p). For which primes p 7 is there an isosceles Pythagorean
triple modulo p? As we show next, the answer depends on whether or not 2 is
a square modulo p. Note that 2 is a square modulo 17, since 2 62 , whereas 2
is not a square modulo 19 the squares modulo 19 are 1, 4, 9, 16, 6, 17, 11, 7,
and 5.
Theorem 6: Given a prime p with p 7, there is an isosceles Pythagorean
triple modulo p if and only if 2 is a square modulo p. Furthermore, if 2 is a
square modulo p, then there are (p 1)/2 nonequivalent isosceles Pythagorean
triples modulo p, one for each value of c, 1 c (p 1)/2.
Proof: Let p be a prime with p 7. First of all, if (a, b, c) is an isosceles
Pythagorean triple modulo p, then so is (c1 a, c1 b, 1). Conversely, if (a, b, 1)
is an isosceles Pythagorean triple modulo p, then so is (ca, cb, c). This shows
that, if there exists an isosceles Pythagorean triple modulo p, then there at least
(p 1)/2 of them, one for each value of c, 1 c (p 1)/2.
Second, suppose that (a, b, 1) and (d, e, 1) are isosceles Pythagorean triples
modulo p. Then, modulo p, a2 b2 and d2 e2 . Hence, modulo p,
a2 + a2 1 d2 + d2 2a2 2d2 a2 d2

Thus, the triples (a, b, 1) and (d, e, 1) are equivalent. It follows that there are at
most (p 1)/2 isosceles Pythagorean triples modulo p.
Finally, if 2 is a square modulo p, say, t2 2, then (1, 1, t) is an isosceles
Pythagorean triple modulo p. Conversely, if (1, 1, t) is an isosceles Pythagorean
triple modulo p, then t2 2, showing that 2 is a square modulo p.
QED
In number theory, the study of quadratic residues leads to methods for determining whether a given number in Z#
p is a square modulo a given odd prime
p. It is known, for example, that 2 is a square modulo p if and only if p is
congruent to 1 or 7 modulo 8. This fact yields the following corollary.
Corollary 7: Given a prime p with p 7, there is an isosceles Pythagorean
triple modulo p if and only if
p 1 or 7 (mod 8)

Note that Corollary 7 confirms our observations concerning the primes 17


and 19: 17 1 (mod 8), so 2 is a square modulo 17, and, hence, there exist
isosceles Pythagorean triples modulo 17; on the other hand, 19 3 (mod 8), so
2 is not a square modulo 19, and, hence, there do not exist isosceles Pythagorean
triples modulo 19.

Using WolframMathematica to Study p (1)

We used WolframMathematica to investigate the nature of the function p (1).


We began by implementing the function PythagoreanTriples, which, given
a prime p, returns a list of the non-equivalent Pythagorean triples modulo p.
Looking at the output of this function led us to conjecture, for example, that
p (c) is constant (Theorem 4).
Next, we implemented sigmas, which, given a positive integer n, returns
a list of the ordered pairs (p, p0 (1)) for each prime p between 7 and n. (Here,
p0 (1)) is the same as p (1)) except that it does not count isosceles triples.) This
led us to plot p0 (1) for p < 1000. This, in turn, led us to conjecture that p0 (1)
is essentially linear. Using more data points, together with the Mathematica
Fit command, we finally conjectured that
p6
p0 (1)
8
We are indebted to the referee for providing a proof of this conjecture. The
proof uses the idea of the Legendre symbol, which is defined for an odd prime p
and an integer a as follows:

 
if a is (equivalent to) a square modulo p
1
a
= 0
if a is a multiple of p

1 otherwise
7

The Legendre symbol ((p 1)/p) is generally written as (1/p); note that
1 p 1 (mod p). It is known that

 (
1
1
if p 1 (mod 4)
=
p
1 if p 3 (mod 4)
Theorem 8: For each prime p with p 7,

p1

p 3
8
p (1) = p
5

p + 1

if p 1 (mod 8)
if p 3 (mod 8)
if p 5 (mod 8)
if p 7 (mod 8)

Proof: Recall that p (1) is the number of non-equivalent Pythagorean triples


(a, b, 1) modulo p; that is, the number of solutions, modulo p, to the equation
x2 + y2 = 1, with 1 < x, y (p 1)/2. Thus, we begin by considering
X  1 x2 
S=
p
2xp2

It follows from Exercise 14.3 in [1] that


S = 1

1
p

A related formula also appears as Problem 8.a on Page 97 in [2], as well as in


the proof of Theorem 10-1 in [3].
Suppose that S has P terms equal to +1 and N terms equal to 1. Then
we have


1
P +N = p3
and
P N = 1
p

so that

1
P =
2

p4

1
p



Again, P counts the number of x [2, p 2] with 1 x2 a square modulo p.


We now consider two cases.
Case 1: p 3 or 5 (mod 8). Then 1 does not have an isosceles sibling,
and hence a given Pythagorean triple (a, b, 1), with 1 < a < b (p 1)/2,
contributes +4 to P : +1 for each of x = a, x = b, x = p b, and x = p a.
Thus,

p 3 if p 3 (mod 8)
P
8
p(1) =
= p
5

if p 5 (mod 8)
8
8

Case 2: p 1 or 7 (mod 8). Then 1 does have an isosceles sibling, say,


(a, a, 1). This Pythagorean triple contributes +2 to P , +1 for each of x = a
and x = p a. Also, as in Case 1, any given non-isosceles Pythagorean triple
(a, b, 1) contributes +4 to P . Thus,

p 1
if p 1 (mod 8)
P +2 8
p (1) =
= p+1

if p 7 (mod 8)
8
QED

Remark: Some work has been done on determining the number of consecutive quadratic residues modulo an odd prime p, that is, the number of pairs
(n, n + 1) with 1 n < p 1 such that both n and n + 1 are squares mod p.
For example, Theorem 10-1 in [3] states that the number C(p) of consecutive
quadratic residues mod p is given by



1
1
C(p) =
p4
4
p
We find it interesting that 2C(p) = P , where, as in the proof of Theorem 8, P
is the number of x [2, p 2] with 1 x2 a square mod p.
Here are a few exercises for the reader.
Exercise 1: Combine Theorem 8 with Corollary 5 to obtain an explicit formula
for N (p) (the number of non-equivalent Pythagorean triples modulo p).
Exercise 2: Prove that p0 (1) is equal to the the integer nearest (p 6)/8.
Hint: p0 (1) is equal to p (1), if 2 is not a square mod p, and otherwise is one
less than p (1).
Exercise 3: Obtain an explicit formula relating N (p) and C(p). (Refer to the
remark following the proof of Theorem 8.)
We end with an example.
Example 2: We use Theorem 8 and Corollary 5 to compute N (p) for several
primes one for each case of the formula in Theorem 8:
61 5
8
79 + 1
p = 79 79 mod 8 = 7 79 (1) =
8
83 3
p = 83 83 mod 8 = 3 83 (1) =
8
97 1
p = 97 97 mod 8 = 1 97 (1) =
8
p = 61 61 mod 8 = 5 61 (1) =

61 1
2
79 1
= 10 N (79) =
2
83 1
= 10 N (83) =
2
97 1
= 12 N (97) =
2
=7

N (61) =

7 = 210
10 = 390
7 = 410
12 = 576

Each of these results was confirmed by Mathematica using the function


PythagoreanTriples, and the Length function, which returns the length of
a list. For instance, when we enter
Length[PythagoreanTriples[97]]
Mathematica returns the result 576, confirming that there are, indeed, 576 nonequivalent Pythagorean triples modulo the prime 97.

10

References
[1] J.-M. De Konick and F. Luca, Analytic Number Theory: Exploring the
Anatomy of the Integers, American Mathematical Society, 2012.
[2] I. M. Vinogradov, Elements of Number Theory, Dover, 1954.
[3] Edwards, George E. Number Theory, Dover, 1994.
[4] Dummit, David S. and Foote, Richard M., Abstract Algebra, Third
Edition, Wiley, 2003.

11

About the authors:


Bernard Moore is a full-time graduate student at Stony Brook University pursuing his Masters degree in pure mathematics. Lately, he has acquired several
interests beyond just pure mathematics. This past summer, he was proud to
be part of the Summer Faculty Fellowship Program (SFFP) at Edwards Air
Force Base, where he obtained hands-on experience with computer programming, aerodynamics, and fluid dynamics. Currently, his research group is creating pressure and density animations for 2D-airfoils, to model the transonic
shock of the F-16 wing near Mach 1. It has become important to Bernard to
understand and appreciate the power of theoretical mathematics and its applications. Following his graduation from Stony Brook University, he would like
to pursue his PhD in Applied Mathematics.
Joseph Straight is currently Chair of the Department of Mathematical Sciences at SUNY Fredonia. He obtained PhD in Graph Theory from Western
Michigan University in 1977. Dr. Straight has been teaching at SUNY Fredonia since then, with the exception of one year, when he was a visiting professor
at Clemson University. He has taught courses ranging from calculus to linear
algebra and number theory, at the undergraduate level, and graduate courses in
symmetry and the theory of equations. Nothing gives him more pleasure than
to mentor talented students, such as Bernard. His very first article appeared in
the Pi Mu Epsilon Journal in 1975!
The present article began as Bernards Senior Honors Thesis, in Spring 2010.
His advisor, Dr. Straight, was also Bernards professor for courses in number
theory and abstract algebra. After taking these two courses with Dr. Straight,
Bernard asked Dr. Straight to be the advisor for his thesis. In Fall 2010, Bernard
gave a poster presentation, on Pythagorean Triples Modulo a Prime, at the MAA
Seaway Section conference, held at SUNY Plattsburgh. His poster was judged
Best in Show. In Spring 2011, Bernard gave his first talk professional talk,
on the same topic, at the MAA Seaway Section conference held at Nazareth
College. Since his graduation in 2011, Bernard has continued to collaborate
with Dr. Straight, and they hope to publish more articles together.

12

Bernard M Moore
111 Seward Avenue
Utica, NY 13502
bernard.moore@stonybrook.edu

H. Joseph Straight
Department of Mathematical Sciences
212 Fenton Hall
SUNY Fredonia
Fredonia, NY 14063
joseph.straight@fredonia.edu

13

Вам также может понравиться