TITLE: Sums of four coprime squares
QUESTION [6 upvotes]: 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$?

REPLY [12 votes]: 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}.
$$