[Math] The number of ways of writing an integer as a sum of two squares

elementary-number-theoryprime numberssums-of-squares

Given an integer $m=pq$, where $p,q$ are both primes such that $p\equiv 1 \pmod{4}, q\equiv 1 \pmod{4}$.
It is known that $p$ can be written as a sum of two squares (of positive integers) in a unique way, and the same for $q$. Prove that $m$ can be written as a sum of two squares (of positive integers) in exactly two distinct ways.

Attempt

Notice that for positive integers $u,v,A,B$, we have
\begin{align*}(u^2+v^2)(A^2+B^2)&=(uA+vB)^2+(vA-uB)^2=(vA+uB)^2+(uA-vB)^2\end{align*}
Therefore if $p=a^2+b^2,q=c^2+d^2$, then
\begin{align*}m&=(a^2+b^2)(c^2+d^2)=(ac+bd)^2+(bc-ad)^2=(bc+ad)^2+(ac-bd)^2\end{align*}
meaning that $m$ can be written as a sum of two squares (of positive integers) in at least two distinct ways.

How do I prove that there doesn't exist a third way of writing $m$ as a sum of two squares (of positive integers)?

Best Answer

I think we can always translate everything to the basics operations but it will take a huge number of pages! Fortunately, your question has an elementary answer. We denote by $S_n$ the set of representation of the integer $n$ as sum of squares, we have $(a,b)\in S_n$ if and only if $0\leq b<a$ and $ a^2+b^2=n$;

Given two primes $p$ and $q$ let: $$ S_p=\{(a_p,b_p)\}\\ S_q=\{(a_q,b_q)\} $$ Now we want to prove that $S_{pq}$ contains exactly two elements, or in other words we want to prove that the following equations on unknown $(a,b),(c,d)$ has exactly one solution :

  • $a>b>0$ and $c>d> 0$ (it's clear that neither $d=0$ or $b=0$ occurs)
  • $a^2+b^2=c^2+d^2=pq$
  • $a>c$ ( different elements)

The equation in the middle is equivalent to: $$(a-c)(a+c)=(d-b)(d+b)$$ this implies the existence of integers $x,y,z,t$ pairwise coprime such that: $$\begin{align} a-c&=&2xy\\ a+c&=&2zt\\d-b&=&2xz\\d+b&=&2yt \end{align}$$ Note that the existence is not hard for example $x=gcd\big(\frac{a-c}{2},\frac{d+b}{2}\big),y=gcd\big(\frac{a-c}{2},\frac{d-b}{2}\big)\cdots$, so this will justify also that they are pairwise corprime.

The result is the fact that: $$pq=(x^2+t^2)(y^2+z^2)$$ obviously $xyzt\neq 0$ therefore $\{p,q\}=\{x^2+t^2,y^2+z^2\}$ we have two cases:

  1. $p=x^2+t^2$ and $q=y^2+z^2$, because $a+c>d-b$ we have $t>x$, and $a+c > d+b$ implies $z>y$ so $x=b_p,t=a_p,y=b_q, z=a_q$ so $a=a_pa_q+b_qb_p,b=a_pb_q-b_pa_q,c=a_pa_q-b_qb_p, d=a_pb_q+b_pa_q$
  2. $q=x^2+t^2$ and $p=y^2+z^2$ because of the symetry it gives different $x,y,z,t$ but the same $a,b,c,d$ as the first case.

So there is only one solution to the equations hence $S_{pq}$ contains exactly two elements.