7
$\begingroup$

Let $S_n = \{ x^2 \pmod{n} \mid x \in \mathbb Z \}$ denote the set of squares in ${\mathbb Z}_n$.

Define $S_n(d) = \{ (x, y) \in S_n^2 \mid x + d \equiv y \pmod{n} \}$.

Is there an explicit formula for $|S_n(d)|$ ?


Update:

As mentioned in comments, if $d \equiv 0 \pmod{n}$, then $|S_n(d)| = |S_n|$ and there is a formula for it according to Walter D. Stangl's paper "Counting Squares in ${\mathbb Z}_n$" (MAA link) (PDF link).

I am still looking for a general result where $d \not\equiv 0 \pmod{n}$.

  • 2
    It definitely seems worth pursuing. The Chinese remainder theorem applies so $S_m(d)S_n(d) = S_{mn}(d)$ for coprime $m,n$. So you only have to look at $S_{p^k}$ for prime $p$. It might be hard to get explicit formulas for $|S_{p^k}(d)|$ but I bet you could find something recursive. Note that $|S_{p^k}(0)|$ is the number of distinct quadratic residues mod $p^k$, and there's a nice recursion (for $2$ as well as odd primes) $a_n = pa_{n-1} + a_{n-2} - pa_{n-3}$ (as well as explicit formulas if you want to approach in cases). Maybe think similarly for other $d$.2017-02-27
  • 1
    Also I noticed that the structure of $S_p(d)$ is particularly simple for $p \equiv 3 \mod 4$. In that case one has $S_p(0) = S_p(p) = \frac{p+1}{2}$ and for all other $d$ one has $S_p(d) = \frac{p+1}{4}$. This symmetry will bubble up through the powers of $p$ so it should not be hard to explicitly express $|S_{p^k}(d)|$ for these $p$2017-02-27
  • 2
    @Badam Baplan, you have a proof of the assertion $S_p(d)=\frac{p+1}{4}$?2017-08-29

1 Answers 1

0

This is far from being a complete answer but it might give you some clue to follow up. What I give is a closed form when $p$ is an odd prime and $p\nmid d$:

\begin{align} S_p(d) &= \frac{ p+1+(\tfrac{-d}{p}) + (\tfrac{d}p)}4 \\&= \frac{ p+1 +(1+(-1)^{\frac{p-1}2})(\tfrac{d}p)}4\end{align}

$(\frac dp)$ is the Legendre symbol which is zero if $p$ divides $d$, $+1$ when $d$ is a square in $\mathbb Z_p$ and $-1$ otherwise. I'm using the elementary theory of quadratic residues and non residues and Legendre symbols freely in the rest of the answer. (by the way zero is neither a quadratic residue nor a quadratic non-residue which is usually a source of some confusion)

The method of proof goes back to Gauss, first I'm using the following result, (I give an sketch of the proof at the end): $$ \sum_{t=1}^p \left(\frac{t(t+d)}p\right) = -1\tag{1}\label{eq1}$$

Call $RR$ the number of integers $t$ mod $p$ such that both $t$ and $t+d$ are both quadratic residues, in the same way let $RN$ the number of integers $t$ mod $p$ such that both $t$ is a quaratic residue and $t+d$ a quadratic non-reside, and define $NR$ and $NN$ in a similar way. Then the sum in \eqref{eq1} can be written $$ RR + RN + NR + NN = -1 \tag{2}\label{eq2} $$ now observe that the sum $RR+RN$ counts once every quadratic residue except $-d$ if it is a quadratic residue, as there are $\tfrac{p-1}2$ quadratic residues and ${1+(\tfrac{-d}p)}2 =1$ exactly when $-d$ is a quadratic residue then
$$ RR + RN = \frac{p-1}2 - \frac {1+(\tfrac{-d}p)}2 = \frac{p-2-(\tfrac{-d}p)}2\tag{3}\label{eq3}$$ With similar arguments we find: $$ NR+NN=\frac{p-2+(\tfrac{-d}p)}2\tag{4}\label{eq4}$$ $$ RR+NR=\frac{p-2-(\tfrac{d}p)}2\tag{5}\label{eq5}$$ $$ RN+NN=\frac{p-2+(\tfrac{d}p)}2\tag{6}\label{eq6}$$

Summing \eqref{eq2}, \eqref{eq3} and \eqref{eq4} we get after simplifying $$ 2RR +2NN = p-3$$ summing \eqref{eq3} and \eqref{eq4} and substracting \eqref{eq5} and \eqref{eq6} we get $$ 2RR - 2NN = -(\tfrac{-d}p)-(\tfrac dp) $$ so we get $$ 4RR = p-3 -(\tfrac{-d}p)-(\tfrac{d}p) $$ Now we have $$ S_p(d) = RR + \tfrac 12 \bigl(1 -(\tfrac{-d}p)\bigr)+ \tfrac 12 \bigl(1 -(\tfrac{d}p)\bigr) $$ and combining both we get the claim.

Now we prove \eqref{eq1}. Call the left hand sum $T(d)$ then \begin{align} T(d) &= \sum_{t=1}^p \left(\frac{t(t+d)}p\right) \\ &= \sum_{t=1}^p \left(\frac{dt(dt+d)}p\right)=\sum_{dt=1}^p \left(\frac{d^2}p\right)\left(\frac{t(t+1)}p\right)\\ &= \sum_{t=1}^p \left(\frac{t(t+1)}p\right) \\ &= T(1) \end{align} Now we can tke the sum $$ T(0)+T(1)+\dots+T(p-1) = \sum_{t=1}^p \left(\frac tp\right) \sum_{d=0}^p\left(\frac{(t+d)}p\right) = 0 $$ but $T(0) = p-1$ and $T(1)=T(2)=\dots =T(p-1)$ so $$ T(0)+T(1)+\dots+T(p-1) = p-1 + (p-1)T(1) = 0 $$ and we get \eqref{eq1}.

If you want to extend this to prime powers you could try to reproduce this argument for prime powers using a primitive root $g$ mod $p^k$, if $t \equiv g^a$ define $\chi(t)= (-1)^a$, and try to evaluate $\sum \chi(t(t+d))$.