<s>[INST] Diophantine equation ${x ^ 2}+{y ^ 2}+{z ^ 2}={m ^ 2}+{n ^ 2} $ has infinite solutions. What is its general solution formula? Diophantine equation ${x ^ 2}+{y ^ 2}+{z ^ 2}={m ^ 2}+{n ^ 2} $ has infinite solutions. For examples,
$\begin{array}{l}
{1^2}+ {3^2} + {4^2}  = {1^2} + {5^2}\\
{1^2} + {2^2} + {6^2} = {4^2} + {5^2}\\
{322^2} + {562^2} + {597^2} = {601^2} + {644^2}\\
{938^2} + {1063^2} + {4722^2} = {536^2} + {4901^2}\\
 \vdots 
\end{array}$
What is its general solution formula? How to get the general solution formula?
 [/INST] It is clear that there are infinitely many solutions (see my comment above). We know that the identity $$(a^2+b^2+c^2+d^2)^2=(a^2-b^2-c^2-d^2)^2+(2ab)^2+(2ac)^2+(2ad)^2$$ gives all the solutions of $x^2+y^2+z^2+w^2=u^2$.
Now we have $$x^2+y^2+z^2=m^2+n^2\iff x^2+y^2+z^2+(im)^2=n^2$$ because the identity is valid in the ring of the Gaussian integers, so for the parameters $a,b,c,id$ we get $$(a^2+b^2+c^2-d^2)^2=(a^2-b^2-c^2+d^2)^2+(2ab)^2+(2ac)^2-(2ad)^2$$ so we have
$$\boxed{(a^2+b^2+c^2-d^2)^2+(2ad)^2=(a^2-b^2-c^2+d^2)^2+(2ab)^2+(2ac)^2}$$ This new identity giving consequently all the solutions of the proposed equation.
</s>