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 p be an odd prime, and let N ++ ( p ) denote the number of n , 1 n p 2 , such that ( n p ) = ( n + 1 p ) = 1 . Show that N ++ ( p ) = ( p ( 1 p ) 4 ) 4 . Similarly define and evaluate N +− ( p ) , N −+ ( p ) , and N −− ( p ) .

Hint. Show first that N ++ ( p ) = 1 4 n = 1 p 2 ( 1 + ( n p ) ) ( 1 + ( n + 1 p ) ) . 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 E = [ [ 1 , p 2 ] ] . Then | E | = p 2 .

Write R ++ the set of integers n E such that n and n + 1 are both quadratic residues modulo p , and N ++ = | R ++ | its cardinality, and similar definitions for R +− , R −+ , R −− . So

R ++ = { n [ [ 1 , p 2 ] ] ( n p ) = + 1  and  ( n + 1 p ) = + 1 } , N ++ = | R ++ | , R +− = { n [ [ 1 , p 2 ] ] ( n p ) = + 1  and  ( n + 1 p ) = 1 } , N +− = | R +− | , R −+ = { n [ [ 1 , p 2 ] ] ( n p ) = 1  and  ( n + 1 p ) = + 1 } , N −+ = | R −+ | , R −− = { n [ [ 1 , p 2 ] ] ( n p ) = 1  and  ( n + 1 p ) = 1 } , N −− = | R −− | .

As E = R ++ R +− R −+ R −− (disjoint union),

N ++ + N +− + N −+ + N −− = | E | = p 2 .

The union R ++ R +− is the set of n E such that n is a quadratic residue. Its cardinality is the number of quadratic residues in [ [ 1 , p 2 ] ] , that is the number of quadratic residues in [ [ 1 , p 1 ] ] , minus s , where s = 1 if p 1 1 is a residue, s = 0 otherwise. Since ( 1 p ) = ( 1 ) ( p 1 ) 2 , we obtain s = 1 + ( 1 ) p 1 2 2 , and the total number of quadratic residues is ( p 1 ) 2 , thus

N ++ + N +− = p 1 2 s = p 1 2 1 + ( 1 ) p 1 2 2 = 1 2 ( p 2 ( 1 ) p 1 2 ) .

Similarly, N −+ + N −− is the number of quadratic nonresidues in [ [ 1 , p 1 ] ] , minus t , where t = 1 if p 1 is a quadratic nonresidue, t = 0 otherwise : t = 1 ( 1 ) p 1 2 2 , so

N −+ + N −− = 1 2 ( p 2 + ( 1 ) p 1 2 )

(the sum of these two results is indeed p 2 = | E | ).

Since 1 is a residue, N ++ + N −+ is the number of quadratic residues in [ [ 1 , p 1 ] ] , minus 1 :

N ++ + N −+ = p 1 2 1 .

N +− + N −− is the number of quadratic nonresidues in [ [ 2 , p 1 ] ] , equal to the number of quadratic residues in [ [ 1 , p 1 ] ] :

N +− + N −− = p 1 2 .

(b)
Let χ be the characteristic function of R ++ R −− . If 1 n p 1 , χ ( n ) = 1 if n , n + 1 are both quadratic residues, or if n , n + 1 are both quadratic nonresidues. Then χ ( n ) = 1 2 ( 1 + ( n p ) ( n + 1 p ) )

(if χ ( n ) = 1 , ( n p ) ( n + 1 p ) = 1 , and ( n p ) ( n + 1 p ) = 1 otherwise.)

Similarly, let χ be the characteristic function of the complement R +− R −+ . Then χ ( n ) = 1 if exactly one of the integer n , n + 1 is a residue, 0 otherwise. Then χ ( n ) = 1 χ ( n ) , so that

χ ( n ) = 1 2 ( 1 ( n p ) ( n + 1 p ) ) .

Since

| R ++ R −− | = n = 1 p 1 χ ( n ) | R +− R −+ | = n = 1 p 1 χ ( n ) ,

we obtain

N ++ + N −− N +− N −+ = | R ++ R −− | | R +− R −+ | = n = 1 p 1 ( χ ( n ) χ ( n ) ) .

Therefore

N ++ + N −− N +− N −+ = n = 1 p 1 ( χ ( n ) χ ( n ) ) = 1 2 n = 1 p 1 ( 1 + ( n ( n + 1 ) p ) ) ( 1 ( n ( n + 1 ) p ) ) = n = 1 p 1 ( n ( n + 1 ) p )

By Problem 17,

n = 1 p 1 ( n ( n + 1 ) p ) = n = 1 p ( n ( n + 1 ) p ) = s ( 1 , p ) = 1 .

Therefore

N ++ + N −− N +− N −+ = n = 1 p 1 ( n ( n + 1 ) p ) = 1 .

(c)
To summarize the results of parts (a) and (b), N ++ + N +− + N −+ + N −− = p 2 (1) N ++ + N −− N +− N −+ = 1 (2)

and

N ++ + N +− = 1 2 ( p 2 ( 1 ) p 1 2 ) (3) N ++ + N −+ = p 1 2 1 (4)

The sum of (1) and (2) gives

N ++ + N −− = p 3 2 . (5)

The sum of (3), (4), (5) gives, using (1),

2 N ++ + p 2 = p 2 2 + p 1 2 + p 3 2 1 ( 1 ) p 1 2 2 ,

thus

2 N ++ = p 1 2 + p 3 2 p 2 2 1 ( 1 ) p 1 2 2 = p 2 2 ( 1 ) p 1 2 2 .

So

N ++ = 1 4 ( p ( 1 p ) 4 ) . (6)
(d)
Then, by equations (5) and (6), N −− = p 3 2 1 4 ( p ( 1 p ) 4 ) = 1 4 ( p + ( 1 p ) 2 ) .

By equations (3) and (6),

N +− = 1 2 ( p 2 ( 1 p ) ) 1 4 ( p ( 1 p ) 4 ) = 1 4 ( p ( 1 p ) ) .

Finally, by equations (4) and (6),

N −+ = p 3 2 1 4 ( p ( 1 p ) 4 ) = 1 4 ( p + ( 1 p ) 2 ) .

In summary,

N ++ = 1 4 ( p ( 1 p ) 4 ) , N −− = 1 4 ( p + ( 1 p ) 2 ) , N +− = 1 4 ( p ( 1 p ) ) , N −+ = 1 4 ( p + ( 1 p ) 2 ) .

Note: The probability, by drawing an integer n at random between 1 and p 2 , of obtaining two consecutive quadratic residues n and n + 1 , is N ++ ( p 2 ) , which is roughly 1 4 , 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)

User profile picture
2024-11-07 10:35
Comments