8

The negative case of the Fermat Christmas Theorem (i.e. that all numbers, in particular primes, that are $3 \pmod 4$ can't be expressed as the sum of two squares) is very quickly proven by seeing that $0,1$ are the only squares in $\mathbb Z/4\mathbb Z$, and hence $0,1,2$ are the only possible residues of sums of 2 squares in $\mathbb Z /4\mathbb Z$. This teaches us one very easy method of ruling out solutions to infinitely many Diophantine equations is by showing that they don't have solutions in some (finite!) quotient ring $\mathbb Z/n\mathbb Z$. More generally, this is one way that solutions (to Diophantine equations) in $\mathbb Z$ vs. $\mathbb Z/n\mathbb Z$ "talk to each other".

I am interested in all possible residue classes $r \pmod n$ that this method rules out for the Diophantine equations $x^2 + y^2 = r \pmod n$. This boils down to wanting to know (what's not in) the image (some subset of $\mathbb Z/n\mathbb Z$ closed under multiplication) of the (multiplicative) map $N_n: \mathbb Z/n\mathbb Z [i] \to \mathbb Z/n\mathbb Z$ where $N$ refers to the norm $N(x+iy):=x ^2 + y^2$.

For $n$ some prime $p$, a classic pigeonhole argument (Sum of two squares modulo p) tells us that because there are many squares, $N_p$ is surjective. The Chinese remainder theorem tells us that it suffices to look at $n$ some prime power, say $p^n$ (abusing notation a little). With a little work we can figure out all the squares in $\mathbb Z/p^n\mathbb Z$: see Efficient way to find squares mod a prime power?, or the formula for the exact number of squares in the quotient ring formula for the number of perfect squares mod $N$. Unfortunately this count tells us that the pigeonhole argument doesn't work for $n$ composite.

Running some experiments https://onlinegdb.com/8raZ0MIzt, I conjecture the following:

  • If $p \equiv 1 \pmod 4$ (I tested $p=5, n=1,2,3,4$; and $p=13, n=1,2,3$), then $N_{p^n}$ is surjective.
  • If $p \equiv 3 \pmod 4$ (tested with $p=3,7, 11$, all powers $<1000$), then the only numbers $N_{p^n}$ misses are $r$ who are multiples of $p$, and whose power of $p$ in the factorization of $r$ is odd (i.e. $r$ with $v_p(r) \in \{1,3,5, \ldots\}$ where $v_p(n)$ denotes the highest power of $p$ dividing $n$).
  • If $p=2$, then the only numbers $N_{2^n}$ misses are all the $3 \pmod 4$ numbers, and their multiples by powers of $2$. E.g. for $\mathbb Z/512\mathbb Z$, we have all the $3 \pmod 4$ numbers $3=4(1)-1, 7, 11, 15, 19, 23, 27, 31,\ldots, 503, 507, 511=4(2^{9-2})-1$; and multiplying by 2: $6, 14, 22, 30, \ldots, 502, 510 = 2\cdot [4(2^{9-3})-1]$; and multiplying by 4: $12, 28, \ldots, 508 = 4\cdot [4(2^{9-4})-1]$; and so on for a total of $255 = 2^8-1$ bad/impossible numbers.

From the Fermat Christmas Theorem, it is easy to show that the "bad/impossible" numbers I listed out above are in fact impossible. We have the following "iff" statement

there exist $x,y\in \mathbb Z$ s.t. $r = x^2 + y^2 \pmod p^n \iff$ there is $k$ and $x,y\in \mathbb Z$ s.t. $p^nk + r = x^2+y^2$;

or its negation:

$r \in \mathbb Z/p^n\mathbb Z$ is not reachable by $N_{p^n} \iff$ for all $k$, $kp^n+r$ is not a sum of squares (which by the Fermat Christmas Theorem is equivalent to "every $3 \pmod 4$ primes in the factorization of $kp^n+r$ are raised to an odd power")

Analyzing in the $p=3\pmod 4$ case or $p=2$ case, we see

  • Indeed if $m$ is odd $<n$ ($<n$ so that $p^m\in \{0,\ldots, p^n-1\}$), then $kp^n+p^m = p^m(kp^{n-m}+1)$, which for any $k$ indeed has highest power of $p$ equal to $m$ (which is odd).
  • If $r=2^m(4l+3)$, then $k2^n + r = 2^m(k2^{n-m}+(4l+3))$ is (for any $k$) a power of 2 times a $3 \pmod 4$ number provided that $m<n$ is not equal to $n-1$, which we know to be impossible. If $m=n-1$, then the only possible $r \in \{0,\ldots, 2^n-1\}$ with a factor of $2^m$ is just $2^m$, which we know to be the sum of squares $2^m= (2^{(m-1)/2})^2 + (2^{(m-1)/2})^2$ if $m$ odd; or $2^m = (2^{m/2})^2+0^2$ if $m$ even.

So indeed the conditions I wrote are sufficient to be impossible, but I don't know how to show that they are necessary.


Similar questions are: Expressing elements of $\mathbb{Z}/n\mathbb{Z}$ as sums of squares which leads to https://www.jstor.org/stable/2318299?seq=5, which is is about the uniform problem of what $n$ are s.t. EVERY number in $\mathbb Z / n\mathbb Z$ are the sum of two squares; and https://mathoverflow.net/questions/306392/number-of-ways-to-write-an-integer-as-a-sum-of-squares-modulo-k which is a bit too general (more than 2 squares, and counts number of solutions instead of just saying which are/aren't possible -- I suppose in principle it is possible to get an answer to my question from this resource, but it requires being able to tell what Ramanujan sums are zero/non-zero. I would prefer a more low-tech approach.)

D.R.
  • 10,556
  • 4
    Bravo for all the work done so far! If I'm correct, you've proved that all of the numbers matching the empirical impossible-classes pattern truly are impossible, so it remains to show the existence of a solution to $x^2+y^2\equiv a\pmod{p^n}$ in the not-impossible cases. I suggest trying to use Hensel's lemma, which is a way of converting solutions to $x^2+y^2\equiv a\pmod p$ into solutions to $x^2+y^2\equiv a\pmod{p^n}$. – Greg Martin Feb 14 '23 at 05:06
  • 1
    @GregMartin I thought of this, but was scared off by the first line in the Wikipedia, which concerns "simple roots" of "a univariate polynomial". Thinking again, perhaps fixing the $y$ variable, and somehow ensuring that $a-y^2$ is not $0$ or something, we get a simple root of a univariate polynomial so Hensel's lemma applies. But the details do seem non-trivial. – D.R. Feb 14 '23 at 06:36
  • 1
    Nontrivial yes but well worth working through (and then you'll have a new tool in your toolbelt for the future!). Nice job recognizing that you can fix one variable $y$ and treat the equation as a univariate polynomial in $x$. I recommend starting with the $p\equiv 1\mod4$ case—I think that's the one that goes most smoothly. – Greg Martin Feb 14 '23 at 07:48
  • This is brilliant work, D.R. I will be keeping an eye on this intriguing question! – Clyde Kertzer Feb 15 '23 at 19:38

0 Answers0