# All integer solutions to $x^2+y^2+z^2=2^{11}$?

I think this problem is from an old math olympiad, but not sure. The problem is:

Find all integer solutions to

$$$$x^2+y^2+z^2=2^{11}.$$$$

I know that this can be describe as "find all coordinates with integer values inside (or on) a sphere with radius $$\sqrt{2^{11}}=\sqrt{2048}\approx45.25$$. However, I don't know how to arrive at the solution. A solution or any hints would be highly appreciated. I also know that people have studied geometry/integer problems like these, for instance Gauss circle problem but that's 2D (circles) not 3D (spheres).

I have found solutions using some online diophantine equation solver to be the following (I added the plus-minuses):

\begin{align} x1 &= 0, & y1 &= \pm32, & z1 &= \pm32 \\ x2 &= \pm32, & y2& = 0, & z2 &= \pm32 \\ x3 &= \pm32, & y3& = \pm32, & z3 &= 0 \end{align}

Hope you understand me!

• I just made a spreadsheet with $x$ and $y$ running from $0$ to $45$ and checked by eye. I did not find any more. – Ross Millikan Jul 4 '19 at 23:25
• There will only be $12$ solutions if $r^2 = 2^{2n+1}$, with $n$ being an integer. The $12$ solutions will be $x = 0, y = \pm 2^{n}, z = \pm 2^{n}$, with each of $x, y, z$ being equal to $0$. There will only be $6$ solutions if $r^2 = 2^{2n}$. See oeis.org/A005875 for the explanation. – Varun Vejalla Jul 4 '19 at 23:34
• Let's @automatically generate an answer. – Oscar Lanzi Jul 4 '19 at 23:40
• Look mod 4, a square of a number is either $1$ or $0$ mod $4$ which implies that all $x, y, z$ are even, continue until you get $x^2+y^2+z^2=2$ – kingW3 Jul 4 '19 at 23:42
• :) I wish StackExchange worked like that, @OscarLanzi. – Varun Vejalla Jul 4 '19 at 23:50

if $$x^2 + y^2 + z^2 \equiv 0 \pmod 4 \; , \;$$ then all three of $$x,y,z$$ are even. In your case, this observation is repeated a few times. Put another way, if $$x^2 + y^2 + z^2 = 4n \; , \;$$ then $$\left( \frac{x}{2 } \right)^2 +\left( \frac{y}{2 } \right)^2 +\left( \frac{z}{2 } \right)^2 = n$$ and so on
Since $$2^{11} = 4^5 \cdot 2,$$ you wind up solving $$u^2 + v^2 + w^2 = 2$$ (twelve answers) and multiplying all three variables by $$32$$