Consider the set of integers $x_1, x_2, x_3, x_4$

Such that:

$$x_1^2 + x_2^2 + x_3^2 = x_4^2$$

How does one compute all the solutions to this system?

I have the following method in place for computing solutions given the initial condition that $$x_1^2 + x_2^2 = y^2$$ for some integer $y$.

One can make the standard Pythagorean triple reduction given this condition and then repeat the reduction again thus generating a general solution for all integers.

But what if there exists 3 square numbers such that the sum of any 2 squares in this set if not a square but the sum of all 3 squares is a square? I have no reason to rule out this possibility and no way of generating such solutions

As a side note:

Given a number and told that it is part of a Pythagorean triple (let's say it's the hypotenuse) how do you find the other squares that sum to it?

You can parametrize the sphere by Stereographic projection. Have you considered that?

• Not exactly familiar with this... Would you have a softer intro by any chance? – frogeyedpeas Aug 9 '13 at 1:47
• Sure. Why not? Well, let's start with the case of Pythagorean triples $x^2+y^2=z^2$. The thing is, if $z=0$, then $x$ and $y$ both must be zero because $x^2$ and $y^2$ are positive. If not, you can divide by $z^2$ and look for rational points on the unit circle $(\frac{x}{z})^2 + (\frac{y}{z})^2 = 1$. See this link: math.stackexchange.com/questions/461527/… .... To be continued... – user66733 Aug 9 '13 at 1:51
• Now, after you have found a parametrization of the circle, you see that all rational points on the curve, except your fixed point, could be obtained by plugging integer values in your parametrization. If you can use the similar technique for other curves or surfaces then the problem will be solved the same way. The thing is, you can do the same with sphere. You can find a rational parametrization of the unit sphere using Stereographic projection. The details are in the wikipedia article I gave you. If you still need more details, let me know. – user66733 Aug 9 '13 at 1:54
• This is very cool – frogeyedpeas Aug 9 '13 at 2:03

All the primitive Pythagorean Quadruples are known. This is Theorem 3 on page 176 and Theorem 4 on page 177 of Jones_Pall_1939.pdf, available at TERNARY as a pdf. The same information is on the first two pages of Pall_Automorphs_1940.pdf at the same site.

The short version is this: you have an odd number $W$ Find all quadruples $a,b,c,d$ with $$a^2 + b^2 + c^2 + d^2 = W,$$ where we are allowed to mix order, take the variables to be positive, negative, or zero. Then all the primitive quadruples, odd entry first, are given by $$\left( a^2 + b^2 - c^2 - d^2 \right)^2 + 4 \left( ad-bc \right)^2 + 4 \left(ac+bd \right)^2 = W^2.$$

Meanwhile, if $t$ is some (positive) divisor of $W,$ we can do the same process for $W/t$ and $W^2 / t^2,$ then multiply all $a,b,c,d$ by $t.$

July 2015: for another project, I decided to try to generate all the quadruples by the sort of three-parameter formulas one gets by stereographic projection to $\mathbb S^2.$ the results are really disappointing. I think I will stick with the four parameter thing. I found it in Jones and Pall, but it goes back at least to V. A. Lebesgue (and likely known to Euler), https://en.wikipedia.org/wiki/Pythagorean_quadruple#Parametrization_of_primitive_quadruples and is a simple calculation using quaternions with ordinary integer coefficients. Alright, the (first correct) proof that the four parameter recipe gives all primitive solutions is from 1920, by Dickson. In 1941, Skolem gave a proof that can be adjusted to give a reasonably direct algorithm for taking a quadruple and reconstructing the four parameters. In 1956, one F. Steiger gave inequalities that make the mapping one-to-one. This is all reported in a 1962 article by Robert Spira, in the maa Monthly, May 1962, volume 69, number 5, pages 360-365, title The Diophantine Equation $x^2 + y^2 + z^2 = m^2.$ One thing I did not initially notice, Spira just discards the Pythagorean triples; in the quadruple setting, if one of the numbers is $0,$ we have a triple and can easily recover parameters.

Let's see, I was able to adapt the methods of Jones and Pall to $x^2 + y^2 + z^2 = 3 t^2,$ coefficients other than $3$ could also be handled this way. http://math.stackexchange.com/questions/1964607/when-will-a-parametric-solution-generate-all-possible-solutions/1965805#1965805