2

What numbers can be written uniquely as a sum of two squares?

I was looking at sequence A125022, which shows the numbers that can be uniquely written as a sum of two squares. Here are a few things that I noticed from the first numbers. We have $1$, $2$, $4$, $8$, $16$, $32$, $64$, $128$. It is then safe to assume that all numbers of the form $2^{s}$ can be written uniquely, where $s \in \mathbb{Z}_{+} \cup \{0\}$. Moreover, primes of the form $4k+1$, for example $5$ and $13$, also appear and, interestingly enough, $5^2$ and $13^{2}$ do not. So, we could also say that $p^{s}$ has a unique representation only when $s = 0$ or $s = 1$. If we analyze $A125022$ a bit more, we notice that $3^{2}$, $7^{2}$, $11^{2}$ are there, so we can conjecture that numbers of the form $q^{2}$ have a unique representation, where $q$ is a prime of the form $4k+3$. Furthermore, for reasons I will say later, I believe $d^{2}$, where $d$ has all of its prime factors of the form $4k+3$, can be uniquely represented as a sum of two squares. It is also possible to see that products of these three cases are in the sequence, for example $2^{2}\cdot 5$, $2 \cdot 5 \cdot 3^{2}$ and $2 \cdot 7^{2}$.

Conjecture. A number $n \in \mathbb{Z}_{+}$ can be written uniquely as a sum of two squares if, and only if, $n = 2^{s} d^{2} p^{e_1}$, where $s \in \mathbb{Z}_{+} \cup \{0\}$, $d = 1$ or $d$ has all of its prime divisors of the form $4k+3$, $p$ is a prime of the form $4k+1$ and $e_{1} \in \{0,1\}$.

It is known that a number can be written as a sum of two squares if, and only if, it can be written as $2^{s} t^{2} l$, where $s \in \mathbb{Z}_{+} \cup \{0\}$ and $l$ is a square-free positive integer with all of its prime factors of the form $4k+1$. Thus, we know the number $n$ we conjectured above can in fact be written as a sum of two squares. We only need to understand uniqueness. It is more natural to study these questions with the Gaussian integers, $\mathbb{Z}[i]$. If, for example, we have $$n = a^{2} + b^{2} = (a+ib)(a-ib) = (\pi_1 \cdots \pi_k) (\overline{\pi_1} \cdots \overline{\pi_k}),$$ where the last expression is the factorization of $n$ in primes of $\mathbb{Z}[i]$, then we may get different sum representations of $n$ by exchanging, say, $\pi_j$ for $\overline{\pi_j}$. That is, the product $$(\pi_1 \cdots \overline{\pi_j} \cdots \pi_n)(\overline{\pi_1} \cdots \pi_j \cdots \overline{\pi_n})$$ should yield a different sum when $\pi_j \neq \overline{\pi_j}$ and at least one of the other primes, say $\pi_i$, also satisfies $\pi_i \neq \overline{\pi_i}$. This does not seem to occur precisely for the numbers conjectured above, which makes me think those are the only numbers that can be uniquely represented.

Question. Is my guess correct or am I missing other numbers?

huh
  • 387
  • 4
    See the Jacobi Theorem Keep in mind that they count solutions using negative integers, but it's easy to adjust for that. – lulu Mar 30 '24 at 18:39
  • 2
    Correct when "unique" refers to $n = a^2 + b^2$ with $a \geq b \geq 0$ – Will Jagy Mar 30 '24 at 18:46
  • If I understood this theorem correctly, then my guess is wrong, no? If we take for example $2205 = 3^{2} \cdot 7^{2} \cdot 5$, the difference of prime divisors of the form $4k+3$ and $4k+1$ is $4 - 1 = 3$. Jacobi's Theorem says we have to multiply this by $4$, but I assume we have to drop this constant to keep the "actual" unique representations. Then, there are $3$ different ways to write $2205$. – huh Mar 30 '24 at 18:59
  • For $n=2205$ there are $10$ factors of the form $4k+1$ and $8$ factors of the form $4k+3$. Thus you should expect two solutions in natural numbers, and indeed we get $(21, 42)$ and $(42, 21)$. – lulu Mar 30 '24 at 19:06
  • The diophantine $x^2+y^2=z^2+w^2$ has infinitely many solutions. – Piquito Mar 30 '24 at 19:07
  • Oh, I see. So we count divisors, rather than prime factors. Then $2205$ has a unique representation in the sense that only order changes. – huh Mar 30 '24 at 19:12
  • That is exactly right. – lulu Mar 30 '24 at 19:14
  • missing ingredient: the number of representations of $n$ as $x^2 + y^2$ is exactly the same as the number of representations for $2^k n.$ There is a bijection. – Will Jagy Mar 30 '24 at 23:41
  • 1
    induction on the power of $2:$ if $a \geq b \geq 0$ and $n = a^2 + b^2$ then we have $2n = (a+b)^2 + (a-b)^2$ where we still have $a+b \geq a-b \geq 0.$ The other direction: suppose $2n = u^2 + v^2 $ with $u \geq v \geq 0. $ We see that $u \equiv v \pmod 2$. Then $$ \left(\frac{u+v}{2} \right)^2 + \left(\frac{u-v}{2} \right)^2 = n$$ – Will Jagy Mar 30 '24 at 23:54
  • See here for more general results. – Bill Dubuque Mar 31 '24 at 15:16

1 Answers1

1

Your conjecture is correct.

You are missing no numbers. Any number not on your list would contain a prime power $q^e$ with $q$ of the form $4k+3$, $e$ odd, or a prime power $p^e$ with $p$ of the form $4k+1$ with $e\ge2$, or at least two primes $p_1$, $p_2$ of the form $4k+1$. In the first case $n$ cannot be written as sum of two primes at all, and in the second and third case one obtains readily several different representations of $n$. An essential ingredient to see this is the Brahmagupta-Fibonacci Identity

Each number on your list has actually only one representation. This can be most easily seen by looking at the prime decomposition of $n$ in the ring of Gaussian integers $\mathbb{Z}[i]$, and considering the fact that $\mathbb{Z}[i]$ has unique prime number decomposition up to units. Choosing different units does not result in different representations. Essentially all different representations arise from combining the factors in $\mathbb{Z}[i]$ of the prime decompositions $p_i=(a+bi)(a-bi)$, where $p_i$ is of form $4k+1$, in different ways. For the numbers on your list, there is just one prime $p_i$ of form $4k+1$, hence no different combinations are possible. Your number $d^2$ has only one representation $d^2=d^2+0$, since all prime factors of $d^2$ have form $4k+3$ and therefore are indecomposable ("inert") in $\mathbb{Z}[i]$.

nor
  • 81