# Can any number of squares sum to a square?

Suppose

$$a^2 = \sum_{i=1}^k b_i^2$$

where $$a, b_i \in \mathbb{Z}$$, $$a>0, b_i > 0$$ (and $$b_i$$ are not necessarily distinct).

Can any positive integer be the value of $$k$$?

The reason I am interested in this: in a irreptile tiling where the smallest piece has area $$A$$, we have $$a^2A = \sum_{i=1}^k b_i^2A$$, where we have $$k$$ pieces scaled by $$b_i$$ to tile the big figure, which is scaled by $$a$$. I am wondering what constraints there are on the number of pieces.

Here is an example tiling that realizes $$4^2 = 3^2 + 7 \cdot 1^2$$, so $$k = 8$$.

• Wouldn't $k = 2$ be a counterexample? – Michael Seifert Dec 7 '19 at 13:57
• @MichaelSeifert No, $5^2 = 1\cdot 4^2 + 1\cdot 3^2$. – Herman Tulleken Dec 7 '19 at 13:59
• It might be a little less confusing to phrase this request as the values of $k$ for which $a^2 = \sum_{i = 1}^k b_i^2$, where the various $b_i$ values may or may not be distinct. For example, $4^2 = 3^2 + 1^2 + 1^2+ 1^2+ 1^2+ 1^2+ 1^2+ 1^2.$ – Michael Seifert Dec 7 '19 at 14:02
• To make the problem nontrivial, we must assume that the $b_i$ are not zero.I think that the case $k_1=k_2=\cdots k_n=1$ is always solvable in positive integers which would already solve the problem. – Peter Dec 7 '19 at 14:05
• Note that for any even $k \geq 4$, we have a solution of the form $(n+1)^2 = n^2 + (2n + 1) \cdot 1^2$; and any as you noted, any Pythagorean triple solves $k = 2$. The interesting cases are when $k$ is odd. – Michael Seifert Dec 7 '19 at 14:15

This holds far more generally. OP is the special case $$S$$ = integer squares, which is closed under multiplication $$\,a^2 b^2 = (ab)^2,\,$$ and has an element that is a sum of $$\,2\,$$ others, e.g. $$\,5^2 = 4^2+3^2$$.

Theorem  If $$\,S\,$$ is a set of integers $$\rm\color{#0a0}{closed}$$ under multiplication then for every integer $$\,n\ge 2\,$$ there is an element of $$\,S\,$$ that is a sum of $$\,n\,$$ elements of $$\,S\! \iff$$ some $$\,s\in S\,$$ is a sum of two elements of $$\,S.$$

Proof $$\ \ (\Rightarrow)\$$ Clear. $$\ (\Leftarrow)\$$ We proceed by induction on $$n$$. The base case $$\,n = 2\,$$ is true by hypothesis, i.e. we are given that $$\,\color{#c00}{a = b + c}\,$$ for some $$\,a,b,c\in S.\,$$ If the statement is true for $$\,n\,$$ elements then

\begin{align} s_0 &\,=\, s_1\ \ +\ s_2\ + \cdots +s_n,\ \ \ \ \,{\rm all}\ \ s_i\,\in\, S\\ \Rightarrow\ s_0a &\,=\, s_1 a + s_2 a + \cdots +s_n\color{#c00} a,\ \ \color{#0a0}{\rm all}\ \ s_ia\in S \\[.1em] &\,=\, s_1 a + s_2 a + \cdots + s_n \color{#c00}b + s_n \color{#c00}c \end{align}\qquad\qquad

so $$\,s_0 a\in S\,$$ is a sum of $$\,n\!+\!1\,$$ elements of $$S$$, completing the induction.

Remark  A comment asks for further examples. Let's consider some "minimal" examples. $$S$$ contains $$\,a,b,c\,$$ wth $$\,a = b + c\:$$ so - being closed under multiplication - $$\,S\,$$ contains all products $$\,a^j b^j c^k\ne 1$$. But these products are already closed under multiplication so we can take $$S$$ to be the set of all such products. Let's examine how the above inductive proof works in this set.

\begin{align} \color{#c00}a &= b + c\\ \smash{\overset{\times\ a}\Longrightarrow}\qquad\qquad\, a^2 = ab+\color{#c00}ac\, &= b(a+c)+c^2\ \ \ {\rm by\ substituting}\,\ \color{#c00}a = b+c\\ \smash{\overset{\times\ a}\Longrightarrow}\ \ a^3 = b(a^2+ac)+ \color{#c00}ac^2 &= b(a^2+ac+c^2)+c^3 \\[.4em] {a^{n}} &\ \smash{\overset{\vdots_{\phantom{|^|}\!\!}}= \color{#0a0}b (a^{n-1} + \cdots + c^{n-1}) + c^{n}\ \ \text{ [sum of \,n\!+\!1\, terms]}}\\[.2em] {\rm by}\ \ \ a^{n}-c^{n} &= (\color{#0a0}{a\!-\!c}) (a^{n-1} + \cdots + c^{n-1})\ \ \ {\rm by}\ \ \color{#0a0}{b = a\!-\!c} \end{align}\quad\ \ \

So the proof's inductive construction of an element that is a sum of $$n+1$$ terms boils down here to writing $$\,a^n\,$$ that way using the above well known factorization of $$\,a^n-c^n\,$$ via the Factor Theorem.

By specializing $$\,a,b,c\,$$ one obtains many examples, e.g. using $$\,5^2,4^2,3^2$$ as in the OP then $$S$$ is set of squares composed only of those factors, and the $$\,n\!+\!1\,$$ element sum constructed is

$$25^n =\, 9^n + 16(25^{n-1}+ \cdots + 9^{n-1})$$

• This is a very clear generalization. Would be lovely if you could add one or two unexpected examples other than squares (I could only think of "multiple of m" and other powers which are not so interesting.) – Herman Tulleken Dec 10 '19 at 0:28
• +1 this is also constructive for OP's needs, I think. – R.. GitHub STOP HELPING ICE Dec 10 '19 at 2:34
• (I said "other powers" but realized this is wrong.) – Herman Tulleken Dec 10 '19 at 3:22
• @Herman I added a Remark showing some simple examples. – Bill Dubuque Dec 11 '19 at 17:59
• @R.. Yes, it is indeed constructive, e.g. see the Remark I appended. – Bill Dubuque Dec 11 '19 at 19:17

"Is any $$k$$ possible?" An easy route to "Yes": You know from the Pythagorean theorem that two squares can add to a perfect square. $$c^2=a^2+b^2$$

$$c^2$$ must be either odd or even. If odd, it is the difference between two consecutive squares. $$c^2=2n-1=n^2-(n-1)^2$$ If even, $$c^2$$ is divisible by $$4$$ and is also the difference between two squares. $$c^2=4n=(n+1)^2-(n-1)^2$$ So in either case, $$c^2$$ equals the difference between two squares. $$c^2=r^2-s^2 \\ r^2=c^2+s^2=a^2+b^2+s^2$$ Here, $$r^2$$ is the sum of three squares.

This can be repeated indefinitely, increasing by one the number of squares in the sum which adds to a square. There is no limit to the number of squares that can be accumulated in the sum.

• Actually, since an odd square is always $1$ modulo $4$, the $n$ in $c^2=2n-1$ is also always odd, so starting from odd $c^2$ always gives odd squares (e.g. starting from $5^2=4^2+3^2$, we get $5^2 = 13^2-12^2$, $13^2 = 85^2-84^2$...). – JiK Dec 8 '19 at 1:49
• @JiK It's possible to start with a non-primitive Pythagorean triple such as $10^2=8^2+6^2$, so some provision for even squares must be considered. – Keith Backman Dec 8 '19 at 4:11

Yes, $$k$$ can be arbitrary. Define a sequence$$a_1:=3,\,a_{k+1}:=\frac12\left(a_k^2+1\right)$$ of odd positive integers (since $$\frac12((2n+1)^2+1)=2(n^2+n)+1$$), so$$a_{k+1}^2-a_k^2=\frac14\left[(a_k^2+1)^2-4a_k^2\right]=\left[\frac12(a_k^2-1)\right]^2$$is a perfect square. Now define$$b_1:=3,\,b_{k+1}:=\frac12(a_k^2-1)$$so $$a_k^2=\sum_{i=1}^kb_i^2$$ for all positive integers $$k$$. The sequence $$a_n$$ is called the Pythagorean spiral or OEIS A053630.

Here is a geometric solution (for $$k > 5$$).

The following are solutions for 6, 7, and 8 squares.

We can replace a square in each of these with four equal size squares to find a tiling with 3 more squares, so we can get 9, 10, and 11 squares. Repeating this we can get any number of squares larger than 5.

I show one iteration below:

• Beautiful and simple. Well done. – Eric Duminil Dec 9 '19 at 20:54
• So the unit square is defined as whatever the smallest square is? – Cruncher Dec 9 '19 at 21:53
• @Cruncher yes indeed. – Herman Tulleken Dec 9 '19 at 22:18
• Yes, when we split a square into 4 we are halving its side length, which would yield nonintegers if the side length was odd. To get around that we first scale everything by 2 to ensure all square side lengths (= summands) are even. Then it's precisely the algebraic transformation I mentioned above. – Bill Dubuque Dec 9 '19 at 23:16
• I added an answer which highlights the key algebraic properties at the heart of the matter. – Bill Dubuque Dec 10 '19 at 0:14

Yes.

For $$k = 2$$: $$3^2 + 4^2 = 5^2$$

For $$k > 2$$:
Start with a solution for $$k-1$$
Multiply both sides by $$5^2$$
Replace one $$(5a)^2$$ on the left with $$(3a)^2$$ + $$(4a)^2$$.

$$3^2 + 4^2 = 5^2$$
$$15^2 + 20^2 = 25^2$$
$$9^2 + 12^2 + 20^2 = 25^2$$ (k = 3)

$$45^2 + 60^2 + 100^2 = 125^2$$
$$27^2 + 36^2 + 60^2 + 100^2 = 125^2$$ (k = 4)

Repeat until k is as desired.

It is known enough the generalization of Phytagorean triples which let us to say YES. Just as for $$k=2$$ two parameters are needed, for $$k\gt2$$ we need $$k$$ arbitrary parameters $$t_1,t_2\cdots,t_k$$ so we have the identity easily verified $$(t_k^2-t_1^2-t_2^2\cdots-t_{k-1}^2)^2+(2t_1t_k)^2+(2t_2t_k)^2+\cdots+(2t_{k-1}t_k)^2=(t_1^1+\cdots+t_k^2)^2$$.

(Note that for $$k=2$$ we have the quite known parameterization of Phytagorean triples).

Solutions exist for every $$k>0$$. The simplest forms use most of the $$b_n$$ values as $$1$$. I will list them as "$$b_*$$". I suspect there are infinitely many distinct answers for each $$k\ge2$$, but I can't prove it.

if $$k = 2n$$ (k is even) and large enough ($$k\ge4$$ or $$n>1$$):

• $$a = n$$
• $$b_1 = n-1$$
• $$b_* = 1$$

\begin{align} \sum_{i=1}^k b_i^2 & = (n-1)^2 + (2n-1)\cdot1^1 \\ & = n^2 - 2n + 1 + 2n - 1 \\ & = n^2 \\ & = a^2 \\ \end{align}

if $$k = 4n + 1$$ and large enough ($$k\ge9$$ or $$n>1$$)

• $$a = n+1$$
• $$b_1 = n-1$$
• $$b_* = 1$$

\begin{align} \sum_{i=1}^k b_i^2 & = (n-1)^2 + ((4n+1)-1)\cdot1^1 \\ & = n^2 - 2n + 1 + 4n \\ & = n^2 +2n + 1 \\ &= (n + 1)^2 \\ & = a^2 \\ \end{align}

if $$k = 4n + 3$$

• $$a = 2n+3$$
• $$b_1 = 2n+2$$
• $$b_2 = 2$$
• $$b_* = 1$$

\begin{align} \sum_{i=1}^k b_i^2 & = (2n+2)^2 + 2^2 + ((4n+3)-2)\cdot1^1 \\ & = 4n^2 + 8n + 4 + 4 + 4n + 1 \\ & = 4n^2 + 12n + 9 \\ &= (2n + 3)^2 \\ & = a^2 \\ \end{align}

The only values that don't work with these patterns are $$k$$ = 1, 2, or 5.

For $$k=1$$, $$a=b_1$$ for any values.

For $$k=2$$, we have we have a well known case, with minimal value $$5^2=4^2+3^2$$

For $$k=5$$, the minimal value is $$4^2=3^2+2^2+1^2+1^2+1^2$$

• Maybe I am missing something. Sup $k = 9$, so $n = 2$, and $a = 3, b_1 = 2$, then we have $3^2 = 2^2 + 5\cdot 1$, but then $k = 1 + 5 = 6$ ... ? – Herman Tulleken Dec 8 '19 at 18:23
• @Herman If k=9, a=3, $b_1$=1, so we have $3^2 = 1^2 + 8 \cdot 1$ – David G. Dec 8 '19 at 20:22
• Ah, I miscalculated. Got it now :+1: – Herman Tulleken Dec 8 '19 at 23:13
• You can maybe improve the answer by showing some calculations to save the reader from having to do them. – Herman Tulleken Dec 8 '19 at 23:23