# parametric solution for the sum of three square

Is there a parametric integer solution for $x,y,z,t$ when the sum of three square is equal to a square, i.e, $$x^2+y^2+z^2=t^2$$?

• As for spherical coordinates, one may simply choose \begin{align*} x &= t \cos \theta \sin \varphi \\ y &= t \cos \theta \cos \varphi \\ z &= t \sin \theta \end{align*} – user61527 Feb 2 '14 at 0:27
• I think the OP wants a solution for integers, not reals. Something akin to the parametrization of Pythagorean triples $$a = k(m^2 - n^2), \quad b = 2kmn, \quad c = k(m^2 + n^2).$$ – heropup Feb 2 '14 at 0:36
• Duplicate : math.stackexchange.com/questions/646255/… – Balarka Sen Feb 2 '14 at 11:15

## 3 Answers

EDIT: I knew i had written up Jones and Pall 1939 before, but it was on a question with different intent: Every integer vector in $\mathbb R^n$ with integer length is part of an orthogonal basis of $\mathbb R^n$

J-P 1939: as long as $t$ is odd, find all solutions to $$a^2 + b^2 + c^2 + d^2 = t,$$ including permuting the letters and choosing various $\pm$ signs, while not requiring $a,b,c,d$ to be coprime. Then all solutions to your equation are given by $$\left( a^2 + b^2 - c^2 - d^2 \right)^2 + (-2ad+2bc)^2 +(2ac+2bd)^2 = t^2.$$

Edit, November 26, 2016. This is often called Lebesgue's Formula, after V. A. Lebesgue the number theorist. It seems to go back to Euler as well. The first acceptable proof that all solution arise this way was due to L. E. Dickson, about 1920.

This is Theorem 3 on page 176 of Regular and Semi-Regular Positive Ternary Quadratic Forms, Acta Mathematica, volume 70, (1939), pages 165-191. It is a theorem about quaternions with all coefficients integers.

Now, if $t$ is even, then $t^2$ is divisible by $4,$ which means you need to double all three numbers; if the sum of three squares is divisible by $4,$ then all the squares are even. So, given some even number $n = 2^k t$ with $t$ odd, solve as above, then multiply through all solutions found by the same $2^k.$

I finished the version with stereographic projection from the North Pole of the sphere, and I can see now why this is not typically taught: by the Gauss-Legendre Three Squares Theorem, either $t$ or $2t$ is the sum of three squares, possibly both.

The first case gives, when $\color{magenta}{t = p^2 + q^2 + r^2},$ $$(2rp)^2 + (2rq)^2 + \left( p^2 + q^2 - r^2 \right)^2 = t^2.$$ Note that the recipe above cannot be used for $t=7,$ despite $2^2+3^2+6^2=7^2.$

If, instead,when $\color{magenta}{2t = p^2 + q^2 + r^2},$ then $p^2 + q^2 - r^2$ is even and $$(rp)^2 + (rq)^2 + \left( \frac{p^2 + q^2 - r^2}{2} \right)^2 = t^2.$$ This way, $2 \cdot 7 = 14 = 3^2 + 2^2 + 1^2,$ we do get $3^2 + 2^2 + (12/2)^2 = 49.$

Let's see, this is very different from Pythagorean triples. there are no restrictions on $t$ at all. Also, if you multiply $t$ by $4$ in either of the recipes above, all that happens is that you are forced to double all three of $p,q,r,$ so nothing important changes. that is, if the sum of three squares is divisible by 4, the squares are all even.

For those keeping score at home, it is quite easy to show that all rational points on the unit sphere $x^2 + y^2 + z^2 = 1$ other than the North Pole $(0,0,1)$ are given by $$\left( \; \frac{-2rp}{p^2 + q^2 + r^2} \; , \; \frac{-2rq}{p^2 + q^2 + r^2} \; , \; \frac{p^2 + q^2 - r^2}{p^2 + q^2 + r^2} \; \right)$$ for an integer triple $p,q,r.$

• @LeeYiyuan, alright. This result is due to Jones and Pall, 1939. – Will Jagy Feb 2 '14 at 1:43
• I cannot access the article linked, but it seems like R=Quaternion(m,n,-p,q)*Quaternion(n,m,q,p) gives the Lebesque Identity with norm squared R=t – don bright Jun 2 '19 at 23:41
• – Will Jagy Jun 2 '19 at 23:43
• wow, thank you ... that is a bit above my head!! – don bright Jun 2 '19 at 23:59

There is a parameterization for every equal sums of squares equation $$X_1^2 + \dotsb + X_m^2 = Y_1^2 + \dotsb + Y_n^2$$ with $n,m$ positive integers and all $X_i,Y_i$ integers; your equation is the special case $(m,n)=(3,1)$. The papers by Barnett and Bradley are my first recommendations.

Notice that for all integers $n$:$$n^2 + (n + 1)^2 + (n(n + 1))^2 = (n^2 + n + 1)^2$$ Of course, the above parametric solution does not necessarily represent all integer solutions.

• Indeed, (1,0,0,1) is certainly not! – RghtHndSd Feb 2 '14 at 20:12
• @RghtHndSd: Permitting permutation, it is. – Kieren MacMillan Sep 6 '14 at 20:59
• @KierenMacMillan: Such a statement will not be true for $(a,0,0,a)$ in general. – RghtHndSd Sep 7 '14 at 1:23