# Sums of more than one combination of squares.

I'm interested in examples like these, where the sum of $n$ squares equals the sum of another $n$ squares.

$3^2 + 11^2 \quad = \quad 7^2 + 9^2 \quad = \quad 130$

$5^2 + 6^2 + 10 ^ 2 \quad = \quad 4^2 + 8^2 + 9^2 \quad = \quad161$

$4^2 + 9^2 + 11^2 \quad = \quad 5^2 + 7^2 + 12^2 \quad = \quad 218$

$3^2 + 6^2 + 10^2 + 11^2 \quad = \quad 4^2 + 5^2 + 9^2 + 12^2 \quad = \quad 266$

Is there a way to generate equalities like these?

If not, is there a way to, given $n$ integers, find a combination of another $n$ integers that satisfies this condition? Or maybe there is a way to tell if a solution exists?

• – Robert Z Jun 7 '17 at 7:35
• There are certainly algorithmic ways to find, given the factorization of $n$, all of the sums of two squares that add to $n$ and all of the sums of four squares that add to $n$. Most $n$ that can be written at all as the sum of two squares can be so written in more than one way (the primes can't, and that's about it). All $n$ can be written as the sum of four squares, and the number of ways grows roughly linearly with $n$! – Greg Martin Jun 7 '17 at 8:10
• Well, not for n squares but there is a way you can do that for random numbers on different sides. Just pick a perfect square which is again sum of two squares (greatest in its pythagorean triplet). For example: $25^2+5^2=3^2+4^2+15^2+20^2$ another one is $10^2+25^2=24^2+7^2+6^2+8^2$ – I am Back Jun 7 '17 at 8:12
• I posted algorithms that allow one to find all 2-square representations (when possible) and all 3-square representations of an integer on this site. Both methods use quadratic equations and triangular numbers to find the representations. – user25406 Jun 8 '17 at 15:12
• here are the links for two algorithms mentioned in my previous comment. math.stackexchange.com/questions/1972771/… and math.stackexchange.com/questions/2070691/… – user25406 Jun 13 '17 at 19:06