# Can a sum of $n$ squares be expressed as the sum of $n/2$ squares?

The answer for the special case when the squares are Pythagorean triple is yes. The Pythagorean triples are the case of the lowest $$n$$, namely $$2$$. Two Pythagorean triples can be combined to form a sum of $$4$$ squares as in $$(3^2 + 4^2) + (5^2 + 12^2) = 5^2 + 13^2$$. Combining (adding) Pythagorean triples, we can make a sum of squares with arbitrary $$n$$.

Question: What happens in the general case when the pairs of squares involved are not Pythagorean triples or when not all pairs are Pythagorean?

• Aug 18, 2020 at 18:51
• @ChrisCulter, the question is specific to the case where both the left and right hand side are sum of squares. The $2$, $3$ and $4$ squares cases deal with numbers that are not necessarily squares themselves. Aug 18, 2020 at 19:30
• I don't understand what you're asking. The immediate interpretation is "Suppose that for a positive integer $k$ we have $k = \sum_{i = 1}^n a_i^2$. Does it follow that also $k = \sum_{i = 1}^{n/2} b_i^2$?" The answer to that is by the links Chris Culter provided easily seen to be "No". But it seems that is not the question you intended. However, it is not clear which question you intended. Aug 18, 2020 at 19:57
• @DanielFischer, I am asking this question: Can a sum of $n$ squares be always expressed as the sum of $n/2$ squares? Using Pythagorean triples, the answer is yes since we can build a sum of squares with arbitrary $n$. But what about the general case (where we don't use Pythagorean triples). Your answer is no so if you can please make it into an answer. thanks. Aug 18, 2020 at 20:15
• The sum of two squares isn't always a square. Aug 18, 2020 at 20:36

The answer is yes for (even) $$n \geq 8$$ and no for (even) $$n \leq 7$$.

If $$n \geq 8$$ then the sum of your $$n$$ squares is the sum of four squares by the Lagrange four square theorem. Now, if $$n/2$$ is greater than 4, you can complete your sum by adding enough terms equal to $$0^2$$.

For $$4 \leq n \leq 7$$ note that $$7$$ can be written as the sum of $$n$$ squares but cannot be written as the sum of $$n/2$$ squares.

For $$2 \leq n \leq 3$$ note that $$5$$ is the sum of $$n$$ squares but not the sum of $$n/2$$ squares.

• I accepted this answer because it is the more complete one. I was hoping to get an answer that does not allow the use of $0^2$ because allowing $0^2$ makes it trivial. Aug 30, 2020 at 15:19

From Lagrange's four square theorem, we have that every natural number can be expressed as the sum of four perfect squares. Because we can always add $$0^2$$ without changing the sum, this means that every natural number can be written as the sum of $$n$$ squares for any $$n\geq4$$.

Your problem asks if given that $$M$$ is the sum of $$n$$ squares, can it be written as the sum of $$\frac{n}{2}$$ squares. As this requires that $$n$$ be even, we have four cases:

Case 1: $$n=2$$

In this case, given that $$M$$ is the sum of two squares, it is only the sum of one square if we have a Pythagorean triple.

Case 2: $$n=4$$

In this case, $$M$$ can be any natural number. The question asks if a generic natural number can be written as the sum of 2 squares. The answer to this question comes from the Sum of Two Squares Theorem, credited to Euler, and says that a number can be written as the sum of two squares if and only if its prime factorization doesn't contain a prime that is congruent $$-1\mod4$$ raised to an odd power.

Case 3: $$n=6$$

In this case, M can be any natural number. The question asks if a generic natural number can be written as the sum of 3 squares. From Legendre's Three-Square Theorem, the answer is that most, but not all natural numbers can be written as the sum of three squares. Specifically, all natural numbers but those appearing in this OEIS sequence can be written as the sum of three squares

Case 4: $$n\geq8$$

In this case, every natural number can be written as the sum of $$\frac{n}{2}$$ squares, and therefore the answer is trivially yes.

For the Cases 3 and 4, we have enough leeway in choosing $$n$$ squares that we can choose a breakup that does not include any Pythagorean Triples

• I think OP mentioned (in the comments under the question) that adding $0^2$ as a term was not allowed. Aug 19, 2020 at 17:57
• @DeepakMS, $0^2$ not allowed precisely because it make the problem trivial. Aug 19, 2020 at 18:03

I am not sure whether I understand the question correctly, because if this is what you actually mean, then it is not too difficult to come up with counter examples.

My interpretation : Given a collection of $$n$$ positive integers, $$\{ a_1, ..., a_n \}$$, it is possible to find a collection of $$n/2$$ positive integers, say, $$\{ b_1, ... , b_{n/2} \}$$ such that $$\sum_{i=1}^{n} {a_i}^2 = \sum_{i=1}^{n/2} {b_i}^2$$.

If this is what you actually mean, first consider $$n$$ to be an odd integer and we are done. Because $$n/2$$ is not an integer the statement is obviously false.

Now suppose $$n$$ is only allowed to be even. Consider, say $$n = 2$$ and $$a_i = 1$$ for both $$i=1,2$$. $$\sum {a_i}^2 = 1^2 +1^2 = 2$$, not a perfect square, and is thus a counterexample to the statement.

• we are talking about squares. I am not sure if considered that. Aug 19, 2020 at 17:59
• Sorry for the typo. Edited now. Aug 19, 2020 at 18:01
• yes there are many counterexamples but we cannot conclude that a sum of $n$ squares can never be a sum of $n/2$ squares unless we use Pythagorean triples. I would like a more general result if possible and preferably a proof to show under what conditions it is possible (or impossible). Aug 19, 2020 at 18:09
• @DeepakMS I second user25406's comment. In particular, see my comment to poetasis' answer. Aug 19, 2020 at 18:43
• Well, here's a counterexample to your counterexample: $113=7^2+8^2=4^2+5^2+6^2+6^2=2^2+3^2+6^2+8^2$. We can in fact build many examples by combining the sum of two squares with that of four squares. In this case we start by choosing and adding $2$ squares then calculate the sum of $4$ squares for the resulting number. We get an infinite number of cases. Aug 20, 2020 at 9:03

Any two Pythagorean triples may be represented as the sum of four squares or the sum of two squares.

Examples: $$\qquad(15^2+8^2)+(21^2+20^2)=17^2+29^2$$

or, from the example I showed in my first version of this answer: $$157^2+12324^2=6493^2+10476^4=10147^2+6996^2=12317^2+444^2=12325^2$$ $$\implies(157^2+12324^2)+(6493^2+10476^4)+(10147^2+6996^2)+(12317^2+444^2)\\\qquad\qquad\qquad=(12325^2)+(12325^2)+(12325^2)+(12325^2)$$

where $$8$$ sums of squares are expressed as $$4$$. I gave the example of $$4$$ equal values but any even number of any combinations of $$C$$-values can be reduced to half that number.

Another example is here where $$10$$ square sums are equal to $$5$$ sums $$\qquad\qquad (3^2+4^2)+(5^2+12^2)+(13^2+84^2)+(85^2+132^2)+(157^2+12324^2)\\ \qquad\qquad=5^2+13^2+85^2+157^2+12325^2$$

For your last question, if squares are not required, there are also infinite solutions: $$(12+13)+(168+1)=5^2+13^2$$ or $$(1^2+2^2)+(4^2+5^2)=(5+41)$$

• Your answer is dealing with a different problem. What I want is in the question I asked, that is "can a sum of $n$ squares be expressed as a sum of $n/2$ squares. To get that for Pythagorean triples, we don't pick squares at random from a given triple. We just add a number $n$ of two squares on the LHS of a given triple and add them to get a sum of $n/2$ squares on the RHS like in this simple example: $(3^2+4^2)+(5^2+12^2)=5^2 + 13^2$. Here we see that $4$ squares add up exactly to $2$ squares. With Pythagorean triples, we can build cases like this for arbitrary large $n$. Aug 19, 2020 at 12:17
• So I will not be accepting your answer since it does not deal with the question as stated. Aug 19, 2020 at 13:29
• @poetasis it seems to me that it could be possible for the sum of positive integers $(A^2 + B^2 + D^2 + E^2)$ to equal the sum of positive integers $(C^2 + F^2)$ without the squares of any two of $\{A,B,D,E\}$ summing to either $C^2$ or $F^2$. Assuming that my supposition (which may be in error) is accurate, you would not need pythagorean triplets involved in the answer. Aug 19, 2020 at 18:39
• @user2661923 I may have addressed your conjecture in an update to my answer. Aug 20, 2020 at 3:02
• @poetasis, I don't have a problem with using $1^2$ and $2^2$, as long as we avoid $0^2$. Aug 20, 2020 at 19:10