How does one solve the diophantine equation $x^2 + y^2 = z^2 + w^2 $? Can solutions be parameterized in three variables analogously to the Pythagorean triples case?

3$\begingroup$ A good starting point is research.att.com/~njas/sequences/A004018, which will tell you the number of ways to write $n$ as the sum of two squares, and give you some references. See also mathworld.wolfram.com/SumofSquaresFunction.html $\endgroup$ – Eric Tressler Jul 29 '10 at 21:08

7$\begingroup$ By rearranging your formula, you get to the equation $(xz)(x+z)=(wy)(w+y)$. Basically $xz$ and $x+z$ can be viewed as independent variables (the slight catch is that they have the same parity) and similarly for the right hand side. So in effect you want to solve the equation $ab = cd$ where $a = b \pmod{2}$ and $c = d \pmod{2}$. By letting $a$ and $b$ vary you then want to find all the different factorizations of $ab$ with a constraint modulo $2$. $\endgroup$ – Matt Young Jul 29 '10 at 21:18

$\begingroup$ +1 Eric Tressler. Expanding on is comment, the relevant equations on the mathworld page are labeled 1618. Basically, your question boils down to finding the splittings of the prime factors of $n=x^2+y^2$ that are equal to 1 mod 4. $\endgroup$ – Daniel Litt Jul 29 '10 at 21:22

$\begingroup$ Matt's approach is the way I would go. It's worth noting that a similar approach works for Pythagorean triples and, with a little effort, for Pythagorean quadruples x^2 + y^2 + z^2 = w^2 as well. $\endgroup$ – Qiaochu Yuan Jul 29 '10 at 22:14

$\begingroup$ Also (especially for rational solutions): make the substitutions w:=x+h, and the equation becomes linear in x. Use y,z,h as parameters and solve in x. Normalizing gives a parametrization for integers solution also (with some care about parity). $\endgroup$ – Pietro Majer Jul 29 '10 at 22:35
Here is the standard geometric argument: after extracting common factors, you are asking for rational points on the quadric $Q\colon x^2w^2=z^2y^2$ in $\mathbb{P}^3$, which is isomorphic to $\mathbb{P}^1\times\mathbb{P}^1$ (as Matt Young's comment explains). Projection from a point on $Q$ gives a birational map $p:Q\to \mathbb{P}^2$ hence a rational parameterisation of $Q$. Explicitly, projecting from $P_0=(0:1:0:1)$ to the $(w=0)$plane gives the parameterisation $$ p : (a:b:c)\in\mathbb{P}^2 \mapsto (2ab:c^2a^2+b^2:2bc:c^2a^2b^2) \in Q $$ of all the points except for the two lines on $Q$ passing through $P_0$  i.e. the intersection of $Q$ with the tangent plane at $P_0$, which are $z=w$, $x=\pm y$. Notice also that the points $\{b=0,a\ne\pm c\}$ all go to $P_0$, for the same reason.
The advantage of this method is that there is nothing particularly special about the quadratic form $x^2+y^2z^2w^2$ here; the same argument parameterises the rational zeros of any nonsingular quadratic form in 3 or more variables, as soon as it has one nontrivial zero.

3$\begingroup$ Right. As for finding the first nontrivial zero, that is what the Hasse principle is for. $\endgroup$ – Qiaochu Yuan Jul 29 '10 at 22:46

2$\begingroup$ The one thing which is somewhat special about the quadratic form $x^2 + y^2  z^2  w^2$ is that its discriminant is a square in the ground field, so the quadric surface is isomorphic to $\mathbb{P^1} \times \mathbb{P}^1$. Otherwise it would  assuming it has a rational point  merely be birational to $\mathbb{P}^1 \times \mathbb{P}^1$. $\endgroup$ – Pete L. Clark Jul 29 '10 at 23:43