2
$\begingroup$

I'm trying to solve the following exercise.

Show that $169$ can be expressed as a sum of $1,2,3,4,5$ non-zero squares, and deduce that any $n \ge 169$ is the sum of five non-zero squares.

The latter part of the exercise is clear from Lagrange's four squares theorem, namely that every integer can be expressed as the sum of four integers. (There's also an answer Integers which are the sum of non-zero squares, detailing the exact steps.) I'm having trouble with the first part of the exercise.

For expressing $169$ as a sum of one square, we have $169=13^2$. Now, $13 = 2^2 + 3^2$, so we can use the identity $(a^2+b^2)(c^2+d^2) = (ac+bd)^2 + (ad-bc)^2$ to get $13^2 = (6+6)^2 + (2^2-3^2)^2$. But what about the rest? Is there any way of obtaining $169$ as a sum of $3,4,5$ non-zero squares, except by brute force, perhaps? (Brute force answers are also welcome, especially if they employ intuition or clever tricks! I will upvote them too)

There is one numerical answer to this in the link above, but I'm looking for intuition or a systematic way of doing things, not just a number solution expressing $169$ as a sum of non-zero squares.

$\endgroup$
8
  • 2
    $\begingroup$ The second-most familiar Pythagorean triple is $\langle 5,12,13\rangle$; that gives you the sum of two squares. $\endgroup$ Commented Feb 7, 2021 at 6:18
  • 1
    $\begingroup$ And the -most- familiar Pythagorean triple is $\langle 3,4,5\rangle$... $\endgroup$ Commented Feb 7, 2021 at 6:19
  • 2
    $\begingroup$ For four squares I happen to know that $65$ can be expressed as the sum of two squares in two ways, as $1^2+8^2$ and as $4^2+7^2$. And $104$ is clearly $2^2+10^2$, so that gives us two representations as the sum of four squares. (That tidbit about $65$ is something that I worked out as a youngster on reading Hardy’s story of Ramanujan and the number $1729$.) $\endgroup$ Commented Feb 7, 2021 at 6:24
  • 2
    $\begingroup$ Oh, of course! Anyone who’s played with special relativity knows that $6^2+8^2=10^2$, which of course also follows from the triple $\langle 3,4,5\rangle$, so the $10^2$ in my previous comment can be decomposed as $6^2+8^2$. If we want the sum of $5$ different squares, we have $169=2^2+4^2+6^2+7^2+8^2$. $\endgroup$ Commented Feb 7, 2021 at 6:40
  • 1
    $\begingroup$ If one has access to Mathematica, the command Select[DeleteDuplicates[Sort/@Tuples[Range[13],n]],#.#==169&] will list the ways to express $169$ as a sum of n squares. (One can of course apply this to larger numbers, though this brute-force approach is hardly ideal.) If one requires that all integers are distinct, then Select[Subsets[Range[13]],#.#==13^2&] produces -all- such decompositions into distinct squares. $\endgroup$ Commented Feb 7, 2021 at 6:50

3 Answers 3

5
$\begingroup$

I wondered how long this would take me, so I sat down to do it and here was my process.

I thought I would have to do some quick comparisons, so I first wrote the squares from $1$ to $169$ at the top of a sheet of paper. I had expected to repeatedly try a greedy algorithm of taking one large square and seeing what one can do with the remaining small number, but in fact this was only necessary once.

  1. $13^2$ gives the expression as one square.

  2. This amounts to choosing two squares and adding them up. In principle I could have looked at my list of squares and begun to compare, but I think it's pretty common to recognize the Pythagorean triple $5^2 + 12^2 = 13^2$.

  3. For $3$, I think it's easiest to modify the previous triple by re-expressing $5$ in its own Pythagorean triple to get $(3^2 + 4^2) + 12^2 = 13^2$.

  4. Although I'm listing these in order, I actually did $4$ squares last. I didn't do anything clever.

    Instead I proceeded greedily: begin with $169$, subtract a large square and see if what remains was obviously a sum of $3$ squares. $25$ is not a sum of three squares, so the initial try of representing $169 - 12^2 = 5^2$ as a sum of three squares doesn't work. But the second guess leads to $169 - 11^2 = 48 = 4^4 + 4^4 + 4^2$ does work. Thus $4^2 + 4^2 + 4^2 + 11^2$ works for $4$.

  5. I know the theorem that every number can be written as a sum of $4$ squares, so you can't really go too wrong here. I thought to examine again the basic Pythagorean triple $5^2 + 12^2 = 13^2$ and to rewrite $5^2$ as a sum of $4$ squares. This can be done with $1^2 + 2^2 + 2^2 + 4^2$ (and all these numbers are small enough to quickly get this with no real work), giving the set $1^2 + 2^2 + 2^2 + 4^2 + 12^2$.

$\endgroup$
3
  • $\begingroup$ As for 5: every number can be written as the sum of four squares, yes. But not every number can be written as the sum of four non-zero squares, which is what you need here. $\endgroup$
    – TonyK
    Commented Feb 7, 2021 at 18:06
  • $\begingroup$ @TonyK I rather think that the idea in the second question is, given an integer $n\ge169$, to write $n-169$ as a sum of four squares, some of which may be equal to zero. Then combine that with the presentation of $169$ as a sum of either $1,2,3,4$ or $5$ non-zero squares according to whichever alternative brings the total number of non-zero squares to exactly five. If your concern was about something else then I apologize for wasting your time. $\endgroup$ Commented Feb 7, 2021 at 18:47
  • $\begingroup$ @JyrkiLahtonen: I think this answer is simply showing how to express $169$ as the sum of $1,2,3,4,$ and $5$ non-zero squares. It doesn't address the second question, as far as I can see. $\endgroup$
    – TonyK
    Commented Feb 7, 2021 at 19:54
2
$\begingroup$

I posted this in comments, so I might as well document the results. If one has access to Mathematica, then Select[DeleteDuplicates[Sort/@Tuples[Range[13],n]],#.#==169&] lists all ways to write $169$ as a sum of n squares. (This can probably be improved but it works fine for the present purpose.) The results for $n=1,2,3$ are just those found above: $$169=13^2=5^2+12^2=3^2+4^2+12^2$$ For $n=4$ and $n=5$ we respectively obtain {{1,2,8,10},{2,4,7,10},{4,4,4,11},{4,5,8,8},{4,6,6,9}} and {{1,2,2,4,12},{1,2,6,8,8},{1,4,4,6,10},{2,2,2,6,11},{2,2,4,8,9},{2,2,5,6,10},{2,4,6,7,8},{3,4,4,8,8},{5,6,6,6,6}}. These give the representations \begin{align} 169 &=1^2+2^2+8^2+10^2\\ &=2^2+4^2+7^2+10^2\\ &=4^2+4^2+4^2+11^2\\ &=4^2+6^2+6^2+9^2\\ &=1^2+2^2+2^2+4^2+12^2\\ &=1^2+2^2+6^2+8^2+8^2\\ &=1^2+4^2+4^2+6^2+10^2\\ &=2^2+2^2+2^2+6^2+11^2\\ &=2^2+2^2+4^2+8^2+9^2\\ &=2^2+2^2+5^2+6^2+10^2\\ &=2^2+4^2+6^2+7^2+8^2\\ &=3^2+4^2+4^2+8^2+8^2\\ &=5^2+6^2+6^2+6^2+6^2.\\ \end{align} The reader may note the prevalence of solutions with repeated squares. If we require distinct squares, then the code can be simplified to Select[Subsets[Range[13]],#.#==1692&] and produces all such decompositions (regardless of number of terms). In this manner we obtain {{13},{5,12},{3,4,12},{1,2,8,10},{2,4,7,10},{2,4,6,7,8},{1,2,3,5,7,9}}, or

\begin{align} 169 &=13^2\\ &=5^2+12^2\\ &=3^2+4^2+12^2\\ &=1^2+2^2+8^2+10^2\\ &=2^2+4^2+7^2+10^2\\ &=2^2+4^2+6^2+7^2+8^2\\ &=1^2+2^2+3^2+5^2+7^2+9^2. \end{align} Note that there are two decompositions of $169$ into four distinct squares and we've also found a decomposition of $169$ into six distinct squares. (If we allow repeated squares, then the code above produces a total of 20 such decompositions into 6 squares.)

$\endgroup$
6
  • $\begingroup$ How will your code perform with 100 to 200-digits squares? Is its efficiency digits independent? $\endgroup$
    – user25406
    Commented Aug 26, 2023 at 12:48
  • 1
    $\begingroup$ @user25406 I’ve no idea if it’s efficient, only that it’s functional. $\endgroup$ Commented Aug 26, 2023 at 14:43
  • $\begingroup$ Can you please explain what your code does ( I don't code so I don't understand it). Is-it a brute force method or a known algorithm to produce all those squares? Thanks. $\endgroup$
    – user25406
    Commented Aug 26, 2023 at 15:31
  • 1
    $\begingroup$ It’s entirely brute-force and I’ll start with the second version. The Range command is used to make the list {1,2,3,4…,13}. The Subsets command then creates all n-element subsets for whatever n is provided. The Select command then casts out everything list whose sum-of-squares (aka dot product of the list with itself) is 169. This is not at all efficient: the n=6 case generates 13-choose-6=1716 candidates, but only one actually works. So this quickly becomes intractable if we replace 169 with larger numbers. $\endgroup$ Commented Aug 27, 2023 at 13:52
  • 1
    $\begingroup$ With the first code, the candidates allow repeated numbers. But the way I implemented this in 2021 seems a bit dumb. See mathematica.stackexchange.com/questions/42278/… for better methods.) $\endgroup$ Commented Aug 27, 2023 at 14:41
0
$\begingroup$

You could take the sum $$s =\sum_{n=1}^N q^{n^2}$$ (for some large $N$...) and see the expansion of $s^5$.

So it seems that $33$ is the largest number that is not the sum of $5$ non-zero square.

In a similar way we see that $19$ is the largest number that is not the sum of $6$ non-zero squares.

Note: Jacobi used the function

$$\theta(q) = \sum_{n\in \mathbb{Z} }q^{n^2} = 1 + 2 \sum_{n=1}^{\infty} q^{n^2}$$

and explicit expression for some $\theta^d$ to find numbers of ways of expressing a number as a sum of $d$ squares of integers.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .