27

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.

Mike
  • 13,318
  • 3
    Write it as $a^2 - c^2 = d^2 - b^2$. – Qiaochu Yuan Jun 04 '12 at 03:49
  • @QiaochuYuan: What does that give. I also thought of the same thing, but couldn't get far enough. –  Jun 04 '12 at 03:52
  • 1
    I’ll add just a little and remark that it has something to do with the number of primes congruent to 1 modulo 4 that appear in the number. For instance, $65=64+1=49+16$. – Lubin Jun 04 '12 at 03:54
  • Follow Lubin's hint you will find the solution if you think the problem in the ring $\mathbb{Z}[i]$. The next example will be $85$. – Joy-Joy Jun 04 '12 at 04:15
  • There are so, so many general equations. Here are a few I’ve found just by using high-school algebra: $$(3a+b)^2+(4a^2+ab+1)^2=(5a+b)^2+(4a^2+ab-1)^2$$ $$(a+3b)^2+(8a+b)^2=(7a+b)^2+(4a+3b)^2$$ $$(3a+b)^2+(14a+3b)^2=(6a+b)^2+(13a+3b)^2$$ $$(5a+2b)^2+(27+3b)^2=(15a+3b)^2+(23a+2b)^2$$ $$(8a+2b)^2+(9a+b)^2=(a+b)^2+(12a+2b)^2$$ and, by letting $P=2(d-b)$, $Q=a^2+2ax+b^2$ and $R=c^2+2cx+d^2$ then if $a^2+b^2=c^2+d^2$ it follows then that $$\big{P(a+x)\big}^2+(P\cdot b + Q - R)^2 = {P(c+x)\big}^2+(P\cdot d + Q - R)^2$$ – Mr Pie Jan 22 '20 at 17:39
  • @MrPie I don't think the first two equations are true, although I didn't check the others. – W. Wongcharoenbhorn Oct 07 '20 at 05:37
  • 1
    @W.Wongcharoenbhorn the first equation is true, but the second is actually not. It should be the other way round: where instead of $3b$ adding to $a$ and $4a$, it should add to $8a$ and $7a$, and vice versa. We should have: $$(a+b)^2+(8a+3b)^2=(7a+3b)^2+(4a+b)^2$$ thanks for noticing. I've also realised that the $P,Q,R$ one is unnecessarily fancy. It may as well just be written as such, for any $x$ and $a,b,c,d$ such that $a^2+b^2=c^2+d^2$: $$\big{(d-b)(a+x)\big}^2+\big{b(d-b) +x(a-c)\big}^2=\big{(d-b)(c+x)\big}^2+\big{d(d-b)+x(a-c)\big}^2$$ Thanks for the pickup! – Mr Pie Oct 07 '20 at 10:49
  • @W.Wongcharoenbhorn the fourth equation is also missing an $a$ in front of $27$ on the left-hand side. perhaps i rushed a bit :P – Mr Pie Oct 07 '20 at 10:53

9 Answers9

19

Essentially you ask for a parametrization of the quadric $V(a^2+b^2=c^2+d^2)$. There is a general geometric method how to do that, which you can find here. On page 13, this example is discussed: Solutions of $a^2+b^2=c^2+d^2$ are parametrized by

$(a,b,c,d) = (p r + q s , q r - p s , p r - q s , p s + q r),$

where $p,q,r,s$ are arbitrary. But one can also derive this via complex numbers (similar to the complex numbers solution of Pythagorean triples): Let $u = p + qi$, $v = r + si \in \mathbb{C}$. Then we have

$$|u \overline{v}| = |u| |\overline{v}| = |u| |v| = |u v|.$$

Square both sides, and compute the norms of the products explicitly. This gives you

$$(p r + q s)^2 + (q r - p s)^2 = (p r - q s)^2 + (p s + q r)^2.$$

YuiTo Cheng
  • 4,705
16

Let $N$ be a positive integer with prime power factorization $$N=2^a \prod_{i=1}^m p_i^{b_i}\prod_{j=1}^n q_j^{c_j},$$ where the $p_i$ are distinct primes congruent to $1$ modulo $4$, and the $q_j$ are distinct primes congruent to $-1$ modulo $4$. (We allow $a$ to be $0$, and $m$ or $n$ or both could be $0$.)

If at least one $c_j$ is odd, then $N$ has no representations as a sum of two squares. If all the $c_j$ are even, then the number of representations of $N$ as a sum of two squares is equal to $f(N)$, where $$f(N)=4\prod_{i=1}^m (b_i+1).$$ In this formula, in counting representations, order matters, and we allow the possibility of using negative integers.

If we want, for example, the representation $5=1^2+2^2$ to count as essentially the same as the representation $5=2^2+1^2$, and we do not want to allow negative integers, things get somewhat more complicated. Let $g(N)$ be the number of representations of $N$ as a sum of two non-negative squares, where order does not matter.

If $f(N)$ as defined above is divisible by $8$, then $g(N)=f(N)/8$.

If $f(N)$ as defined above is not divisible by $8$, then $g(N)=(f(N)+4)/8$.

The above formula gives a partial answer to your question, in that it tells us the number of solutions of the equation $a^2+b^2=c^2+d^2=N$, where order does not matter,and we allow only non-negative integers in the representation.

Your question also asks how to actually produce the solutions. The difficult part is to find representations of the $p_i$ as a sum of two squares. As you mentioned, there is, for any prime $p_i$ congruent to $1$ modulo $4$, essentially only one such representation. There are reasonably good algorithms available for producing the representation of such primes.

Once we have representations for the appropriate primes, we can obtain representations for products by repeatedly using the Brahmagupta Identity $$(s^2+t^2)(u^2+v^2)=(su+tv)^2+ (sv-tu)^2.$$ Here is a simple example. We have $13=2^2+3^2$ and $17=1^2+4^2$. So taking $s=2$, $t=3$, $u=1$, and $v=4$ we get $221=13\cdot 17= 14^2 + 5^2$.

Another essentially equivalent approach is to factor $N$ as a product of Gaussian primes. Once we have that, we can easily produce all representations of $N$ as a sum of two squares.

André Nicolas
  • 507,029
1

$[2(wx+yz)+w+x+y+z+1]^{2} +[2(wy-xz)+w+y-x-z]^{2} = [2(wx-yz)+w+x-y-z]^{2} + [2(wy+xz)+w+x+y+z+1]^{2}$

                 [OR]

$[2wx+yz]^{2} + [2wy-xz]^{2} = [2wx-yz]^{2} + [2wy+xz]^{2}$

K_user
  • 2,438
sujith
  • 11
1

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.

individ
  • 4,301
0

THE SET OF SOLUTION TO THE DIOPHANTINE EQUATION$$A^2+B^2=C^2+D^2$$ can be given by
$$A=|ma/n| , B=|mb/n| , C=|mc/n| , D=|md/n|$$ where $a=up,$ $b=vp+(u^2+v^2),$ $c=up+2uv,$ $d=vp+(v^2-u^2)$ AND $n$ is the HIGHEST COMMON FACTOR of $a,b,c,d$ AND $m,p,u,v$ are integer.

0

The equation can be solved by finding any value of $C$ in a Pythagorean triple where $2$ combinations of $A^2+B^2=C^2$. Given Euclid's formula we begin by solving the $C$-function for $n$ in terms of $C$ and $m$. $$A=m^2-n^2\quad B=2mn\quad C=m^2+n^2$$

$$C=m^2+k^2\implies n=\sqrt{C-m^2}\qquad\text{where}\qquad \bigg\lfloor\frac{ 1+\sqrt{2C-1}}{2}\bigg\rfloor \le m \le \lfloor\sqrt{C-1}\rfloor$$ The lower limit ensures $m>k$ and the upper limit ensures $k\in\mathbb{N}$. $$C=65\implies \bigg\lfloor\frac{ 1+\sqrt{130-1}}{2}\bigg\rfloor=6 \le m \le \lfloor\sqrt{65-1}\rfloor=8\quad\text{ and we find} \quad m\in\{7,8\}\Rightarrow k\in\{4,1\}\\$$ $$F(7,4)=(33,56,65)\quad F(8,1)=(63,16,65) $$

There infinitely many of these pairs of triples; the next that meet the criteria are

$\quad(13,84,85), (77,36,85)\qquad (75,100,125), (117,44,125)\qquad (17,144,145), (143,24,145)\quad\quad ...$

poetasis
  • 6,338
0

You can write a similar equation and solutions:

$a^2+ac+c^2=x^2+xy+y^2$

Solutions have the form:

$a=q^2+k^2-p^2+kq$

$c=q^2+k^2+2p^2+kq-3pk-3pq$

$x=q^2-2k^2-p^2+3pk-2qk$

$y=k^2-2q^2-p^2+3pq-2qk$

more:

$a=(b-k)p^2+2(3b-2k)ps+(5b-7k)s^2$

$c=b(p^2-s^2)$

$x=bp^2+2(3b-2k)ps+(5b-8k)s^2$

$y=(b-k)p^2-2kps-(b-3k)s^2$

more:

$a=-(k+b)p^2+2(3b+k)ps+(7b-13k)s^2$

$c=2b(p^2-s^2)$

$x=(k-b)p^2+2(3b+k)ps+(7b-15k)s^2$

$y=-(k+b)p^2+6(k-b)ps+(7k-5b)s^2$

individ
  • 4,301
-1

Pick any point inside the square. The distances from the corners to that point have the relation $a^2 +c^2 = b^2 +d^2$ where the lines to that point are labeled $a,b,c,d$ going clockwise. Finding any point inside the unit square where all distances from the corners to that point are rational is an unsolved problem.

If you did find such a point you would find integer solutions to those distances and the diophantine equation above. You also would have found eight pythagorean triple triangles that can be assembled into a square.

robert
  • 11
-1

Here is the formula for all the solutions of $a^2+b^2=c^2+d^2$ Take $$a=x-y $$ $$b=x^2+xy+y^2+1 $$ $$c=x+y+1 $$ $$d=x^2+xy+y^2$$ For any integers $x$ and $y$ Ex : for $x=2$ and $y=1$ you have $a=2-1=1$ and $b=2^2+2*1+1^2+1=8$ $c=2+1+1=4$ and $d=2^2+2*1+2^2=7$ And $1^2+8^2=7^2+4^2=65$ the smallest number that can be writing as sum of two squares in two different ways . Send message if you want know where this formula came from.

Siong Thye Goh
  • 149,520
  • 20
  • 88
  • 149
  • $50-5^2+5^2=7^2+1^2,$ so $65$ is not the smallest number for non-zero squares. But the question didn't say non-zero, and neither did you, so $3^2+4^2=5^2+0^2$ is the actual smallest. But the real problem with this answer is not that error at the end, but the fact there is no reasoning behind it. – Thomas Andrews Aug 08 '22 at 15:43