# Sums of squares question

If you have $a,b\in\mathbb{N}$ such that $a^2+b^2=M$, are there other natural numbers $c,d$ such that $c^2+d^2=M$? If so, is there an algorithm for generating such pairs or an equation relating them to $a$ and $b$? I tried messing around with a few ideas using $\mathbb{Z[i]}$, but didn't really get anywhere.

-
Yes - let $a=c,b=d$! :-) – Sanath K. Devalapurkar Apr 1 '14 at 23:19
If $M > 2$ is prime then $a$ and $b$ are unique. See this theorem of Fermat's and Thue's lemma. – Antonio Vargas Apr 1 '14 at 23:27

Let us consider the equation $$a^2+b^2=c^2+d^2\\ \implies a^2-c^2=d^2-b^2$$ See page 13 of here for a geometric interpretation.

Let $A+Bi=u,C+Di=v\in\mathbb{C}$. Then, you can show that $|u\overline{v}|=|uv|$. Square both sides and compute the norms to get $$(AC+BD)^2+(BC-AD)^2=(AC-BD)^2+(AD+BC)^2$$ Showing that for arbitrary $A,B,C,D$ we must have a bijection between the sets $$\{a,b,c,d\}\text{ and }\{AC+BD,BC-AD,AC-BD,AD+BC\}$$ Alternatively, you could factor $M$ as a product of Gaussian primes, allowing us to easily produce all representations of $M$ as a sum of two squares. Yet another way is to use Bramhagupta's identity ($(a^2+b^2)(c^2+d^2)=(ac+bd)^2+(ac-bd)^2$) repeatedly.

-

The others have nicely answered your question. But there is something else worth saying. According to a theorem of Jacobi, the number of solutions to $x^2+y^2=M$ in integers is equal to eight times the number of odd divisors of $M$ which are $1$ mod $4$ minus eight times the number of odd divisors of $M$ which are $3$ mod $4$. One recovers as a particular case Fermat's theorem on sums of two squares.

This theorem follows from the fact that the Dedekind zeta function of $\mathbf Q[i]$ equals $\zeta(s)L(\chi,s)$, where $\chi$ is the primitive quadratic character of conductor $4$.

(The reason for the factor $8$ is that solutions generally occur in "octopules": $(x,y),(y,x),(-x,y),(x,-y),...$).

-

There are definitely $a,b,c,d\in\mathbb{N}$ so $a^2+b^2=c^2+d^2=M$. Consider $2,9,6,$ and $7$. $2^2+9^2=85=6^2+7^2$. You can easily find these by looking for integer solutions for the level set $a^2+(a+x)^2-(c^2+(c+y)^2)=0$ where $x,y\in\mathbb{N}, x\neq y$. Then your $a,b$ and $c,d$ are $a,a+x$, and $c, c+y$

-