Writing 2024 as the sum of 3 and 4 squares

171 Views Asked by At

I'm currently taking a course in number theory and we've just seen that any number can be written as the sum of the 4 squares, and that numbers can be written as the sum of 3 if they aren't of a certain form.

The notes gave an example using 2024

$2024=44^2+4^2+6^2+6^2$ and then leaves finding if its possible to find a sum of 3 as an exercise.

My first question is if there is a systematic way to find some 4 numbers such that you have $n=x^2+y^2+z^2+w^2$ for any $n$ you pick, for smaller numbers anyway.

As to the exercise, i know the sums of 3 exist since 2024 is not of the form $4^a(8b+7)$, and after some brute force guessing i've found 8,14,42 and 10,30,32 as triples that work. But this was me just plugging in values and seeing if it worked, is there a better way of finding these triples? I've had some ideas along of the lines if you can find a sum of 4 such that 2 of them are in a Pythagorean triple, but this doesn't seem to help much because i still have to find the sum of 4.

2

There are 2 best solutions below

0
On

For four squares, a somewhat systematic way to go is find the prime factorization and then reduce to representing each such prime as a sum of four squares. For example, $2024 = 2^3 \cdot 11 \cdot 23$. We have $11 = 3^2 + 1^2 + 1^2 + 0^2$ and $23 = 3^2 + 3^2 + 2^2 + 1^2$. Then systematically use the identity (hope it's right; I'm multiplying quaternions in my head)

$$(a^2 + b^2 + c^2 + d^2)(x^2 + y^2 + z^2 + w^2) = (ax - by - cz - dw)^2 + (ay + bx + cw - dz)^2 + (az + cx + dy - bw)^2 + (aw + dx + bz - cy)^2$$ that shows that sums of four squares are closed under taking products.

(More systematic still, the Wikipedia article linked to by JMoravitz in a comment gives a reference to an algorithm due to Rabin and Shallitt for finding the four squares, but I've not looked at that.)

0
On

I decided to factor out the power of four, so $2024 = 4 \cdot 506$. Then any sum of squares for $506$ can be easily converted into a sum of squares for the original $2024$.

To get a sum of three squares, we need to subtract off a square that leaves us with a number that is a sum of two squares. We will need an odd square somewhere along the line, so I tried subtracting off $81$:

$$ 506 - 81 = 5^2 \cdot 17 = 5^2 + 20^2 $$

Then $2024 = 4(9^2 + 5^2 + 20^2)$ gives us a sum of three squares. Also $5^2 = 3^2 + 4^2$ is a well-known Pythagorean triple, so sum of four squares quickly follows.