# Sums of four coprime squares

The Four Squares Theorem says that every natural number is the sum of four squares in $\mathbb Z$. What is known about coprime representations? Here we call a presentation $n=a^2+b^2+c^2+d^2$ coprime if the g.c.d. of the four numbers $a,b,c,d$ is 1. Does every natural number have a coprime presentation? If not, is there a simple criterion characterising the numbers that have coprime presentations? What is known about the number of different coprime presentations of a given $n$?

• If $8|n$ then you must have all the four variables being even. Apart from that you can establish the result by Mobius inversion and using Jacobi's result on sums of four squares. – Lucia Nov 27 '17 at 6:42
• @Lucia: Could you please explain that? I don't quite get it, sorry. – user1688 Nov 27 '17 at 6:53
• If $n$ is odd (for simplicity) and you write $n = rs^2$ where $r$ is square-free, then your question is equivalent to checking whether $\sum_{a | s} \mu(a) \sum_{b | r(s/a)^2} b \geq 1$. The arithmetic seems annoying... but if you further assume that $\gcd(r,s) = 1$ then this is equivalent to checking whether $\sum_{a | s} \mu(a) \sigma((s/a)^2) \geq 1$, since $\sigma(r)$ would factor out (here $\sigma$ is the sum of divisors function). Note that $\sigma(s^2)$ is also multiplicative, so Mobius inversion would work – Stanley Yao Xiao Nov 27 '17 at 9:50

Let $R(n)$ denote the number of ways of writing $n$ as a sum of $4$ squares, and $r(n)$ the number of ways where gcd of $(a,b,c,d) =1$. Then grouping representations of $n$ as a sum of $4$ squares according to the gcd of the variables, clearly we have $$R(n) = \sum_{k^2 | n} r(n/k^2),$$ and so by Mobius inversion $$r(n) = \sum_{k^2| n} \mu(k) R(n/k^2).$$

Now by Jacobi's four square theorem, $R(n)$ is given explicitly as $8$ times a multiplicative function $F(n)$ defined on prime powers by $$F(2^k) = 3 \text{ for all } k\ge 1,$$ and, for odd primes $p$,
$$F(p^k) = p^k + p^{k-1} + \ldots + 1.$$ So $r(n)$ is $8$ times a multiplicative function $f(n)$ which is defined on prime powers by $$f(2)= 3; \ \ f(4) = 2;\ \ f(2^k)=0 \text{ for } k \ge 3,$$ and for odd primes $p$ and $k\ge 1$ $$f(p^k) = p^k + p^{k-1}.$$

• Good to have this on record! For the interested reader: there is a similar (but somewhat deeper) formula for the sum of 3 coprime squares. See our responses at mathoverflow.net/questions/217698/… – GH from MO Nov 28 '17 at 17:52
• I am wondering if there is a formula for the number of representations where every summand is coprime to any other. – Captain Darling Dec 22 '17 at 15:42

As Lucia noticed, if $8\mid n$, then $a,b,c$, and $d$ must be even, so that there is no "co-prime representation". If $8\nmid n$ with $n$ large enough, one can argue as follows.

Find a positive integer $d<\sqrt n$ such that

• $d$ is co-prime with $n$;
• $d$ and $n$ are of different parity;
• moreover, if $n\equiv 3\pmod 8$, then $d\equiv 0\pmod 4$, and if $n\equiv 7\pmod 8$, then $d\equiv 2\pmod 4$.

One readily verifies that $d^2\not\equiv n+1\pmod 8$, as a result of which $n-d^2$ is not of the form $4^u(8v+7)$ (where $u$ and $v$ are non-negative integers). Therefore, by Legendre's three-square theorem, $n-d^2$ is a sum of three squares: $n-d^2=a^2+b^2+c^2$. This yields $n=a^2+b^2+c^2+d^2$, and co-primality of $d$ and $n$ ensures that $\gcd(a,b,c,d)=1$.