# TRIPLES AND QUADRUPLES OF CONSECUTIVE SQUARES
OR NON-SQUARES IN A FINITE FIELD

STEPHEN D. COHEN 1116 Bracken Road, Portlethen, Aberdeen AB12 4TA, Scotland,
UK<EMAIL_ADDRESS>formerly Professor of Number Theory, University
of Glasgow, Scotland, UK

###### Abstract

Let $\mathbb{F}_{q}$ be the finite field of odd prime power order $q$, We find
explicit expressions for the number of triples
$\\{\alpha-1,\alpha,\alpha+1\\}$ of consecutive non-zero squares in
$\mathbb{F}_{q}$ and similarly for the number of triples of consecutive non-
square elements. A key ingredient is the evaluation of Jacobsthal sums over
general finite fields by Katre and Rajwade. This extends results of
Monzingo(1985) to non-prime fields. Curiously, the same machinery alows the
evaluation of the number of consecutive quadruples
$\\{\alpha-1,\alpha,\alpha+1,\alpha+2\\}$ of square and non-squares over
$\mathbb{F}_{q}$, when $q$ is a power of 5.

###### keywords:

finite fields, squares and non-squares Jacobsthal sums

2010 Mathematics Subject Classification: 11T24, 11T30, 16U99

##  1 Introduction

Let $\mathbb{F}_{q}$ the the finite field of order $q=p^{d}$, where $q$ is an
odd prime. The elements of $\mathbb{F}_{q}$ comprise $\frac{q-1}{2}$ elements
that are non-zero squares of elements of $\mathbb{F}_{q}$ (quadratic residues)
$\frac{q-1}{2}$ non-square elements (quadratic non-resdues) together with $0$.

In brief, the purpose of this note is to provide an expression for the number
of triples of consecutive elements of $\mathbb{F}_{q}$ which are either all
non-zero squares or all non-squares. To clarify this we summarise what is
meant by consecutive elements. If $q=p$, an odd prime, the members of
$\mathbb{F}_{p}$ possess a natural cyclic ordering $(0,1,2,\ldots,p-1)$ and a
run of distinct consecutive elements
$\\{\alpha,\alpha+1,\ldots,\alpha+\ell-1\\}$ has length $\ell$ not exceeding
$p$. For a general prime power $q=p^{d}$, if $\alpha,\beta\in\mathbb{F}_{q}$
are defined to be equivalent when $\alpha-\beta\in\mathbb{F}_{p}$, then
$\mathbb{F}_{q}$ is divided into $p^{d-1}$ equivalence class of the form
$\alpha+\mathbb{F}_{p}$, whose elements can be cyclically ordered
corresponding to the ordering of the elements of $\mathbb{F}_{p}$. Again, the
length of a maximum run of consecutive elements of $\mathbb{F}_{q}$ is $p$.

In particular, given any element $\alpha\in\mathbb{F}_{q}$, call
$\mathcal{T}_{\alpha}$ the triple of consecutive elements
$\\{\alpha-1,\alpha,\alpha+1\\}$ in $\mathbb{F}_{q}$. Define $M_{q}$ to be the
number of $\alpha\in\mathbb{F}_{q}$ such that the members of
$\mathcal{T}_{\alpha}$ are all non-zero squares. Sinilarly, define $N_{q}$ to
be the number of $\alpha\in\mathbb{F}_{q}$ such that the members of
$\mathcal{T}_{\alpha}$ are all non-squares. In the situation in which $q=p$, a
prime, Monzingo [12] evaluated each of $M_{q}$ and $N_{q}$ in four cases. Our
theorem subdivides one of these into two (Cases 4 and 5 below) to cater for
square prime powers $q$.

######  Theorem 1.1.

Let $q=p^{d}$, where $p$ is an odd prime..

Case 1. If $q\equiv 7\ (\mathrm{mod}\;8)$, then

$M_{q}=N_{q}=\frac{q-7}{8}.$ (1.1)

Case 2. If $q\equiv 3\ (\mathrm{mod}\;8)$, then

$M_{q}=N_{q}=\frac{q-3}{8}.$ (1.2)

Case 3. If $q\equiv 5\ (\mathrm{mod}\;8)$, then

$M_{q}=\frac{q+2s-7}{8};\quad N_{q}=\frac{q-2s-3}{8},$ (1.3)

where integers $s,t$ are uniquely defined by by $q=s^{2}+t^{2},p\nmid
s,s\equiv 1\ (\mathrm{mod}\;4)$.

Case 4. If $q=p^{d}\equiv 1\ (\mathrm{mod}\;8)$, where $p\equiv 1\
(\mathrm{mod}\;4)$, then

$M_{q}=\frac{q-2s-15}{8};\quad N_{q}=\frac{q+2s-3}{8},$ (1.4)

where integers $s,t$ are defined as in Case $3$.

Case 5. If $q=p^{d}\equiv 1\ (\mathrm{mod}\;8)$, where $p\equiv 3\
(\mathrm{mod}\;4)$, then $q$ is a square and

$M_{q}=\frac{1}{8}\left(q-2(-1)^{d/2}\sqrt{q}-15\right);\quad
N_{q}=\frac{1}{8}\left(q+2(-1)^{d/2}\sqrt{q}-3\right).$ (1.5)

A key ingredient to our proof of Theorem 1.1 is the extension by Katre and
Rajwsade in 1987 [9] to the classical evaluation of the Jacobsthal sum, see
Lemma 2.2. We remark that Monzingo [11] derives his version of Theorem 1.1 for
triples of quadratic residues and non-residues modulo a prime $p$ by
elementary means. In [12] he shows the connection with Jacobsthal sums by
deriving the latter out of considerations of the distribution od quadratic
residues and non-residues modulo $p$

The author’s work on Theorem 1.1 in respect of consecutive triples of non-
squares was originally presented in [1] (whiich remains unpublished). Its
motivation came from commutative ring theory. Let $R$ be an integral ring (or
domain), see [1] and Theorem 4.3, below. An element $\alpha\in R$ is called an
$k$-potent if $\alpha^{k}=\alpha$. Use of Theorem 1.1 (not just for prime
fields) allows the classificaton of integral rings for which for some positive
integer $n$, each matrix in $M_{n}(R)$ is the sum of a tripotent (3-potent)
and a $k$-potent. Counting consecutive triples (or longer runs) of squares and
non and non-squares is also relevant to counting points om elliptic curves
over $\mathbb{F}_{q}$, see [10].

Following Theorem 1.1, one might contemplate the evaluation of consective
qudruples (say,$\\{\alpha-1,\alpha,\alpha+1,\alpha+2\\}$) in $\mathbb{F}_{q}$
that are either all non -zero squares or all non-squares, although one would
suspect this would involve the evaluation of character sums of higher degree.
(Here to insist that the quadruples contain distinct elements one would assume
that the characteristic $p$ is at least 5). Surprisingly, perhaps, when $p=5$
(and only then), we are able to evaluate these numbers using nothing beyond
Lemma 2.2.

######  Theorem 1.2.

Let $q=5^{d}$ and $m_{q},n_{q}$ denote respectively, the numbe of quadruples
$\\{\alpha-1,\alpha,\alpha+1,\alpha+2\\}$ of consecutive members of
$\mathbb{F}_{q}$ that are all non-zero squares or all non-squares. Define
integers $s,t$ as in Case $3$ of Theorem 1.1. Then, if $d$ is even, we have

$m_{q}=\frac{q-10s-39}{16};\quad n_{q}=\frac{q+6s-7}{16}.$ (1.6)

If, on the other hand, $d$ is odd, then

$m_{q}=n_{q}=\frac{q+2s-7}{16}.$ (1.7)

##  2 Character sums

Suppose throughout $q=p^{d}$ is an odd prime power and let $\lambda$ be the
quadratic character on $\mathbb{F}_{q}$. Thus

$\sum_{\alpha}\lambda(\alpha)=\sum_{\alpha\neq 0}\lambda(\alpha)=0,$ (2.1)

where $\displaystyle{\sum_{\alpha}}$ stands for
$\displaystyle{\sum_{\alpha\in\mathbb{F}_{q}}}$ and
$\displaystyle{\sum_{\alpha\neq 0}}$ means that $\alpha=0$ is excluded from
the sum. We need further evaluations of character sums. The first can be found
in [4, Theorem 2.1.2].

######  Lemma 2.1.

Suppose $q$ is an odd prime power. Let $f(x)=x^{2}+bx+c\in\mathbb{F}_{q}[x]$.
Assume $b^{2}-4c\neq 0$. Then

$\sum_{\alpha\in\mathbb{F}_{q}}\lambda(f(\alpha))=-1.$

The next result concerns the Jacobsthal sum
$\displaystyle{J(a)=\sum_{\alpha}\lambda(x(x^{2}+a)),a\in\mathbb{F}_{q}}$.
Recall that

$\lambda(-1)=\begin{cases}1,&\text{if }q\equiv 1\ (\mathrm{mod}\;4),\\\
-1,&\text{if }q\equiv 3\ (\mathrm{mod}\;4).\end{cases}$

Hence, by replacing $\alpha$ by $-\alpha$ in the expression for $J(a)$, we see
that, if $q\equiv 3\ (\mathrm{mod}\;4)$, then $J(a)=0$. On the other hand,
when $q\equiv 1\ (\mathrm{mod}\;4)$, we use an extension of the classical
evaluation of the Jacobsthal sum on prime fields given by Katre and Rajwade
[9] For any $q\equiv 1\ (\mathrm{mod}\;4)$, they evaluate $J(a)$ for any non-
zero $a\in\mathbb{F}_{q}$. We only require the case in which $a$ is a square
in $\mathbb{F}_{q}$.

######  Lemma 2.2 ([9],Theorem 2).

Suppose that $q=p^{d}\equiv 1\ (\mathrm{mod}\;4)$, where $p$ is an odd prime
and $a$ is a square in $\mathbb{F}_{q}$. If $p\equiv 3\ (\mathrm{mod}\;4)$ (so
that $d$ is even), let $s=(-1)^{d/2}\sqrt{q}$. If $p\equiv 1\
(\mathrm{mod}\;4)$, define $s$ uniquely by $q=s^{2}+t^{2},p\nmid s,s\equiv 1\
(\mathrm{mod}\;4)$. Then

$J(a)=\begin{cases}-2s,&\mbox{ if $a$ is a fourth power in
$\mathbb{F}_{q}$,}\\\ 2s,&\mbox{ if $a$ is a square but not a fourth power in
$\mathbb{F}_{q}$.}\end{cases}$

##  3 Proof of Theorem 1.1

Obviously, a triple $\mathcal{T}_{\alpha}$ cannot comprise only non-zero
squares or only non-squares if $\alpha=0,\pm 1$. Hence, we avoid consideration
of such triples.

As a further preliminary, observe that, if $q\equiv 3\ (\mathrm{mod}\;4)$ and
if $\mathcal{T}_{\alpha}$ is a triple consisting of squares, then
$-T_{-\alpha}$ is a triple of non-squares. Conseqently, in this case
$N_{q}=M_{q}$

More generally, for any odd $q$, we have

$M_{q}=\frac{1}{8}\sum_{\alpha\neq 0,\pm
1}(1+\lambda(\alpha))(1+\lambda(\alpha-1))(1+\lambda(\alpha+1)),$ (3.1)

and

$N_{q}=\frac{1}{8}\sum_{\alpha\neq 0,\pm
1}(1-\lambda(\alpha))(1-\lambda(\alpha-1))(1-\lambda(\alpha+1)).$ (3.2)

Now, set

$S_{1}=\sum_{\alpha\neq 0,\pm 1}\lambda(\alpha);\quad S_{2}=\sum_{\alpha\neq
0,\pm 1}\lambda(\alpha-1);\quad S_{3}=\sum_{\alpha\neq 0,\pm
1}\lambda(\alpha+1)$

and

$T_{1}=\sum_{\alpha\neq 0,\pm
1}\lambda(\alpha(\alpha-1));\;T_{2}=\sum_{\alpha\neq 0,\pm
1}\lambda(\alpha(\alpha+1));\;T_{3}=\sum_{\alpha\neq 0,\pm
1}\lambda(\alpha^{2}-1).$

Then

$M_{q}=\frac{1}{8}\left(q-3+\sum_{i=1}^{3}S_{i}+\sum_{i=1}^{3}T_{i}+J(-1)\right)$

and

$N_{q}=\frac{1}{8}\left(q-3-\sum_{i=1}^{3}S_{i}+\sum_{i=1}^{3}T_{i}-J(-1)\right).$

From (2.1),

$S_{1}=\sum_{\alpha}\lambda(\alpha)-1-\lambda(-1)=-1-\lambda(-1);\;S_{2}=-\lambda(-2)-\lambda(-1);\;S_{3}=-1-\lambda(2),$

whereas, from Lemma 2.1,

$T_{1}=\sum_{\alpha\neq-1}\lambda(\alpha(\alpha-1))=-1-\lambda(2);\;T_{2}=-1-\lambda(2);\;T_{3}=-1-\lambda(-1).$

Further, $J(-1)=0$ if $q\equiv 3\ (\mathrm{mod}\;4)$. But, when $q\equiv 1\
(\mathrm{mod}\;4)$, by Lemma 2.2, we have

$J(-1)=\begin{cases}-2s,&\mbox{if }q\equiv 1\ (\mathrm{mod}\;8),\\\
2s,&\mbox{if }q\equiv 5\ (\mathrm{mod}\;8).\end{cases}$ (3.3)

We also have the well-known facts that

$\lambda(2)=\begin{cases}1,&\mbox{if }q\equiv\pm 1\ (\mathrm{mod}\;8),\\\
-1,&\mbox{ if }q\equiv\pm 3\ (\mathrm{mod}\;8),\end{cases}$ (3.4)

and

$\lambda(-2)=\begin{cases}1,&\mbox{if }q\equiv 1\mbox{ or }3\
(\mathrm{mod}\;8),\\\ -1,&\mbox{ if }q\equiv 5\mbox{ or }7\
(\mathrm{mod}\;8).\end{cases}$ (3.5)

To evaluate $M_{q},N_{q}$ from (3.2), (3.3), (3.4) and (3.5). we consider in
turn the five cases of Theorem 1.1 and illustrate the result for some small
values of $q$.

Case 1: If $q\equiv 7\ (\mathrm{mod}\;8)$, then
$\displaystyle{N_{q}=\frac{q-7}{8}}.$

######  Proof 3.1.

Here $\lambda(-1)=-1,\lambda(2)=1,\lambda(-2)=-1$. Thus
$S_{1}=0,S_{2}=2,S_{3}=-2,T_{1}=T_{2}=-2,T_{3}=0$, while $J(-1)=0$. Hence

$8N_{q}=(q-3+0-4)=q-7.$

Small examples of Case 1 include $M_{7}=N_{7}=0,M_{23}=N_{23}=2$.

Case 2: If $q\equiv 3\ (\mathrm{mod}\;8)$, then
$\displaystyle{N_{q}=\frac{q-3}{8}}.$

######  Proof 3.2.

Now $\lambda(-1)=-1,\lambda(2)=-1,\lambda(-2)=1$. Thus
$S_{1}=S_{2}=S_{3}=T_{1}=T_{2}=T_{3}=0$. Also, $J(-1)=0$. The reult is now
immediate.

Small examples of Case 2 include
$M_{3}=N_{3}=0,M_{11}=N_{11}=1,M_{19}=N_{19}=2$.

Case 3: If $q\equiv 5\ (\mathrm{mod}\;8)$, then

$M_{q}=\frac{q+2s-7}{8}q;\quad N_{q}=\frac{q-2s-3}{8},$

where $q=s^{2}+t^{2},\ p\nmid s,\ s\equiv 1\ (\mathrm{mod}\;4)$.

######  Proof 3.3.

Here $q=p^{d}$, where also $p\equiv 5\ (\mathrm{mod}\;8)$ and $r$ is odd. We
have $\lambda(-1)=1,\lambda(2)=\lambda(-2)=-1$. Hence,
$S_{1}=-2,S_{2}=S_{3}=0,T_{1}=T_{2}=0,T_{3}=-2$.

Further, let $\alpha$ be a primitive element in $\mathbb{F}_{q}$. Then
$-1=\alpha^{\frac{q-1}{2}}$ is the square of $\alpha^{\frac{q-1}{4}}$ but not
a fourth power, since $\frac{q-1}{4}$ is odd. Hence $J(-1)=2s$.

Small examples of Case 3 include

$M_{5}=N_{5}=0$ (since $5=1^{2}+2^{2}$),

$M_{13}=0,\ N_{13}=2$ (since $13=(-3)^{2}+2^{2}$),

$M_{29}=4,\ N_{29}=2$ (since $29=5^{2}+2^{2}$),

$M_{125}=12,\ N_{125}=18$ (since $125=(-11)^{2}+2^{2}$ but ignoring
$125=5^{2}+10^{2}$ because $p\nmid s$).

Case 4: If $q=p^{d}\equiv 1\ (\mathrm{mod}\;8)$, where $p\equiv 1\
(\mathrm{mod}\;4)$, then

$M_{q}=\frac{q-2s-15}{8};\quad N_{q}=\frac{q+2s-3}{8},$

where $q=s^{2}+t^{2},\ p\nmid s,\ s\equiv 1\ (\mathrm{mod}\;4)$.

######  Proof 3.4.

Here $\lambda(-1)=\lambda(2)=\lambda(-2)=1$. Hence,
$S_{1}=S_{2}=S_{3}=T_{1}=T_{2}=T_{3}=-2$. This time $\frac{q-1}{4}$ is even
and so $-1$ is a fourth power and $J(-1)=-2s$.

Small examples of Case 4 include

$M_{17}=0,\ N_{17}=2$ (since $17=1^{2}+4^{2}$),

$M_{25}=N_{25}=2$ (since $25=(-3)^{2}+4^{2}$),

$M_{169}=18,\operatorname{\mathbb{N}}_{169}=22$ (since $169=5^{2}+12^{2}$),

$M_{289}=38,\ N_{289}=32$ (since $289=(-15)^{2}+8^{2}$).

Case 5: If $q=p^{d}\equiv 1\ (\mathrm{mod}\;8)$, where $p\equiv 3\
(\mathrm{mod}\;4)$, then $q$ is a square and

$M_{q}=\frac{1}{8}\left(q-2(-1)^{d/2}\sqrt{q}-15\right),\quad
N_{q}=\frac{1}{8}\left(q+2(-1)^{d/2}\sqrt{q}-3\right).$

######  Proof 3.5.

As in Case $4$, each $S_{i}$ and $T_{i}$ has the value $-2$. Again $(-1)$ is a
fourth power in $\mathbb{F}_{q}$ so that, by Lemma 2.2,
$J(-1)=-2s=-2(-1)^{d/2}\sqrt{q}$.

Small examples of Case $5$ include $M_{9}=N_{9}=0,\ M_{49}=6,\ N_{49}=4,\
M_{81}=6,\ N_{81}=12$.

##  4 Further results and remarks on triples

Although the expressions for $M_{q}$ and $N_{q}$ in Theorem 1.1 determine
these numbers precisely, the expressions in Cases 3 and 4 do not depend
explicitly on $q$ alone. To remedy this, we deduce lower bounds that depend
more explicitly on $q$.

######  Corollary 1.

Let $q=p^{d}$, where $p$ is an odd prime. Then

$N_{q}\geq\frac{1}{8}\Big{(}q-2\sqrt{q}-3\Big{)},$ (4.1)

with equality if and only if $p\equiv 3\;(\mathrm{mod}\;4)$ and $d=2m$, where
$m$ is odd. Further,

$M_{q}\geq\frac{1}{8}\Big{(}q-2\sqrt{q}-15\Big{)},$ (4.2)

with equality if and only if $p\equiv 3\;(\mathrm{mod}\;4)$ and $d=4m$.

######  Proof 4.1.

The bound $(\ref{Nbound}$ is vacuous unless $q\geq 9$ in which case, since
$|s|<\sqrt{q}$, from Cases 1–5, $N_{q}$ exceeds the right side except when
equality occurs in Case 5 with $n=2m$, $m$ odd.

Similarly, $(\ref{Mbound})$ is vacuous unless $q\geq 25$ and then the right
side exceeds the right side except in Case 5 with $4|d$.

######  Corollary 2.

For any odd prime power exceeding $9$ there exists a triple of consecutive
non-squares in $\mathbb{F}_{q}$. Further, for any
$q\notin\\{3,5,7,9,13,17\\}$, there exists a triple of consecutive non-zero
squares.

######  Proof 4.2.

Follows from Corollary 1 and the illusrasted values in the proof of Theorem
1.1.

In connection with the first existence statement of Corollary 2, we remark
that it is an immediate consequence of Theorem 1 of [7] for all odd prime
powers $q$ exceeding 169. Specifically, the latter asserts that there exists a
triple of consecutive primitive elements of $\mathbb{F}_{q}$ except when
$q\in\\{3,\ 5,\ 7,\ 9,\ 13,\ 25,\ 29,\ 61,\ 81,\ 121,\ 169\\}$. The proof of
that theorem is, however, far more intricate.

Finally, the following is the application of Theorem 1.1 (in respect of
$N_{q}$) referred to in the introduction, see [1], Lemma 2.2.

######  Theorem 4.3.

Let $m>1$ be a positive integer and $R$ be an integral ring of cardinality
$q$. If, for some positive integer $n$, each matrix in the matrix ring
$M_{n}(R)$ is representable as a sum of a tripotent and a $m$-potent, then $R$
is a finite field $\mathbb{F}_{q}$ with $q$ an odd prime power and either
$q\leq 9$ and ${\frac{q-1}{2}\big{|}(m-1)}$, or $q>9$ and $(q-1)|(m-1)$.

Further ring-theoretical consequences are given in [1], Section 6. Some
background material is in [2] and [3].

##  5 Proof of Theorem 1.2

Let $q=5^{d}$ so that $q\equiv 1$ or $5\ (\mathrm{mod}\;8)$ according as $d$
is even or odd, respectively. The result and its proof are highly
characteristic-dependent, so that the elements $\\{0,1,2,3,4\\}$ are
respectively $\\{0,1,2,-2,-1\\}$. Moreover $\lambda(\pm 1)=1$, while
$\lambda(2)=\lambda(-2)=1$ or $-1$ according as $d$ is even or odd,
respectively.

Instead of triples we now seek to count quadruples
$\mathcal{Q}_{\alpha}=\\{\alpha-1,\alpha.\alpha+1,\alpha+2\\}$ of consecutive
elements of $\mathbb{F}_{q}$ wholly consisting of non-zero squares (counted by
$m_{q}$) or of non-squares (counted by $n_{q}$). Since no element of a
relevant quadruple $\mathcal{Q}_{\alpha}$ can be zero we can suppose
$\alpha\neq 0,\pm 1,-2$. We shall call the quadruple
$\mathcal{Q}_{2}=\\{1,2,3,4\\}$ of elements of $\mathbb{F}_{5}$ the basic
quadruple. In particular, $\mathcal{Q}_{2}$ consists of non-zero squares if
$d$ is even whereas $\mathcal{Q}_{2}$ contains two squares and two non-squares
if $d$ is odd.

######  Lemma 5.1.

Suppose $q=5^{d}$, where $d$ is odd. Then $m_{q}=n_{q}$.

######  Proof 5.2.

First, observe that, since $p=5$, then any 4-element subset of an equivalence
class $\beta+\mathbb{F}_{5}$ can be arranged as a quadruple
$\mathcal{Q}_{\alpha}$ of consecutive elements. As noted, the basic quadruple
does not consist only of squares or only of non-squares. Further, if $d$ is
odd (so that $\lambda(2)=-1$), an equivalence class containing
$\beta\in\mathbb{F}_{q}\setminus\mathbb{F}_{5}$ which contains 4 non-zero
squares or 4 non-squares implies that the equivalence class which contains
$2\beta$ must contain 4 non-squares or 4 non-zero squares, respectively, i.e.,
a quadruple of consecutive non-zero squares is associated with one comprising
non-squares. The result follows.

A character sum involving a product of four linear factors is a new
consideration..

######  Lemma 5.3.

Define
$\displaystyle{V=\sum_{\alpha\in\mathbb{F}_{q}}\lambda(\alpha(\alpha-1)(\alpha+1)\alpha+2)})$.
Then

$V=\begin{cases}-2s-1,\mbox{ if d is even},\\\ \;\;\;2s-1,\,\mbox{ if d {i}s
odd},\end{cases}$

where $s$ is as in Case $3$ of Theorem 1.1.

######  Proof 5.4.

Replacing $\alpha$ by $\alpha+2$, we have

$\displaystyle V$ $\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda((\alpha+1)(\alpha+2)(\alpha+3)(\alpha+4))=\sum_{\alpha}\lambda((\alpha+1)(\alpha-1)(\alpha+2)(\alpha-2))$
(5.1) $\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda((\alpha^{2}-1)(\alpha^{2}-4))=\sum_{\alpha}\lambda((\alpha^{2}-1)(\alpha^{2}+1)).$

Now, in the sum of (5.1), set $\beta=\alpha^{2}$ and multiply by the weighting
factor $1+\lambda(\beta)$ which (correctly) assigns 2 to each non-zero square
$\beta$ (corresponding to $\pm\alpha$) and 1 for $\beta=0$. Thus

$V=\sum_{\beta}\lambda(\beta^{2}-1)+\sum_{\beta}\lambda((\beta(\beta^{2}-1))=-1+J(-1),$

by Lemma 2.1, and the result follows from Lemma 2.2.

The remainder of the proof parallels that of Theorem 1.1 in Section 3.
Corresponding to (3.1) and (3.2), we have

$m_{q}=\frac{1}{16}\sum_{\alpha\neq 0,\pm
1,-2}(1+\lambda(\alpha))(1+\lambda(\alpha-1))(1+\lambda(\alpha+1))(1+\lambda(\alpha+2)),$
(5.2)

and

$n_{q}=\frac{1}{16}\sum_{\alpha\neq 0,\pm
1,-2}(1-\lambda(\alpha))(1-\lambda(\alpha-1))(1-\lambda(\alpha+1))(1-\lambda(\alpha+2)).$
(5.3)

Thus

$m_{q}=\frac{1}{16}\left(q-4+\sum_{i=1}^{4}S_{i}+\sum_{i=1}^{6}T_{i}+\sum_{i=1}^{4}U_{i}+V\right)$
(5.4)

and

$n_{q}=\frac{1}{16}\left(q-4-\sum_{i=1}^{4}S_{i}+\sum_{i=1}^{6}T_{i}-\sum_{i=1}^{4}U_{i}+V\right).$
(5.5)

Here $S_{i}$, $T_{i}$, $U_{i}$ are sums of the form
$\displaystyle{\sum_{\alpha\neq 0,\pm 1,-2}f(\alpha)}$, where the polynomial
$f$ runs through all factors of the polynomial $f(x)$ of degrees 1,2,3,
respectively. Further $V$ is as defined in Lemma 5.3 in which case the
retrictions on $\alpha$ are immaterial since $\lambda(0)=0$. We evaluate these
in turn.

First the $S_{i}$. We have

$\displaystyle\sum_{\alpha\neq 0,-1,-2}\lambda(\alpha-1)$ $\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha-1)-1-\lambda(-2)-\lambda(2)=-1-2\lambda(2);$
$\displaystyle\sum_{\alpha\neq\pm 1,-2}\lambda(\alpha)\qquad$ $\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha)-1-1-\lambda(-2)=-2-\lambda(2));$
$\displaystyle\sum_{\alpha\neq 0,1,-2}\lambda(\alpha+1)$ $\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha+1)-1-\lambda(2)-1=-2-\lambda(2);$
$\displaystyle\sum_{\alpha\neq 0,\pm 1}\lambda(\alpha+2)$ $\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha+2)-\lambda(2)-\lambda(-2)-1=-1-2\lambda(2).$

Hence $S=\displaystyle{\sum_{i=1}^{4}S_{i}}=-6-6\lambda(2)$. Thus $s=-12$ if
$d$ is even but $S=0$ if $d$ is odd. Next the $T_{i}$. Using Lemma 2.1 we have

$\displaystyle\sum_{\alpha\neq-1,-2}\lambda(\alpha(\alpha-1))\qquad$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha(\alpha-1))-\lambda(2)-1=-2-\lambda(2);$
$\displaystyle\sum_{\alpha\neq 0,-2}\lambda((\alpha-1)(\alpha+1))$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda((\alpha-1)(\alpha+1))-1-\lambda(2)=-2-\lambda(2);$
$\displaystyle\sum_{\alpha\neq 0,-1}\lambda((\alpha-1)(\alpha+2))$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda((\alpha-1)(\alpha+2))-\lambda(-2)-\lambda(-2)=-1-2\lambda(2);$
$\displaystyle\sum_{\alpha\neq 1,-2}\lambda(\alpha(\alpha+1))\qquad$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha(\alpha+1))-\lambda(2)-\lambda(-2)=-1-2\lambda(2);$
$\displaystyle\sum_{\alpha\neq\pm 1}\lambda(\alpha(\alpha+2))\qquad$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha(\alpha+2))-\lambda(2)-1=-2-\lambda(2);$
$\displaystyle\sum_{\alpha\neq 0,1}\lambda((\alpha+1)(\alpha+2))$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda((\alpha+1)(\alpha+2))-\lambda(2)-1=-2-\lambda(2).$

Hence $T=\displaystyle{\sum_{i=1}^{6}T_{i}}=-10-8\lambda(2)$. Thus $T=-18$, if
$d$ is even, whereas $T=-2$ if $d$ is odd.

Finally, the $U_{i}$. Now Lemma 2.2 comes into play again. We have

$\displaystyle\sum_{\alpha\neq-2}\lambda(\alpha(\alpha-1)(\alpha+1))$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha(\alpha-1)(\alpha+1))-1$
$\displaystyle=$ $\displaystyle J(-1)-1$ $\displaystyle=$
$\displaystyle\begin{cases}-2s-1,\mbox{ if $d$ is even},\\\ \;\;2s-1,\;\mbox{
if $d$ is odd}.\end{cases}$

Next, replacing $\alpha$ by $\alpha-2$ in the sum,

$\displaystyle\sum_{\alpha\neq-1}\lambda(\alpha(\alpha-1)(\alpha+2))$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha(\alpha-1)(\alpha+2))-\lambda(-2)$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda((\alpha-2)(\alpha+2)\alpha)-\lambda(2)$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda(\alpha(\alpha^{2}-4))-\lambda(2)$
$\displaystyle=$ $\displaystyle J(1)-\lambda(2)=-2s-\lambda(2).$

Next, again replacing $\alpha$ by $\alpha-2$ in the sum,

$\displaystyle\sum_{\alpha\neq-1}\lambda((\alpha-1)\alpha(\alpha+2))$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda((\alpha+2)(\alpha-2)\alpha)-\lambda(2)$
$\displaystyle=$ $\displaystyle J(1)-\lambda(2)=-2s-\lambda(2).$

Finally, replacing $\alpha$ by $\alpha-1$ in the sum,

$\displaystyle\sum_{\alpha\neq 1}\lambda(\alpha(\alpha+1)(\alpha+2))$
$\displaystyle=$
$\displaystyle\sum_{\alpha}\lambda((\alpha-1)\alpha(\alpha+1))-1$
$\displaystyle=$ $\displaystyle J(-1)-1=\begin{cases}-2s-1,\mbox{ if $d$ is
even},\\\ \;\;2s-1,\mbox{ if $d$ is odd}.\end{cases}$

Set $U=\displaystyle{\sum_{i=1}^{4}U_{i}}$. From the above, if $d$ is even,
then $U=-8s-4$. On the other hand, if $d$ is odd, then $U=0$.

We put all this together using (5.2) and (5.3). First, suppose $d$ is even.
Then

$16m_{q}=q-4-12-18-8s-4-2s-1=q=10s-30.$

Further,

$16n_{q}=q-4-12-18-8s-4-2s-1=q+6s-7.$

This yields (1.6).

Now suppose $d$ is odd. By Lemma 5.1 we already know that $m_{q}=n_{q}$ (Lemma
5.1). This is consistent with the fact that here $S=U=0$. In fact, from the
above,

$16n_{q}=q-4-2+2s-1=q+2s-7,$

in agreement with (1.7).

This completes the proof of Theorem 1.2.

Given the apparently arbitrary form of the expressions in Theorem 1.2, it is
reassuring to present some illustrative examples for small values of $d$. A
preliminary observation is that, if $d$ is even, then the basic quadruple
comprises 4 consecutive non-zero squares so that $m_{q}\geq 1$.

If $d=1$, then the basic quadruple is the only quadruple of consecutive
elements and clearly $m_{5}=n_{5}=0$. Since $5=1^{1}+2^{2}$ this agrees with
(1.7) in this case.

If $d=2$, then $q=25=(-3)^{2}+4^{2}$, so that $s=-3$. Thus, from (1.6),
$m_{5}=1,n_{5}=0$. In particular, the basic quadruple is the only one
consisting of squares.

At this point we recall that $M_{25}=N_{25}=2$ and pause to identify
explicitly the triples of squares and non-squares in $\mathbb{F}_{25}$. First,
the basic quadruple $\mathcal{Q}_{2}$ of consecutive squares yields two
triples $\mathcal{T}_{2}$ and $\mathcal{T}_{3}$ of consecutive non-zero
squares. Next, apart from the equivalence class $\mathbb{F}_{5}$ in
$\mathbb{F}_{25}$ there are four further equivalence ckassss which we now
describe. Let $\mathbb{F}_{25}=\mathbb{F}_{5}({\beta)}$, where $\beta^{2}=2$.
Then $\beta$ has order 8 and is therefore a non-square in $\mathbb{F}_{25}$.
Further, all of $i\beta,i=\pm 1,\pm 2$ are inequivalent and the four classes
are $i\beta+\mathbb{F}_{5}=i(\beta+\mathbb{F}_{5}),i=\pm 1,\pm 2$. Moreover,
$(\beta-2)^{2}=\beta+1$ and so the latter is a square. Since $\beta^{2}-1=1$,
a square, then $\beta-1$ is also a square. Also $(\beta-2)^{3}=-\beta$ which
has oder 8 and so $\beta-2$ is a non-square. So is $\beta+2$, since
$\beta^{2}-4=-2$, a square. Thus each of the four equivalence classes comprise
three non-squares and two squares. There are therefore no more quadruples of
consecutive square or non-squares and no further triples of consecutive
squares. Observe also that $-(\beta+\mathbb{F}_{5})$ is just the set of
negaives of $\beta+\mathbb{F}_{5}$ and similarly for $\pm
2(\beta+\mathbb{F}_{5})$. In $\beta+\mathbb{F}_{5}$ the non-square $\beta$
lies between the squares $\beta\pm 1$ and so each of
$\pm(\beta+\mathbb{F}_{5})$ does not contain a triple of consecutive non-
squares, whereas, in $\pm 2(\beta+\mathbb{F}_{5})$ the squares
$2\beta-2=2\beta+3$ and $2\beta+2$ are consecutive, thus confirming that
$M_{25}=2$.

We resume the consequences of Theorem1.2 for a few more values of $d$. If
$d=3$, then $q=125=(-11)^{2}+2^{2}$. Thus, from (1.7), $m_{125}=n_{125}=16$.

If $d=4$, then $q=625=(-7)^{2}+24^{2}$. Thus $m_{625}=41,\ n_{625}=36$.

If $d=5$, then $q-3125=41^{2}+38^{2}$. Thus $m_{3125}=n_{3125}=200$.

If $d=6$, then $q=15625=117^{2}+44^{2}$. Thus $m_{15625}=901,\
n_{15625}=1020$.

From (1.6), if $d$ is even then, since $|s|<\sqrt{q}$, $n_{q}$ is positive iif
$(\sqrt{q}-3)^{2}>16$, so ceratainly 1f $q>49$. In particular, there exists a
quadruple of non-squares whenever $q\geq 4$. On the other hand $m_{q}>1$ if
$(\sqrt{q}-5)^{2}>80$ which occurs if $q>195$. Hence, whenever $d\geq 4$,
there exists a quadruple of consecutive squares (other than the basic
quadruple) whenever $d\geq 4$.

Further, if $d$ is odd, there exists a quadruple of non-zero squares or of
non-squares whenever $(\sqrt{q}-1)^{2}>8$ and so whenever $q>15$ which occcurs
whever $d\geq 3$.

Finally, when $q=5^{d}$, the existence of a quadruple of consecutive primitive
elements of $\mathbb{F}_{q}$ is established in [8] for all $d\geq 3$. This is
a deep result.

## References

  * [1] A.N. Abyzov, S. D. Cohen, P. V. Danchev and D. T. Tapkin, Rings and finite fields whose elements are sums or differences of tripotents and potents, arXiv math. 2112.14617, (2023), 18 pages.
  * [2] A. N. Abyzov and D. T. Tapkin, Rings over which every matrices are sums of idempotent and $q$-potent matrice., Siberian Math. J. 62 (2021) 1–13.
  * [3] A. N. Abyzov and D. T. Tapkin, When is every matrix over a ring the sum of two tripotents?, Lin. Algebra Appl. 630 (2021) 316–325.
  * [4] B. C. Berndt, R. J. Evans and K. S. Williams, Gauss and Jacobi Sums Canadian Mathematical Society Series of Monographs and Advanced Texts (John Wiley & Sons, Inc., New York, 1998).
  * [5] D. A. Buell and R.H. Hudoon, On runs of consecutive quadratic residues and quadratic nonresidues, BIT Numerical Mathematics 24 (2) (1984) 243–247.
  * [6] S. D. Cohen, Consecutive primitive roots in a finite field, Proc. Amer. Math. Soc. 93 (1985) 189–197.
  * [7] S. D. Cohen, T.O. e Silva, and T.S. Trudgian, On consecutive primitive elements in a finite field. Bull. Lond. Math. Soc. 47, 418–426 (2015)S. D.
  * [8] T. Jarso and T, Trudgian, T.: Four consecutive primitive elements in a finite field, Math. Comp. 91 (2022) 1521–1532.
  * [9] S. A. Katre and A. R. Rajwade, Resolution of the sign ambiguity in the determination of the cyclotomomic numbers of order $4$ and the corresponding Jacobsthal sum, Math. Scand. 60 (1987) 52–62.
  * [10] V. Kirichenko, M. Tsfasman, S. Vladut and I. Zakharevich,: Quadratic residue patterns and point count on K3 surfaces, arXiv math. 2303.03270 (2023) 9 pages.
  * [11] M. G. Monzingo, On the distibution of consecutive triples of quaratic residues and quadratic nonresidues and related topics, Fibonacci Quart. 23 (1985) 133–138.
  * [12] M. G. Monzingo, An elementary evaluation of the Jacobsthal sum, J. Number Th. 22 (1986) 21–25.