Representing a given number as the sum of two squares.

Some thoughts on this without using complex numbers

Let $N=1885$ which can be factorised to give 3 different primes, each of which can be written as the sum of two squares in one way only (i.e. $5=1^2+2^2$,$13=2^2+3^2$ and $29=2^2+5^2$. Notice that 5, 13 and 29 are all of the form $(4n+1)$ ). Therefore $N=xyz$ where $x=\left(r^2+s^2\right)$, $y=\left(t^2+u^2\right)$ and $z=\left(v^2+w^2\right)$

First multiplying x and y we can show that the product equals the sum of two squares in at least two algebraically distinct ways. $$xy=\left(r^2+s^2\right)\left(t^2+u^2\right)=\left(rt+su\right)^2+\left(ru-st\right)^2=\left(rt-su\right)^2+\left(ru+st\right)^2$$ I am not sure how to prove that this represents the maximum number of ways the product can be written distinctly as the sum of two squares. I suppose you need to convince yourself of this before continuing.

In a similar way we can demonstrate that multiplying the product $xy$ by $z=\left(v^2+w^2\right)$ doubles the previous number of algebraic solutions. Therefore we provisionally find that $N$ equals the sum of two square in four algebraically distinct ways.

You then need to make the calculations to see if these four possible algebraic solutions are numerically distinct.


Since $\mathbb{Z}[i]$ is a UFD, by letting $$ r_2(n)=\left|\left\{(a,b)\in\mathbb{Z}^2:a^2+b^2=n\right\}\right|$$ we have $$ r_2(n) = 4(\chi_4*1)(n) = 4\sum_{d\mid n}\chi_4(d) $$ where $\chi_4(m)$ equals $1$ if $m\equiv 1\pmod{4}$, $-1$ if $m\equiv 3\pmod{4}$ and zero otherwise.
This is essentially due to the Brahmagupta-Fibonacci identity $$ (a^2+b^2)(c^2+d^2) = (ad-bc)^2+(ac+bd)^2 $$ equivalent to the multiplicativity of the norm over $\mathbb{Z}[i]$. Since $1885=5\cdot 13\cdot 29$ and $5=1^2+2^2$, $13=2^2+3^2$, $29=2^2+5^2$, from $$(1+2i)(2+3i)(2+5i)=-43-6i$$ $$(1-2i)(2+3i)(2+5i)=21+38i$$ $$(1+2i)(2-3i)(2+5i)=11+42i$$ $$(1+2i)(2+3i)(2-5i)=27+34i$$ we get that the wanted representations are $$ 1885=6^2+43^2 = 21^2+38^2 = 11^2+42^2=27^2+34^2.$$