Solve equations: $x+y+z+w=30$; $x^2+y^2=z^2+w^2$ 
I have been trying to find the solutions to the joint equations below,
$$x+y+z+w=30$$
$$x^2+y^2=z^2+w^2$$
where $x$, $y$, $z$ and $z$ are distinctive natural numbers.

I have not worked with integer equations that much and do not seem to have equipped myself with a systematic approach as I do real equations. So, with certain reasoning and some reluctant trial-and-errors, I was able to come up with one set of solutions, only after about a good hour spent.
I am not sure how to tell if there are other solutions and aware that my method is inefficient to find them. I would like to see if there is a clean algebraic way to find all the solutions.
 A: The general solution of $x^2+y^2=z^2+w^2$ is given by the identity
$$(ab+cd)^2+(ad-bc)^2=(ab-cd)^2+(ad+bc)^2$$ where $a,b,c,d$ are arbitrary integers.
It follows that we have to take  $a,b,c,d$ such that
$$2a(b+d)=30\iff a(b+d)=15$$ For example $(a,b,d)=(3,1,4)$ gives the following  parameterization of solutions with the parameter $t$
$$\begin{cases}x=3+4t\\y=12-t\\z=3-4t\\w=12+t\end{cases}$$
A: Rewrite the system as
\begin{align}
   (x+z) + (w+y) &= 30\\
   (x+z)(x-z)    &= (w+y)(w-y) \tag{1}
\end{align}
and make substitution $k = x + z,\, m = x - z,\, l = w + y,\, n = w - y$ to get
\begin{align}
   k + l &= 30\\
      km &= ln. \tag{2}
\end{align}
Obviously, any integral solution of $(1)$ gives us an integral solution of $(2)$. However, not every integral solution of $(2)$ will give an integral solution of $(1)$. Necessary and sufficient condition for an integral solution of $(2)$ to give an integral solution of $(1)$ is $k\equiv l \equiv m \equiv n \pmod 2$.
Thus, our strategy will be to describe all solutions of $(2)$, determine necessary and sufficient condition for $k\equiv l \equiv m \equiv n \pmod 2$ to hold, and therefore describe all solutions of $(1)$.

Let us solve $(2)$. Note that by substituting $l = 30 - k $ we get a homogeneous linear Diophantine equation in $m,\, n$ with parameter $k$:
$$ km - (30 - k)n = 0,$$
and thus, all of its solutions are given by
\begin{align}
   m &= \frac{30 - k}d t,\\
   n &= \frac kd t,\quad    t\in\mathbb Z,
\end{align}
where $d = \gcd(k,30-k) = \gcd(k,30).$
So, if $(k, l, m, n)$ is a solution of $(2)$, then it is of the form $(k, 30-k, \frac{30 - k}d t, \frac kd t),\ k,t\in\mathbb Z$. Obviously, any quadruple of that form is a solution of $(2)$.

We now have that any integral solution $(x, y, z, w)$ of $(1)$ is of the form 

\begin{align}
   x &= \frac{kd + (30 - k)t}{2d}\\
   y &= \frac{(30 - k)d - kt}{2d}\\
   z &= \frac{kd - (30 - k)t}{2d}\\
   w &= \frac{(30 - k)d + kt}{2d},   \quad k,t\in\mathbb Z. \tag{3}
\end{align}

It remains to determine for which choices of $k, t\in\mathbb Z$ the above solution is integral. I claim that

$(x, y, z, w)$ given by $(3)$ is in $\mathbb Z^4$ if and only if $k\equiv t \pmod 2$.

Proof. Let $(x, y, z, w)$ given by $(3)$ be in $\mathbb Z^4$. In particular, $k + \frac{30 - k}d t$ and $30 - k - \frac kd t$ are both even. Since $\frac kd$ and $\frac{30 - k}d$ are relatively prime, at least one of them is odd. WLOG, let it be $\frac kd$. Then,
$$30 - k - \frac kd t \equiv 0 \pmod 2 \implies k \equiv \frac kd t \pmod 2 \stackrel{\frac kd \equiv 1 \pmod 2}\implies k \equiv t \pmod 2.$$
Now, let $k \equiv t \pmod 2$. If both are even, then $k + \frac{30 - k}d t$, $30 - k - \frac kd t$, $k - \frac{30 - k}d t$ and $30 - k + \frac kd t$ are all even and thus $x, y, z, w \in \mathbb Z$. If they are both odd, then $\frac kd$ and $\frac{30 - k}d$ are also odd and the same conclusion holds. $\tag*{$\square$}$

Therefore, all solutions of $(1)$ are given by $(3)$ with additional condition that $k \equiv t \pmod 2$.


Example. Let $k = 10$. Then $d = 10$ and
\begin{align}
   x &= 5 + t \\
   y &= 10 - \frac t2 \\
   z &= 5 - t \\
   w &= 10 + \frac t2,   \quad t \in 2\mathbb Z.
\end{align}
Letting $t = -2$ gives us solution $(3, 11, 7, 9)$.

Finally, let me remark that representation of a solution of $(1)$ by $(3)$ should be unique if I'm not making some silly mistake, i.e. different choices of pair $(k, t)$ will necessarily give us different quadruples $(x, y, z, w)$.
This is because different solutions $(k, l, m, n)$ of $(2)$ will give us different solutions $(x, y, z, w)$ of $(1)$ and different choices of $(k, t)$ will give us different solutions $(k, 30-k, \frac{30 - k}d t, \frac kd t)$ of $(2)$.
A: We can assume that $w=\max \{x,y,z,w\}$ and $z=\min \{x,y,z,w\}$ (at the end we take all permutation). Write: $$(x-z)(x+z)= (w-y)(w+y)\implies $$
exists $a,b,c,d\in\mathbb{N}$ such that 
\begin{eqnarray}
x+z &=& ab\\ 
x-z &=& cd\\
w-y &=& ac\\
w+y&=&bd
\end{eqnarray}
so $b(a+d)= 30 \;\;\wedge \;\; d>a \implies b\leq 10$, so $b\in\{1,2,3,5,6,10\}$


*

*if $b=10$ then $a=1$ and $d=2$ so $x=...$

*if $b=6$ then $a=1$ and $d=4$ or $a=2$ and $d=3$...

*if $b=5$ then $a=1$ and $d=5$ or $a=2$ and $d=4$... 

*...

A: Let $m,n$ be integers. Then we may write $$x=2mn,y=m^2-n^2,$$ so that the system becomes $$w^2+z^2=p,w+z=q,$$ where $p=m^2+n^2$ and $q=30-2mn-m^2+n^2.$
The $2×2$ system in $z,w$ may be easily solved, so that $z,w$ may also be explicitly written in terms of the integers $m,n.$ In particular, substitution gives the quadratic equation $$2z^2-2qz+q^2-p=0.$$ For the solutions $z$ to be integers, it is necessary that the discriminant $$2p-q^2$$ be a complete square.
A particular case of the analysis above with one of $z,w$ set to $0$ shows that there is no solution of the form $0,a,b,c.$
