# integer solutions to quadratic forms

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?

-
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 – Eric Tressler Jul 29 '10 at 21:08
By rearranging your formula, you get to the equation $(x-z)(x+z)=(w-y)(w+y)$. Basically $x-z$ 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$. – Matt Young Jul 29 '10 at 21:18
+1 Eric Tressler. Expanding on is comment, the relevant equations on the mathworld page are labeled 16-18. 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. – Daniel Litt Jul 29 '10 at 21:22
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. – Qiaochu Yuan Jul 29 '10 at 22:14
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). – 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^2-w^2=z^2-y^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^2-a^2+b^2:2bc:c^2-a^2-b^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^2-z^2-w^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 non-trivial zero.
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$. – Pete L. Clark Jul 29 '10 at 23:43