Number of ways of representing a number as the sum of four squares

734 Views Asked by At

I need a formula, if there is one, for the number of ways a number can be represented as the sum of four squares.

I already found one, that says:

The number of ways to represent $n$ as the sum of four squares is $8$ times the sum of the divisors of $n$ if $n$ is odd and $24$ times the sum of the odd divisors of $n$ if $n$ is even.

My problem is that this formula doesn't take into account the possible repetitions, for example $4 = 1 + 1 + 1 + 1 $ , and this is the only way to do it, but that formula says that there are $24$ ways to do it, as it is counting all of the possible permutations ($4!$), but all $24$ of them are the same.

1

There are 1 best solutions below

0
On

COMMENT.- From $$(a_1^2+a_2^2+a_3^2+a_4^2)(b_1^2+b_2^2+b_3^2+b_4^2) =\\ \quad(a_1b_1 - a_2b_2 - a_3b_3 - a_4b_4)^2 + (a_1b_2+a_2b_1+a_3b_4-a_4b_3)^2 +(a_1b_3 - a_2b_4 + a_3b_1 + a_4b_2)^2 + (a_1b_4 + a_2b_3 - a_3b_2 + a_4b_1)^2$$ you have that the set of sums of four integers is closed by multiplication so if $$n=\prod_{1\le i\le k} p_i^{\alpha_i}$$ it is enough to calculate the number os representations of the primes in the factorization of $n$. You can see that the resulting number of ways you are asking could be "large" maybe. You can study for some details interesting you the non commutative field of quaternions and don't forget that in the sum of four squares the number zero is considered (for example $2=1^2+1^2+0^2+0^2$)