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$.
Solution 1:
"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.
Solution 2:
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.
Solution 3:
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
$\qquad\qquad \begin{align}\phantom{|^{|^|}}\forall\,n\ge 2\!:\text{ there is a }\,t_n\in S\,&\ \text{that is a sum of $\,n\,$ elements of $\,S$ }\\[.1em]
\iff\! \text{ there is a }\,t_2\in S\,&\ \text{that is a sum of $\,2\,$ elements of $\,S\!$}\\
\end{align}$
Proof $\ \ (\Rightarrow)\ $ Clear. $\ (\Leftarrow)\ $ We induct 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})$$
Solution 4:
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: