1

Show (or disprove) that numbers with at most two prime factors can be expressed as a sum of two squares in at most 2 ways.

This post is inspired by an answer to this other post, say post A.

I found a post, say post B, that proves that if n is prime, then it can be expressed as a sum of two squares in at most one way. I thought I could modify this proof to show that numbers that have at most two (not necessarily distinct) primes in their prime factorization could be expressed as a sum of two squares in at most one way. The answer in post A uses some useful number theory facts: if $p\equiv 3\mod 4$ is a prime, then it cannot be expressed as a sum of two squares, which is a simple corollary of Fermat's little theorem.

Now one can prove that if $p$ is a prime, then $p^2$ can be expressed as a sum of two squares in at most two nontrivial ways as shown below.

(start of proof)

Fix any prime number $p$. If $p=2,$ then $4$ can only be written as a sum of two squares in one trivial way: $4 = 0+2^2$. Assume henceforth that p is odd. Note that if $p\equiv 3\mod 4$, then any nontrivial sum $x^2 + y^2$ equal to $p^2$ must satisfy that $x$ and $y$ are coprime. Any positive integers $x,y$ satisfying $x^2+y^2 = p^2$ thus form a primitive Pythagorean triple $(x,y,p)$. But then $p$ is the sum of two squares by the formula for primitive Pythagorean triples, a contradiction. Assume now that $p\equiv 1\mod 4$. Then if $x,y$ are positive integers so that $x^2 + y^2 = p^2,$ we know that $x$ and $y$ are coprime, so $p$ is a sum of two squares. But by the answer in post B, p can be uniquely expressed as a sum of two squares. Hence $p^2$ can be expressed as a sum of two squares of positive integers in at most one way (we consider swapping the order of the two terms or swapping signs the same way).

(end of proof)

Question: Now I'm not sure how to show that if $p$ and $q$ are distinct primes, then $pq$ can be expressed as the sum of two squares in at most two different ways. Clearly, since $pq$ is not a square, both integers must be nonzero, and by flipping signs if necessary, we may assume both integers are positive.

Suppose $$pq= a^2 + b^2 = c^2 + d^2=e^2 + f^2\quad (1)$$. We will prove that not all these three ways of writing pq as a sum of two squares are distinct. Now note that $a$ and $b$ are coprime, for if they shared a prime factor $t$, then $t^2$ would divide $pq$, which is impossible. We also have $(pq)^2 = (a^2 + b^2)(c^2+d^2) = a^2c^2+a^2d^2+b^2c^2+b^2d^2.$ We see that $$(pq)^2 = (ac+bd)^2 + (ad-bc)^2\quad (2)$$ and $$ (pq)^2= (ac-bd)^2 + (ad+bc)^2\quad (3)$$. Similarly, $(pq)^2 = (ae + bf)^2 + (af-be)^2 = (ae-bf^2)+(af+be)^2 = (ce + df)^2 + (cf-de)^2 = (ce-df)^2 + (cf+de)^2.$ By (1), $$(pq-a^2)d^2 = (pq-c^2)b^2\Rightarrow pq(d^2-b^2) = (ad-bc)(ad+bc)\quad (4).$$ Now $pq | (ad - bc)$ or $pq | (ad + bc)$. If the former occurs, then by $(2),$ $ad-bc = 0$ and so $a=c,b=d$ since $a,b,c,d$ are coprime and if $a | c,b|d, a < c$ or $b<d,$ then $p=a^2 + b^2 < c^2+d^2 = p,$ a contradiction. If the latter occurs, then by (3), $ac-bd = 0\Rightarrow a=d,b=c.$

Now the harder case is when $p | (ad-bc)$ and $q | (ad+bc)$ or vice versa. Obviously by relabelling we may assume the former occurs. Then we may write $ad-bc = kp$ for some integer k and we have $p^2(q^2 -k^2) = (ac+bd)^2.$ So $ac+bd$ is also divisible by p. I'm not sure how to proceed from here.

I'm looking for an elementary answer that avoids any use of Algebraic Number Theory concepts to an extent that would no longer be considered elementary.

user33096
  • 2,021
  • 1
    In your proof for $p^2$ when $p\equiv1\bmod4,$ knowing that $p$ can be uniquely expressed as a sum of two squares, how do you derive that $p^2$ can be expressed as a sum of two squares of positive integers in (essentially) at most one way? – Anne Bauval Dec 17 '22 at 17:20
  • Would considering factorisations in $\Bbb Z[i]$ be non-elementary for you? – Hagen von Eitzen Dec 17 '22 at 17:24

1 Answers1

1

This was Euler's argument in one of his letters to Goldbach, as transcribed on the French Wikipédia: Théorème des deux carrés de Fermat, § Euler et la descente infinie.

Let $pq=a^2+b^2$ where $p,q$ are distinct primes, hence both (uniquely) sums of two (coprime) squares. Given the decomposition $p=c^2+d^2,$ let us prove that there are (essentialy) only two possibilities for $(a,b).$

Since $pqc^2-a^2p=b^2c^2-a^2d^2,$ we have $p\mid bc+ad$ (wlog, i.e. up to changing $d$ to $-d$ if necessary). Define $$m:=\frac{bc+ad}p,\quad x:=b-mc,\quad y:=a-md.$$

$mp=bc+ad=(x+mc)c+(y+md)d=mp+xc+yd$ hence $xc+yd=0.$ Since $c,d$ are coprime, $x=nd$ and $y=-nc$ for some integer $n,$ i.e. $$a=md-nc,\quad b=mc+nd,$$ so that $$pq=(md-nc)^2+(mc+nd)^2=(m^2+n^2)(c^2+d^2)=(m^2+n^2)p.$$ Therefore, $n$ is uniquely determined up to sign, which ends the proof.

Anne Bauval
  • 34,650