Parametrization of $a^2+b^2+c^2=2d^2$ Is a complete parametrization of primitive solutions to the equation
$$a^2+b^2+c^2=2d^2\qquad a,b,c,d \in \mathbb{Z}$$
known? A reference would be great.  
Solutions to $a^2+b^2=c^2$ give solutions to the equation above, but I know that there are other solutions.
 A: Look for a single rational solution to $x^2+y^2+z^2=2$.  Say, $(x_0,y_0,z_0)=(-1,0,1)$.
Then take any three integers $(u,v,w)$ and seek solutions of form $(-1+tu,tv,1+tw)$. You get:
$$1-2tu+t^2u^2 + t^2v^2 + 1+2tw + t^2w^2=2$$
solving, excluding $t=0$, you get:
$$t=\frac{2(u-w)}{u^2+v^2+w^2}$$
Substituting that bach in, we get:
$$\begin{align}
x&=-1+tu = \frac{-(u^2+v^2+w^2)+2(u-w)u}{u^2+v^2+w^2}&=&\frac{u^2-2uw-v^2-w^2}{u^2+v^2+w^2}\\
y&=tv &=& \frac{2(u-w)v}{u^2+v^2+w^2}\\
z&=1+tw &=&\frac{u^2+v^2-w^2 +2uw}{u^2+v^2+w^2}
\end{align}$$
Then $$(a,b,c,d)=(u^2-2uw-v^2-w^2,2(u-w)v,u^2+v^2-w^2+2uw,u^2+v^2+w^2)\tag{1}$$
When $w=0$, this gives: $(a,b,c,d)=(u^2-v^2,2uv,u^2+v^2,u^2+v^2)$, which is the result you note that if $(a,b,c)$ is a Pythagorean triple then $(a,b,c,c)$ is a solution of your equation. (I had to pick the $(x_0,y_0,z_0)$ carefully to make that work.
The formula (1) should yield all integer solutions, up to constant multiples.
To ensure a primitive solution, you need that $u+v+w$ is odd and that $u-w$ and $v^2+2u^2$ are relatively prime. That is equivalent to $\gcd(2(u-w),u^2+v^2+w^2)=1$, which is saying that $t$ above is in lowest common denominator form.
As Will noted in comments, this doesn't give all primitive solutions directly, since:
$$9^2+4^2+1^2=2\cdot 7^2$$
is a solution, and there is no way to write $7$ as the sum of three squares.
Instead, we get: $21=4^2+2^2+1^2$, and we get a solution:
$$(27,12,3,21)$$ from my formula, which is obviously not primitive.
