# Sum of three squares equalling a different sum of three squares

Assume $$x_1, x_2, x_3, y_1, y_2, y_3 \in \mathbb{N}_{> 0}$$. I am trying to figure out if it is possible to find all solutions where

$$x_1^2 + x_2^2 + x_3^2 = y_1^2 + y_2^2 + y_3^2.$$

I know the Three-Square Theorem places conditions on what types of numbers may be written as the sum of three squares, but I am not sure how that applies here.

• Your points are on a sphere. Commented May 19 at 20:41

There is a classical way of finding all rational solutions to a quadratic equation (such as the Pythagorean equation $$x^2+y^2=1$$). Fix one solution—in our case we'll fix $$(x_1,x_2,x_3,y_1,y_2,y_3) = (-1,0,0,-1,0,0)$$. Then for every other rational solution $$(s_1,s_2,s_3,t_1,t_2,t_3)$$, each of the "slopes" $$m_1=\frac{s_1-(-1)}{t_3-0}$$, $$m_2=\frac{s_2-0}{t_3-0}$$, $$m_3=\frac{s_3-0}{t_3-0}$$, $$m_4=\frac{t_1-(-1)}{t_3-0}$$, $$m_5=\frac{t_2-0}{t_3-0}$$ must be a rational number. On the other hand, given any five rational numbers $$m_1,m_2,m_3,m_4,m_5$$, the intersection of the quadratic surface $$x_1^2+x_2^2+x_3^2=y_1^2+y_2^2+y_3^2$$ with these five hyperplanes $$m_1t_3=s_1+1$$, $$m_2t_3=s_2$$, $$m_3t_3=s_3$$, $$m_4t_3=t_1+1$$, $$m_5t_3=t_2$$ yields a pair of points, one of which, namely $$(-1,0,0,-1,0,0)$$, we already know; solving the corresponding quadratic equation will give us the other point.
Therefore there is a bijective correspondence between $$5$$-tuples $$(m_1,m_2,m_3,m_4,m_5)$$ of rational numbers and rational solutions to $$x_1^2+x_2^2+x_3^2=y_1^2+y_2^2+y_3^2$$ other than $$(-1,0,0,-1,0,0)$$. Solving these equations yields \begin{align*} x_1 &= \frac{m_1^2-2 m_1m_4-m_2^2-m_3^2+m_4^2+m_5^2+1}{m_1^2+m_2^2+m_3^2-m_4^2-m_5^2-1} \\ x_2 &= \frac{2 m_2(m_1-m_4)}{m_1^2+m_2^2+m_3^2-m_4^2-m_5^2-1} \\ x_3 &= \frac{2 m_3(m_1 -m_4)}{m_1^2+m_2^2+m_3^2-m_4^2-m_5^2-1} \\ y_1 &= \frac{-m_1^2+2 m_1m_4-m_2^2-m_3^2-m_4^2+m_5^2+1}{m_1^2+m_2^2+m_3^2-m_4^2-m_5^2-1} \\ y_2 &= \frac{2 m_5(m_1-m_4)}{m_1^2+m_2^2+m_3^2-m_4^2-m_5^2-1} \\ y_3 &= \frac{2(m_1-m_4)}{m_1^2+m_2^2+m_3^2-m_4^2-m_5^2-1} \end{align*} If we write $$m_j = \frac{n_j}d$$ and clear all denominators, we get the parametrization in $$6$$ integer variables \begin{align*} x_1 &= n_1^2-2 n_1n_4-n_2^2-n_3^2+n_4^2+n_5^2 +d^2\\ x_2 &= 2 n_2(n_1-n_4) \\ x_3 &= 2 n_3 (n_1-n_4) \\ y_1 &= -n_1^2+2 n_1n_4-n_2^2-n_3^2-n_4^2+n_5^2+d^2 \\ y_2 &= 2 n_5(n_1-n_4) \\ y_3 &= 2 d (n_1-n_4). \end{align*} It would take extra work to produce a complete minimal parametrization (this one might hit solutions many times each). There are also some issues with gcds of the numbers. (Although since the original equation is homogeneous, finding integer and rational solutions is basically the same thing.)
• for integers, you'd want to divide through by $\gcd(x_1, x_2, x_3, y_1, y_2, y_3).$ For example, four of the six numbers are even, while there are solutions with all odd, or four odd. Commented May 19 at 22:20