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?
 A: When $z\neq 0,$ that means we want all rational solutions to:
$$m^2+n^2-x^2-y^2=1\tag 1$$
We pick one solution, $\mathbf s_0=(m_0,n_0,x_0,y_0)=(-1,0,0,0)$ and any directional vector $\mathbf p=(p_1,p_2,p_3,p_4)$ with the $p_i$ integers with $\gcd(p_1,p_2,p_3,p_4)=1.$
Then $\mathbf s_0+t\mathbf p$ yields a solution for $t=0$ trivially, and we get another value $t$ where you get another solution.
Specifically, you want $$(-1+p_1t)^2+(p_2t)^2-(p_3t)^2-(p_4t)^2=1$$ which, when simplified and factoring out $t,$ gives you:
$$-2p_1+(p_1^2+p_2^2-p_3^2-p_4^2)t=0\\
t=\frac{2p_1}{p_1^2+p_2^2-p_3^2-p_4^2}$$ where now we assume $p_1^2+p_2^2\neq p_3^2+p_4^2.$
Then our integer solution formula is $$\begin{align}m&=p_1^2-p_2^2+p_3^2+p_4^2\\
n&=2p_1p_2\\
x&=2p_1p_3\\
y&=2p_1p_4\\
z&=p_1^2+p_2^2-p_3^2-p_4^2.
\end{align}$$
This won't give primitive solutions, in that we won't always have $\gcd(m,n,x,y,z)=1,$ but we'll get one from every equivalence class of solutions with $z\neq 0.$
This will also give solutions with $z=0,$ but we don't know yet if it will give all (equivalence classes) of solutions for $z=0.$ But we can show if $z=0,$ the above solution is a scalar multiple of $(m,n,x,y,z)=(p_1,p_2,p_3,p_4,0),$ which gives all solutions.
The fact that three of the numbers are even makes it clear that we can't get all the primitive solutions with $z\neq 0.$ For example, we can get values $m$ odd, so we should be able to get $n$ odd.

For example, $(p_i)=(2,1,1,1)$ gives a solution $(m,n,x,y,z)=(5,4,4,4,3).$
This means we need a solution with $(m,n)$ switched, and possibly scaled .
The corresponding rational solution to $(1)$ is $(m,n,x,y)=(\frac43,\frac53,\frac43,\frac43)$ which is in the direction $p=(7,5,4,4)$ from $s_0.$
That gives $m=56, n=70, x=56,y=56, z=42.$ And that is $14$ times our goal $(m,n,x,y,z)=(4,5,4,4,3).$

This technique works for all homogenous quadratic Diophantine equations: once you find one non-zero solution, you can find an infinite class. But the formula won't general all solutions - it will only generate all solutions of the corresponding rational equation, which means it will generate all solutions modulo scalar multiplication, and with one fixed variable chosen to be non-zero.
In general, we would first assume $z\neq 0,$ apply the above technique, then assume $z=0$ and solve the resulting smaller Diophantine equation using the same technique. But often, the resulting formula for $z\neq 0$ would give (up to equivalence) all solutions for $z=0.$
Sometimes, we get an obvious variable to assume non-zero. $x^2+xy+y^2=z^2$ has only the trivial solution when $z=0,$ so we can assume $z\neq 0$ for all others.
A: 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.
A: A very simple equation. You can write various combinations.
https://artofproblemsolving.com/community/c3046h1055645_quadratic_diophantine_equation
For the equation:
$$X_1^2+X_2^2=Y_1^2+Y_2^2+Y_3^2$$
Solutions have the form:
$$X_1=t^2+2(p+s-k)t+2k^2+2p^2+4ps-4pk-2sk$$
$$X_2=t^2+2(p+s-k)t+2k^2+2s^2+4ps-2pk-4sk$$
$$Y_1=t^2+2(p+s-k)t+2k^2+2ps-2pk-2sk$$
$$Y_2=t^2+2(p+s-k)t+2ps$$
$$Y_3=2(p+s-k)(t+p+s-k)$$
