Vol 9
o.
2 (1986) 261-266SEQUENCES
IN POWER RESIDUE CLASSES
261
DUNCAN A. BUELL
Department of Computer Science Louisiana State University
Baton Rouge, LA 70803
and
RICHARD H.
HUDSON
Department of Mathematics University of South Carolina
Columbia, SC 29208 (Received June 13, 1985)
ABSTRACT. Using A. Well’s estimates the authors have given bounds for the largest prime
P0
such that all primes PPO
have sequences of quadratic residues of length m. For m 8 the smallest prime having m consecutivequadraticresidues is 3(mod 4) andP0
E (mod 4). The reason for this phenomenon is investigated in this paper andth the theory developed is used to successfully uncover analogous phenomena for r power residues, r 2, r even.
KEY
WORDSAND
PHRASES.Sequences
of
consecutive rpower residues,
random
sequences
of
zerosand ones,
linearleast
squares
fit.
I. INTRODUCTION.
In [I] the authors used Well’s estimates
[2]
togive explicit bounds for the largest primeP0
such that all primes PP0
have sequences of quadratic residues of pre-assigned length m. Unexpectedly, the authors discovered that for all m < 8thesmallest primes having m consecutive quadratic residues are congruent to 3(mod r) and that P0 is l(mod 4).
In this paper we develop a theory which suggests that primes E 3(mod 4) can be expected to have a longest sequence of quadratic residues (or non residues) whichis, in the mean, approximately one longer that the longest sequence for primes l(mod 4) of conparable size. Data in Table support this theory.
Using our theory we predicted that primes 5(mod 8) can be expected to have a longest sequence of quadratic residues which is, in the mean, about
I/2
longer than the longest sequence for primes l(mod 8) of comparable size. This is supported by data in Table 2. In Table 5 we observe that (as aconsequence) the smallest primes E l(mod 4) having a sequence of 1,2,3 I0 consecutive quadratic residues, respectively, are allThe data in Tables 3 and 4 support our theory regarding the approximate magnitude th
of the mean excesses in the lengths of the longest r power residue sequences, r 2 and even, for primes E r+l (mod 2r) versus the corresponding mean lengths for prime
E l(mod
2r);
data is supplied for r 6,8.Additional supporting’material can be obtained from the first author in
[3]
where thdata for all cosets formed with respect to the subgroup of r powers (mod
p)
is presented and the mean value of the longest sequence in any coset is observed to be closely approximated bylogrp
for all integers r_>
2, 70,000 < p <300,000; see Table 6. 2. NOTATION.th For each fixed r let n(p) denote the length of the longest sequence of r power residues modulo the prime p which, as customary,wetaketo be E l(mod r). We let m(g) be the smallest prime p such that n(p) and m(g) the largest prime such that
n(p)
3. RANDOM
SEQUENCES
OF ZEROS AND ONES.Consider all n-character strings of t zeros and n-t ones. For convenience we shall call a substring of E or more consecutive zeros an E-substring. If X is an event which is a function of a variable x and which happens with probability P(X) we shall say that X happens almost surely if
P(X)
tends to as x tends to infinity.Let R(n,,t) denote the number of n-character strings with t zeros and n-t ones which do not contain and -substring.
THEOREM 3.1 For n t > > O, we have
(a) R(n+l,E,t) R(n,,t)
+
R(n,,t-l) R(n-,,t-l), (b) R(n,E,t)i>O
PROOF. The recursion for part (a) is easy. If we append a
"l"
to and n-character string with no -substring then we get an (n+l)-character string with no -substring, accounting for the addend R(n,,t). If we append a"0"
to an n-character string with no -substring then we get an (n+i)-character string which has no -substring unless the original string ended with -1 zeros, accounting for the second and thrird addends on the right-hand-side of formula (a).To prove (b) we use the two variable generating function F(x,y)
R(n,,t)
(xn-t) (yt).
Using the recursion in
(a)
and taking into account the "initial conditions" we getF xF
+
yF
xyF
+
yThus
l-y G
F(x,y)
l-x-y+xyE l-xG
where (; G(y)
(l-yE)/(1-y).
The remainder of the proof is easily supplied by the reader using simple algebra to extract coefficients.Let s(n,E,t) denote the number of n-character strings with t zeros and n-t other digits, 0 through r-l, with no E-substring. We may omit the proof of the following theorem as its proof is entirely similar to the above.
THEOREM 3.2
SEQUENCES IN POWER RESIDUE CLASSES 263
(b)
Sr(n,,t)
(-l)i(r-l) n-t+l-i’n-t+l(
i)(.n-in_t)
i=OLet v(n) denote the length of the longest -substring and w(n) denote any function such that w(n) tends to infinity as n tends to infinity.
THEOREM 3.3 Consider an arbitrary n-character string having t zeros. (a) Let X be the event that there exists at least one -string. Then
P(X
I)
<n().
(b) If n rt then
v(n)
logr(n)+w(n)
almost surely does not happen. (c) Let X2 be the event that there exists no -substrlng. Then P(E
2)
)()(I
+
n(t-)
(d) If n rt then
v(n)
logrn-W(n)
almost surely happens. PROOF.(a) The probability that at least one -substrings. Thus
n-(t-)
P(X
I)
(n-+l)-n
(n-+l)(a),
twhere
t(t-l)...(t-+l) a
n(n-l)...(n-+l)
Henceforth, we assume the easy inequality t-I t
for n t > i 0, n-i n
from which it follows that
a
<(t/n)
so that P(XI)
<n(t/n)
(b) Let n rt and apply part (a). Then
P(X
I)
<n()
n(r-
).-
-w(n)r
/n.
As n tends to infinity, If logr(n)
+
w(n), then rP(X
I)
r-w(n) tends to zero.(c) Let X be the number of -substrings. Using an appropriate version of
Chebyshev’s
inequality we haveE(X2)
I. <
P(X2)
E2(X)
As before,
E(X)
(n-+l)(a).
It is not difficult to see thatn-2+2 n-2
E(X
2)()
2(2
(t-2)
-I
n-2+i,
n-+
2 (n-2+l+i)(t_2+i)
+
(n-+l)(t_).
i=l Then
-I
n-2+2 2(
2
)a2
+
2(n-2+l+i)a2_i
+
(n-+l)(a)
i=lP(X2)
-I.Using the
aforementioned
inequality
we have 2
a2
<a
so that(n-2+2) (n-2+I)
(a2)
a2_i
n-
i2
<I,
2-<
(_-)
(n-+l)a
a
Cosequently,
n-2+2 2
2
)a2+2
"
(n-2+I+i)a2-i
i=]
P(X
2)
<-I
(n-+l)2 a2
2 (n-2+I+i)
a2_i
P(X2
i=l <..,2
[
a2-i
2 2
(.-i
2(n-+l)
a
i=la
so that
or
n2
n-
i 2n-
t- iP(X2)
<(-+I)
i=l
(t--)
(n-+l)(t-)
(i=l
(n-)
Summing the geometric series completes the proof of
(c).
(d) Let n rt so that by part (c)
2r (r-l)
P(X2)
<(n(r-i)
(r) (I+
n-r
Let =log
r n-w(n). Then there is a constant m such that < m log n so that 2(r_ .m2
log2n
(I
+
(r-I)
< exp( < expn-r
n-r
[n-2m
log nFor large n this is easily bounded by 2 so that
4r 4r
riO
-w(n)
P(X
2)
(n(r_l)) (r)
(n(r_l))
grn)r
4r
(_l)r
-w(n)
0 as n completing the proof of Theorem 3.3.4.
CONSEQUENCES
OF 3.th We can visualize coset membership formed with respect to the subgroup of r powers (mod p) as a string of digits, each digit from the range 0 to r-l, with 0
corre-th
sponding to the r powers. These strings are clearly not randomly determined. None-theless the theory in 3 suggests that to the extent that
n(p)
can be thought of as a random variable we should expect its mean value to be on the order oflogrp.
Specifically, in Table 6 we give coefficients a and b produced by a linear least squares fit of n(p) to n(p) m In p+b.Tables to 6 illustrate the central feature of this note. If r is even and th
2 then we have (p-l)/2r r powers (and similarly for the other r-1 cosets formed th
with respect to the subgroup of r powers (mod
p))
in the interval to(p-l)/2
if p l(mod 2r) and in the interval to p-1 if p r+l(mod2r).
Data in the following tables suggest that mean lengths of n(p) for primes r+1(mod 2r) exceed those for primes E 1(mod 2r) by in 2/in r for reven and 2. The mean dif-ference of
I,
e.g., for r=2 translates into an expected value forn(p)
forp 3(mod 4) equal to the expected value for
N(q)
for aSEQUENCES
IN POWER RESIDUE CLASSESThe theory which allows us to conjecture approximate mean differences in n(p) between the residue classes produces estimates which are startlingly close to actual data given the obvious differences between r th power residue distributions and random character strings. However, our theory represents only a partial first hypothesis, and a superior explanation for the phenomenon described here may well be developed. None-theless statistical tests (see
[4]
for the standard Z-test) provides better than 99% confidence that primes l(mod 2r) and primes r+l(mod 2r), r=2,4,6,8, constitute two entirely different sample populations.Of course this note raises a number of questions, many very difficult. Even for r 2 it is not at all obvious for large % whether the probability that
m() 3(mod 4) and m(E) E 1(mod 4) increases or decreases or even has a limit as % goes to infinity.
5. COMPUTATION. Originally computations were done in VS FORTRAN
(IBM’s
FORTRAN 77) on the IBM 3033N of the System Network Computer Center at Louisianna State University. The computation was redone, also in FORTRAN, on the VAX11/780
running VMS of the Department of Computer Science at L.S.U. Most of the statistical results were obtained using SAS on the IBM 3033.Table i r 2
Difference Primes l(mod
4)
Primes E 3(mod 4) in MeanRange #p Mean Dev. #p Mean Dev.
n
r/En 2 i<70000 3449 12.738 2.4q6 3485 13.809 2.445 1.071
140000 3029 14.938 1.995 3046 16.007 1.905 1.069
210000 2914 15.731 1.969 2883 16.742 1.907 1.011 280000 2790 16.234 1.992 2835 17.245 1.923 1.011
350000 2762 16.566 2.046 2783 17.572 1.946 1.006
420000 2709 16.886 1.982 2704 17.897 1.941 1.011
Table 2 r 4
Difference Primes
=-
l(mod 8) Primes 5(mod8)
in MeanRang. #p Mean Dev. #p Mean Dev. r/En 2 0.5
<70000 1820 6.359 1.438 1860 6.985 1.302 .626
140000 1606 7.545 1.173 1620 8.078 0.959 .533
210000 1549 7.954 1.170 1535 8.506
1.024
.552280000 1482 8.172 1.083 1508 8.672 0.967 .500
Table 3 r 6
Primes l(mod 12) Primes 7(mod
12)
Difference in Mean
<70000 1830 4.892 1.073 1851 5.307 1.019 .415
140000 1601 5.737 0.857 1624 6.206 0.794 .469
210000 1537 6.064 0.864 1548 6.438 0.763 .374
280000 1499 6.253 0.822 1480 6.680 0.766 .427
Range
70000 140000 210000 280000
Table 4: r 8
Primes
-=
l(mod 16) Primes 9(mod16).
#p Mean Dev. #p Mean Dev.
909 4.183 1.011 911 4.535 0.821
803 4.923 0.857 803 5.296 0.693
776 5.173 0.776 773 5.542 0.683
739 5.361 0.872 743 5.681 0.730
Difference in Mean %n r/En2--.333..
.352 .373 .369 320
Table 5: r 4
m()
m()m()(mod 8)
m()(mod
8)i 5 41 5 1
2 37 1153 5 1
3 29 2689 5 1
4 i01 32233 5 1
5 269 103529 5 1
6 389 5
7 661 5
8 1301 5
9 4621 5
i0 4261 5
Table 6: Regression
n(p),
mnp
+__b
70000 < p < 300000
b i/En r
r m
2 1.436 -1.088 1.443
3 0.910 -0.970 0.910
4 0.726 -0.608 0.721
5 0.612 -0.622 0.621
ACKNOWLEDGMENTS. We wish to express sincere thanks to Andrew Thomason, who has de-clined to accept co-authorship of this paper, for insight, help and particulary for suggestions regarding the theorems in 3.
REFERENCES
i. BUELL, D. A., and HUDSON, R. H.,
"On
Runs of Consecutive Quadratic Residues and and Quadratic Nonresidues", BIT 24 (1984), 243-247.2. WELL, A.,
"Su
les CourbesAlgbriques
et les Varietes quis’en
Deduisent", Actualites Math. Sci. No. 1041 (Paris, 1945),deuxime
partie, Section IV. 3. BUELL, D.A.,
and HUDSON, R. H.,"Sequences
in Power Residue Classes", L.S.U.Com-puter Science Technical
Report,
BatonRouge,
LA.