Homepage › Solution manuals › Ivan Niven › An Introduction to the Theory of Numbers › Exercise 3.3.18* (Probability to draw consecutive residues)
Exercise 3.3.18* (Probability to draw consecutive residues)
Let be an odd prime, and let denote the number of , , such that . Show that . Similarly define and evaluate , and .
Hint. Show first that . Then use the results of Problems 5 and 17.
Answers
Same problem as in the more detailed exercises in Ireland, Rosen, Ex. 5.29, 5.30, 5.31. I used some “copy and paste”. After proofreading and corrections, I propose this solution.
Proof.
- (a)
-
Let
. Then
.
Write the set of integers such that and are both quadratic residues modulo , and its cardinality, and similar definitions for . So
As (disjoint union),
The union is the set of such that is a quadratic residue. Its cardinality is the number of quadratic residues in , that is the number of quadratic residues in , minus , where if is a residue, otherwise. Since , we obtain , and the total number of quadratic residues is , thus
Similarly, is the number of quadratic nonresidues in , minus , where if is a quadratic nonresidue, otherwise : , so
(the sum of these two results is indeed ).
Since is a residue, is the number of quadratic residues in , minus :
is the number of quadratic nonresidues in , equal to the number of quadratic residues in :
- (b)
-
Let
be the characteristic function of
. If
,
if
are both quadratic residues, or if
are both quadratic nonresidues. Then
(if , and otherwise.)
Similarly, let be the characteristic function of the complement . Then if exactly one of the integer is a residue, otherwise. Then , so that
Since
we obtain
Therefore
By Problem 17,
Therefore
- (c)
-
To summarize the results of parts (a) and (b),
and
The sum of (1) and (2) gives
The sum of (3), (4), (5) gives, using (1),
thus
So
- (d)
-
Then, by equations (5) and (6),
By equations (3) and (6),
Finally, by equations (4) and (6),
In summary,
Note: The probability, by drawing an integer at random between and , of obtaining two consecutive quadratic residues and , is , which is roughly , as expected.
Check with Sage:
def Npp(p): N = 0 for n in range(1, p-1): if kronecker(n,p)== 1 and kronecker(n+1,p) == 1: N += 1 return N
etc.
lg = kronecker p = 11213 print(Npp(p), Nmm(p), Npm(p), Nmp(p)) print((p - lg(-1,p) - 4) // 4, (p + lg(-1,p) - 2) // 4, (p - lg(-1,p)) // 4, (p + lg(-1,p) - 2) // 4) (2802, 2803, 2803, 2803) (2802, 2803, 2803, 2803)