# Find all $x,y,z$ such that $x^2 + y^2 + z^2 = 3^{10}$

By Legendre's 3-squares theorem, a number $n = x^2 + y^2 + z^2$ can be written as the sum of three squares if $n \neq 4^a(8b+7)$. In my case, I am choosing $$n = 3^{10} \equiv (3^2)^5 \equiv 1 \mod 8$$ which is safe. In that case, is there any way I can find these integers by induction? Perhaps I can try: $$3 = 1^2 + 1^2 + 1^2$$ This is encouraging to let's try the case of $n=9$: That is even easier since it is a perfect square: $$9 = 3^2 + 0^2 + 0^2$$ Let's take it one step further. $n = 3^3 = 27$. There is no way to combine my previous two answers to get a third solution. However, by searching: $$27 = 5^2 + 1^2 + 1^2 = 3^2 + 3^2 + 3^2$$ and $n = 81 = 3^4$ is another perfect square (in fact a perfect 4th power) but there may be other solutions: $$81 = 9^2 + 0^2 + 0^2 = \dots$$ Is it possible to get all the way to $n = 3^{10}$ in this manner. Is there an inductive approach to solving: $$3^n = x^2 + y^2 + z^2$$ for all odd and even powers $n$ ?

• Arithmetical structure of sums of three squares is much more complicated than it is for two or four squares. I personally doubt a simple method of enumerating solutions exists, even in such specific cases, but I'd love to be proven wrong. – Wojowu Nov 21 '16 at 19:49

I gave the method for $$a^2 + b^2 + c^2 = 3 m^2$$ at When will a parametric solution generate all possible solutions?

Very proud of that one, I had not been sure how to tweak Jones and Pall, turns out there is no problem since we need only express the $3$ as the norm of either quaternion $i+j+k$ or of $-i-j-k,$ so there is no loss in just taking the first and saying that we could negate $a,b,c$ without harming anything.

Given odd positive $m,$ all primitive solutions to $$a^2 + b^2 + c^2 = m^2$$ come from first finding all $$w^2 + x^2 + y^2 + z^2 = m,$$ then writing out Lebesgue's (V. A. Lebesgue) formula , $$a = w^2 + x^2 - y^2 - z^2,$$ $$b = 2(wz+xy),$$ $$c = 2(-wy + xz).$$ A complete discussion is Theorem 3 of Jones and Pall

Well. Easy enough to program what is often called Lebesgue's identity. Here are all primitive solutions for $a^2 + b^2 + c^2 = 3 m^2,$ for $m = 1, 3, 9, 27, 81, 243.$ I take $a,b,c$ either all positive or all negative, $\gcd(a,b,c) = 1$ as I mentioned, and $|a| \geq |b| \geq |c|.$ All are odd, of course, check mod 8.

    1       1    1    1   check  0 w x y z      1    0    0    0
3      -5   -1   -1   check  0 w x y z      0    1   -1   -1
9      11   11    1   check  0 w x y z      0    2    2    1
9     -13   -7   -5   check  0 w x y z      0    2   -1   -2
27     -35  -29  -11   check  0 w x y z      1   -3    4   -1
27     -35  -31   -1   check  0 w x y z      1   -1    3   -4
27      37   23   17   check  0 w x y z      5    1    0    1
27      43   13   13   check  0 w x y z      5    0   -1    1
27     -43  -17   -7   check  0 w x y z      1   -3    4    1
81     103   85   43   check  0 w x y z      2    6    5    4
81    -103  -95   -7   check  0 w x y z      1    0    4   -8
81    -113  -83   -5   check  0 w x y z      2   -6    5    4
81     115   77   23   check  0 w x y z      6   -4   -5   -2
81    -121  -71   -1   check  0 w x y z      0    4   -1   -8
81     125   47   43   check  0 w x y z      6    5    2    4
81    -127  -55  -23   check  0 w x y z      1    4    0   -8
81    -131  -41  -29   check  0 w x y z      2    3    2   -8
81     131   49   11   check  0 w x y z      4   -6   -5   -2
81     133   37   25   check  0 w x y z      5    6    2    4
81     137   25   17   check  0 w x y z      7   -4   -4    0
81     139   19    1   check  0 w x y z      8    2   -2    3
81      91   89   59   check  0 w x y z      8   -2   -3   -2
81     -95  -73  -73   check  0 w x y z      0    7   -4   -4
243    -257 -253 -217   check  0 w x y z      0    7    5  -13
243    -263 -263 -197   check  0 w x y z      1  -11   11    0
243    -265 -241 -221   check  0 w x y z      0   11   -1  -11
243     271  245  209   check  0 w x y z      9    8    7    7
243     283  263  167   check  0 w x y z     12    7    5    5
243    -289 -251 -175   check  0 w x y z      1  -12    7    7
243    -295 -241 -179   check  0 w x y z      1    3    8  -13
243     299  239  175   check  0 w x y z      8    9    7    7
243     299  289   65   check  0 w x y z     15    4   -1    1
243     301  211  205   check  0 w x y z      7   -9   -8   -7
243     301  289   55   check  0 w x y z     11    9    5    4
243    -305 -211 -199   check  0 w x y z      1    8    3  -13
243    -307 -283  -53   check  0 w x y z      3  -11    7    8
243     307  287   23   check  0 w x y z      4   11    9    5
243     311  265  101   check  0 w x y z     13   -4   -7   -3
243     317  257  103   check  0 w x y z     13    7    3    4
243    -319 -269  -55   check  0 w x y z      3  -11    8    7
243     341  215  121   check  0 w x y z      3   11    8    7
243    -341 -245  -29   check  0 w x y z      4   -5   11   -9
243    -349 -235  -11   check  0 w x y z      1   -8    3   13
243     353  167  157   check  0 w x y z      3  -11   -8   -7
243     353  223   53   check  0 w x y z     15    1   -4    1
243    -355 -191 -121   check  0 w x y z      3   -7   13   -4
243    -359 -205  -79   check  0 w x y z      3    1    8  -13
243    -361 -155 -151   check  0 w x y z      3   -4   13   -7
243     361  199   85   check  0 w x y z     11   -7   -8   -3
243     365  179  109   check  0 w x y z     15   -1   -4    1
243     371  191   55   check  0 w x y z      4  -11   -9   -5
243    -373 -163 -107   check  0 w x y z      3   -8   13   -1
243    -377 -187   -7   check  0 w x y z      5   -4   11   -9
243     383  133  113   check  0 w x y z      1   12    7    7
243    -383 -173  -23   check  0 w x y z      5   -5   12   -7
243     385  169   19   check  0 w x y z      5  -11   -9   -4
243    -389 -125 -101   check  0 w x y z      4    3    7  -13
243    -389 -151  -55   check  0 w x y z      1    8   -3  -13
243     397  133   43   check  0 w x y z     13   -5   -7    0
243     403   97   73   check  0 w x y z      5   12    5    7
243     407  107    7   check  0 w x y z      0   13    7    5
243     409   95   29   check  0 w x y z      7  -11   -8   -3
243    -419  -31  -25   check  0 w x y z      3   -7   13    4
243     419   35   19   check  0 w x y z     12   -7   -7    1


Hope you don’t mind, but I’ll rewrite your equation as $$x^2+y^2+z^2=n=3^q$$ as you’ve given two meanings to $n$.

I’ll show all solutions in the form $(q,n,x,y,z)$

You found $(1,3,1,1,1)$, which, basically, states that $3*k^2=(k^2+k^2+k^2)$, giving, $$(3,27,3,3,3)$$ $$(5,243,9,9,9)$$ $$(7,2187,27,27,27)$$ $$(9,19683,81,81,81)$$

$(2a+1,3^{2a+1},3^a,3^a,3^a)$ with $a>=0$

You also found $(2,9,3,0,0)$, so multiplying by a constant gives $$(2,9,3,0,0)$$ $$(4,81,9,0,0)$$ $$(6,729,27,0,0)$$ $$(8,6561,81,0,0)$$ $$(10,59049,243,0,0)$$

$(2b,3^{2b},3^b,0,0)$ with $b>0$

There is a standard parametric solution for the sum of three (or more) squares equal to a square. In the notation of this problem, an existing solution $(q,n,x,y,z)$ gives a new solution, $(Q,N,X,Y,Z)$ $$Q=2q$$ $$N=3^Q$$ $$X=Abs(-x^2+y^2+z^2)$$ $$Y=2*x*y$$ $$Z=2*x*z$$

Because the values of $(x,y,z)$ are interchangeable, changing the order of the values gives up to two further solutions

Applying this to $(1,3,1,1,1)$ gives $(2,9,2,2,1)$. Feeding this new solution in gives $(4,81,8,4,1)$ and $(4,81,7,4,4)$, and so on.

Now I’m almost certain there are other patterns to be seen, to generate parametric solutions and methods, but fear they will never be able to form a full list. Sadly, I don’t have the time to keep looking in the next week.

However, the effort to code a program is tiny, so perhaps this $(q,n,x,y,z)$ list will help.

$$(1,3,1,1,1)$$ $$(2,9,2,2,1)$$ $$(2,9,3,0,0)$$ $$(3,27,3,3,3)$$ $$(3,27,5,1,1)$$ $$(4,81,6,6,3)$$ $$(4,81,7,4,4)$$ $$(4,81,8,4,1)$$ $$(4,81,9,0,0)$$ $$(5,243,9,9,9)$$ $$(5,243,11,11,1)$$ $$(5,243,13,7,5)$$ $$(5,243,15,3,3)$$ $$(6,729,18,18,9)$$ $$(6,729,21,12,12)$$ $$(6,729,22,14,7)$$ $$(6,729,23,10,10)$$ $$(6,729,23,14,2)$$ $$(6,729,24,12,3)$$ $$(6,729,25,10,2)$$ $$(6,729,26,7,2)$$ $$(6,729,27,0,0)$$ $$(7,2187,27,27,27)$$ $$(7,2187,33,33,3)$$ $$(7,2187,35,29,11)$$ $$(7,2187,35,31,1)$$ $$(7,2187,37,23,17)$$ $$(7,2187,39,21,15)$$ $$(7,2187,43,13,13)$$ $$(7,2187,43,17,7)$$ $$(7,2187,45,9,9)$$ $$(8,6561,54,54,27)$$ $$(8,6561,55,44,40)$$ $$(8,6561,56,49,32)$$ $$(8,6561,56,55,20)$$ $$(8,6561,56,56,17)$$ $$(8,6561,63,36,36)$$ $$(8,6561,64,41,28)$$ $$(8,6561,64,44,23)$$ $$(8,6561,64,47,16)$$ $$(8,6561,64,49,8)$$ $$(8,6561,65,44,20)$$ $$(8,6561,66,42,21)$$ $$(8,6561,68,41,16)$$ $$(8,6561,68,44,1)$$ $$(8,6561,69,30,30)$$ $$(8,6561,69,42,6)$$ $$(8,6561,72,36,9)$$ $$(8,6561,75,30,6)$$ $$(8,6561,76,23,16)$$ $$(8,6561,76,28,1)$$ $$(8,6561,78,21,6)$$ $$(8,6561,79,16,8)$$ $$(8,6561,81,0,0)$$ $$(9,19683,81,81,81)$$ $$(9,19683,91,89,59)$$ $$(9,19683,95,73,73)$$ $$(9,19683,99,99,9)$$ $$(9,19683,103,85,43)$$ $$(9,19683,103,95,7)$$ $$(9,19683,105,87,33)$$ $$(9,19683,105,93,3)$$ $$(9,19683,111,69,51)$$ $$(9,19683,113,83,5)$$ $$(9,19683,115,77,23)$$ $$(9,19683,117,63,45)$$ $$(9,19683,121,71,1)$$ $$(9,19683,125,47,43)$$ $$(9,19683,127,55,23)$$ $$(9,19683,129,39,39)$$ $$(9,19683,129,51,21)$$ $$(9,19683,131,41,29)$$ $$(9,19683,131,49,11)$$ $$(9,19683,133,37,25)$$ $$(9,19683,135,27,27)$$ $$(9,19683,137,25,17)$$ $$(9,19683,139,19,1)$$ $$(10,59049,154,143,122)$$ $$(10,59049,158,134,127)$$ $$(10,59049,158,146,113)$$ $$(10,59049,162,162,81)$$ $$(10,59049,165,132,120)$$ $$(10,59049,168,147,96)$$ $$(10,59049,168,165,60)$$ $$(10,59049,168,168,51)$$ $$(10,59049,178,127,106)$$ $$(10,59049,178,134,97)$$ $$(10,59049,178,158,49)$$ $$(10,59049,178,161,38)$$ $$(10,59049,182,130,95)$$ $$(10,59049,182,143,74)$$ $$(10,59049,182,145,70)$$ $$(10,59049,182,154,47)$$ $$(10,59049,182,158,31)$$ $$(10,59049,182,161,2)$$ $$(10,59049,189,108,108)$$ $$(10,59049,190,118,95)$$ $$(10,59049,190,143,50)$$ $$(10,59049,192,123,84)$$ $$(10,59049,192,132,69)$$ $$(10,59049,192,141,48)$$ $$(10,59049,192,147,24)$$ $$(10,59049,193,130,70)$$ $$(10,59049,193,134,62)$$ $$(10,59049,193,146,22)$$ $$(10,59049,195,132,60)$$ $$(10,59049,198,126,63)$$ $$(10,59049,202,97,94)$$ $$(10,59049,202,113,74)$$ $$(10,59049,202,127,46)$$ $$(10,59049,202,134,17)$$ $$(10,59049,204,123,48)$$ $$(10,59049,204,132,3)$$ $$(10,59049,206,113,62)$$ $$(10,59049,206,127,22)$$ $$(10,59049,207,90,90)$$ $$(10,59049,207,126,18)$$ $$(10,59049,209,118,38)$$ $$(10,59049,209,122,22)$$ $$(10,59049,214,97,62)$$ $$(10,59049,214,113,22)$$ $$(10,59049,216,108,27)$$ $$(10,59049,218,95,50)$$ $$(10,59049,218,97,46)$$ $$(10,59049,218,106,17)$$ $$(10,59049,223,74,62)$$ $$(10,59049,223,94,22)$$ $$(10,59049,225,90,18)$$ $$(10,59049,228,69,48)$$ $$(10,59049,228,84,3)$$ $$(10,59049,234,63,18)$$ $$(10,59049,237,48,24)$$ $$(10,59049,238,38,31)$$ $$(10,59049,238,46,17)$$ $$(10,59049,238,47,14)$$ $$(10,59049,238,49,2)$$ $$(10,59049,239,38,22)$$ $$(10,59049,241,22,22)$$ $$(10,59049,242,17,14)$$ $$(10,59049,242,22,1)$$ $$(10,59049,243,0,0)$$

Proffering a special solution in your case of $3^n$ using quaternion algebra.

When $n$ is odd this is trivial.

When $n$ is even we can consider the quaternion $$q=2+2i+j.$$ It has reduced norm $N(q)=2^2+2^2+1^2=9$, so we know that $N(q^\ell)=9^\ell$ for all integers $\ell$. Also, clearly the powers of $q$ belong to the Lipschitz order $\mathcal O_L=\Bbb{Z}\oplus\Bbb{Z}i\oplus \Bbb{Z}j\oplus\Bbb{Z}k.$

Let $u$ be the unit vector $u=(2i+j)/\sqrt5$. Because $u^2=-1$ (holds for all unit vectors $u$), it follows that $\Bbb{C}_u:=\Bbb{R}\oplus \Bbb{R}u$ is a subring of the quaternions (actually it is isomorphic to the field of complex numbers, but we won't be needing that bit). Consequently $q^\ell\in\Bbb{C}_u$ for all integers $\ell$.

Therefore:

• The quaternion $q^\ell$ has integer coefficients, because those powers belong to the ring $\mathcal{O}_L$.
• When we write the quaternion power $$q^\ell=a_\ell+b_\ell i+c_\ell j+d_\ell k$$ with some integers $a_\ell,b_\ell, c_\ell, d_\ell$, we always have $d_\ell=0$, because $q^\ell\in\Bbb{C}_u$.
• Thus $$9^\ell=a_\ell^2+b_\ell^2+c_\ell^2$$ is a presentation of $9^\ell$ as a sum of three integers for all natural numbers $\ell$.

So we get $$\begin{array}{c|c|c|c} \ell&a_\ell&b_\ell&c_\ell\\ \hline 1&2&2&1\\ 2&-1&8&4\\ 3&-22&14&7\\ 4&-79&-16&-8\\ 5&-118&-190&-95\\ 6&239&-616&-308\\ 7&2018&-754&-377 \end{array}$$ Extend as you see fit.

The quaternion product rule of $q^{\ell+1}=q\cdot q^\ell$ translates to the following recurrence formula for the integers $a_\ell,b_\ell,c_\ell$:

• $a_{\ell+1}=2a_{\ell}-2b_{\ell}-c_{\ell}$,
• $b_{\ell+1}=2a_{\ell}+2b_{\ell}$,
• $c_{\ell+1}=2c_{\ell}+a_{\ell}$,
• And, as an extra, we shall always have $0=d_{\ell+1}=2c_{\ell}-b_{\ell}$ explaining the relation $b_\ell=2c_\ell$ easily spotted from the above table.

This approach obviously generalizes to powers of any sum of three squares - simply arrange the coefficient of $k$ to be zero. OTOH this is unlikely to lead to a list of ALL presentations as sums of three squares.

• +1 At the moment only looking at prime powers $n = p^k$ where $p = 8k+7$ and $p=2$ are special cases. For now just $p=3$. At least I generate one solution, hopefully I can try to generate all solutions. – cactus314 Nov 21 '16 at 22:15
• You can obviously alter the signs of the coefficients at any point as long as you observe the rule $b_\ell=2c_\ell$ to keep the products inside the subring $\Bbb{C}_u$. – Jyrki Lahtonen Nov 21 '16 at 22:21
• We can possibly say more about this particular solution using the observation that $q=2+\sqrt{5}u$. Its powers behave exactly like those of $2+\sqrt5 i$. We simply need to split the imaginary parts (an integer multiple of $\sqrt5$) into orthogonal components with 2-to-1 ratio. – Jyrki Lahtonen Nov 22 '16 at 8:20

Continuing on from my previous answer, I’ve found three more infinite families that can be generated from small solutions. I now suspect these are just special cases of a more general parametric. My apologies for any typos, I did this in a rush.

$$(2,9,2,2,1)$$ $$(4,81,6,6,3)$$ $$(6,729,18,18,9)$$ $$(8,6561,54,54,27)$$ $$(10,59049,162,162,81)$$ $$(2c,3^2c,3^{c-1}*2,3^{c-1}*2,3^{c-1}), c>0$$

$$(4,81,8,4,1)$$ $$(6,729,24,12,3)$$ $$(8,6561,72,36,9)$$ $$(10,59049,216,108,27)$$ $$(2+2d,3^{2+2d},3^{d-1}*8,3^{d-1}*4,3^{d-1}), d>0$$

$$(4,81,7,4,4)$$ $$(6,729,21,12,12)$$ $$(8,6561,63,36,36)$$ $$(10,59049,189,108,108)$$ $$(2+2e,3^{2+2e},3^{e-1}*7,3^{e-1}*4,3^{e-1}*4), e>0$$

Update 29 Nov 2016.

I’ve assumed and used the most obvious method of generating new solutions in my answers, but neglected to spot its generality; multiplying through by a constant $3^k$.

Sorry.

When $(q,n,x,y,z)$ is a solution, then new solutions are given by $$(q+2k,3^{2k}n,3^kx,3^ky,3^kz)$$