<s>[INST] lebesgue's identity In the Lebesgue's identity $$ a^2+b^2+c^2=d^2$$ where: $$a=m^2+n^2-p^2-q^2$$ $$b=2(mp+nq) $$ $$c=2(mq-np) $$ $$d=m^2+n^2+p^2+q^2 $$how can we write $(m,n,p,q)$ as a function of the integers $(a,b,c,d)$? I have been trying and failing. Please help.
 [/INST] Lebesgue's Identity is complete only if you add a scaling factor t. Hence,
$$\begin{align}
a &= (m^2+n^2-p^2-q^2)t\\
b &= 2(mp+nq)t\\
c &= 2(mq-np)t\\
d &= (m^2+n^2+p^2+q^2)t
\end{align}\tag{1}$$
As a function of the integers $a,b,c,d$, then the variables $m,n,p,q,t$ are simply,
$$\begin{align}
m &= \frac{-b-c}{a-d}\\
n &= \frac{-b+c}{a-d}\\
p &= 1\\
q &= 1\\
t &= \tfrac{1}{4}(-a+d)
\end{align}$$
If you substitute these into the eqns in $(1)$, for example,
$$(m^2+n^2-p^2-q^2)t-a = 0$$
then factor it, you get this result, hence is true if indeed $a^2+b^2+c^2 = d^2$. (Similarly for the 2nd, 3rd, 4th eqns.)
For the smallest solution,
$$1^2+2^2+2^2 = 3^2$$
we get $m,n,p,q,t = 2, 0, 1, 1,\tfrac{1}{2}$. And so on.
</s>