When is $(m+1)/2$ a quadratic residue mod $m$?

39 Views Asked by At

The motivation here comes from this MSE question involving a set of divisibility constraints. In particular, it requires finding $n,p,q$ such that $p \mid 2n^2-1$ and $q \mid 2n^2-1$. Since $2n^2-1$ is always odd, $2$ is invertible, and these can be rearranged to the following:

$$n^2 \equiv 2^{-1} \pmod m \equiv \frac{m+1}{2} \pmod m$$

where $m$ is either $p$ or $q$ as needed. From a quick perusal up to $10000$, it seems this hold true when $m$ is a prime of the form $\pm 1 \pmod 8$, or the product of such primes. Interestingly, this is the same set of moduli for which $2$ is a quadratic residue.

There are supplements to quadratic reciprocity for $\pm 1, \pm 2, \pm 3$, and many others, but I don't know of one for $(m+1)/2$. Does this form follow the rule it appears to? As a sub-question, is this generally true for inverses of quadratic residues? That would seem pretty wild.