I'd like to combine a sum of as many squares as possible into a sum of as few squares as possible. The signs of the squares doesn't matter.

For example, the Brahmagupta-Fibonacci Identity combines a sum of four squares into a sum of two squares. Thus the compression ratio is 2:1. Using this identity, we can, with careful calculations, apply it recursively to get an even better compression ratio. In other words, take two sums of four squares and combine them together to get one sum of four squares, and then combine this to get one sum of two squares. Thus we have a ratio of 4:1.


Are there are any other formulas that take a sum of as many squares as possible and combine them into as few squares as possible?

  • $\begingroup$ Well... One must be careful with the definition of the problem, because a procedure like the one in Brahmagupta-Fibonacci cannot done for all sums of four squares. Indeed, the fact is that only some natural numbers can be written as a sum of two squares, while all natural numbers can be written as a sum of four squares. $\endgroup$ – user228113 Jun 24 '15 at 16:23
  • $\begingroup$ @G.Sassatelli: Yes, the full procedure is fairly complicated with recursion. Essentially, my idea is to include some "dummy" squares and subtract them from the sums of four squares, thus creating sums of squares with negative signs in front of them. Thus the recursion can be done on these as well, although it's tedious and relatively complicated. But my question remains; are there other formulas/methods? $\endgroup$ – Matt Groff Jun 24 '15 at 16:29
  • 1
    $\begingroup$ Every integer can be written as $x^2 + y^2 - z^2$ with only $x =0,1.$ $\endgroup$ – Will Jagy Jun 24 '15 at 17:23
  • $\begingroup$ @WillJagy: I'm really interested, specifically, in going from sums/differences of squares to sums/differences of squares, though. I don't need to represent every integer. I just want to specifically go from squares to squares. Perhaps it's easier to consider the reverse direction: going from two, three, or four squares to many squares. I guess I don't see why we need to represent every integer when making this transition. $\endgroup$ – Matt Groff Jun 24 '15 at 17:52
  • $\begingroup$ @WillJagy: Oh, wait... I think I see it: square the integer and you also square (x^2 + y^2 - z^2). I'm still wondering if there are more of these transformations. I'm working on a complicated algorithm, and it's hard to explain exactly what I'm looking for. But transitions from only squares to only squares seem essential. $\endgroup$ – Matt Groff Jun 24 '15 at 17:57

The "compression ratio" can be made as high as you want.

I. Euler-Aida Ammei

$$(-x_0^2+x_1^2+x_2^2+\dots+x_n^2)^2+(2x_0x_1)^2+(2x_0x_2)^2+\dots+(2x_0x_n)^2 = (x_0^2+x_1^2+x_2^2+\dots+x_n^2)^2$$

Thus, there can be arbitrarily many squares on the LHS.

II. Fauquembergue $n$-Squares Identity

Using the Brahmagupta-Fibonacci,

$$(a^2+b^2)(c^2+d^2) = u_1^2+u_2^2 = (ac+bd)^2+(ad-bc)^2$$


$$(a^2+b^2-c^2-d^2+x)^2 + (2u_1)^2 + (2u_2)^2 + 4x(c^2+d^2) = (a^2+b^2+c^2+d^2+x)^2$$

where $x$ is arbitrary and can be chosen as any sum of $n$ squares.

III. Using the Euler-Four Square


$$(a^2+b^2+c^2+d^2)(e^2+f^2+g^2+h^2) = v_1^2+v_2^2+v_3^2+v_4^2$$


$$(a^2+b^2+c^2+d^2-e^2-f^2-g^2-h^2+x)^2 + (2v_1)^2 + (2v_2)^2 + (2v_3)^2 + (2v_4)^2 + 4x(e^2+f^2+g^2+h^2) = (a^2+b^2+c^2+d^2+e^2+f^2+g^2+h^2+x)^2$$

where $x$ can again be any sum of squares. (I trust you know the expressions for the $v_i$.) Of course, a similar $n$-square identity can be made using the Degen-Graves Eight-Square.

For more on sums of $n$ squares, more details at my site.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.