Another Project Euler problem has me checking the internet again. Among other conditions, four of my variables satisfy:
$$a^2+b^2+c^2=d^2 .$$
According to Wikipedia, this is known as a Pythagorean Quadruple. It goes on to say all quadruples can be generated from an odd value of $a$ and an even value of $b$ as:
$$c=\frac{a^2+b^2-p^2}{2}, \quad d=\frac{a^2+b^2+p^2}{2} ,$$
where $p$ is any factor of $a^2+b^2$ that satisfies $p^2<a^2+b^2$.
However, I can't see how or why this works. I also can't seem to see how this works for $\lbrace 4,4,7,9 \rbrace$. Am I missing something here?
I think $c$ and $d$ should have been $$ \begin{split} c &= \frac{a^2+b^2-p^2}{2 p}\qquad\qquad d &= \frac{a^2+b^2+p^2}{2 p} \end{split} $$