Diophantine equation $a^2+b^2=c^2+d^2$ I was reasonably certain I've seen this before, but I was wondering how to solve the Diophantine equation
$$a^2+b^2=c^2+d^2$$
I tried a web search and found nothing on this one.  I'm trying to avoid another library trip to a less than local library (maybe I should have taken better notes on that chapter...).
I'm not quite sure how to handle this one.  The only thing I can figure out with this equation, if I remember correctly, is that the sum on either side may only contain prime factors of 2 or odd primes congruent to 1 mod 4.  And if I don't want a and b equal to c and d, the sum can't be prime as I believe a prime congruent to 1 mod 4 can be represented as the sum of 2 squares in exactly one way.  But that doesn't give me any insight into actually solving this problem.

This equation is quite symmetrical so formulas making too much can be written: So for the equation:
$X^2+Y^2=Z^2+R^2$ 
solution:
$X=a(p^2+s^2)$ 
$Y=b(p^2+s^2)$ 
$Z=a(p^2-s^2)+2psb$ 
$R=2psa+(s^2-p^2)b$ 
solution: 
$X=p^2-2(a-2b)ps+(2a^2-4ab+3b^2)s^2$ 
$Y=2p^2-4(a-b)ps+(4a^2-6ab+2b^2)s^2$
$Z=2p^2-2(a-2b)ps+2(b^2-a^2)s^2$ 
$R=p^2-2(3a-2b)ps+(4a^2-8ab+3b^2)s^2$ 
solution: 
$X=p^2+2(a-2b)ps+(10a^2-4ab-5b^2)s^2$ 
$Y=2p^2+4(a+b)ps+(20a^2-14ab+2b^2)s^2$ 
$Z=-2p^2+2(a-2b)ps+(22a^2-16ab-2b^2)s^2$ 
$R=p^2+2(7a-2b)ps+(4a^2+8ab-5b^2)s^2$ 
solution: 
$X=2(a+b)p^2+2(a+b)ps+(5a-4b)s^2$ 
$Y=2((2a-b)p^2+2(a+b)ps+(5a-b)s^2)$ 
$Z=2((a+b)p^2+(7a-2b)ps+(a+b)s^2)$ 
$R=2(b-2a)p^2+2(a+b)ps+(11a-4b)s^2$
solution: 
$X=2(b-a)p^2+2(a-b)ps-as^2$ 
$Y=2((b-2a)p^2+2(a-b)ps+(b-a)s^2)$ 
$Z=2((b-a)p^2+(3a-2b)ps-(a-b)s^2)$ 
$R=2(b-2a)p^2+2(a-b)ps+as^2$
solution: 
$X=(p^2-s^2)b^2+a^2s^2$
$Y=b^2(p-s)^2-2abs^2+a^2s^2$
$Z=b^2(p-s)^2+2abps-a^2s^2$
$R=s^2(a-b)^2+2abps-p^2b^2$
number $a,b,p,s$ integers and sets us, and may be of any sign.
