This is not homework; but I am completely lost on how to go about handling this especially for large N
|
|
if you want integer solutions, then the primes of the form $4k+3$ dividing $N$ must occur to an even power. To see this you must show that i) the product of a sum of two squares is a sum of two squares ii) an odd prime $p$ is the sum of two squares iff $p\equiv1\mod 4$ i) $(a^2+b^2)(c^2+d^2)=(ac-bd)^2+(ad+bc)^2$ (think of the norms of complex numbers) |
|||||||||
|
|
Here are a few possible simplifications of the computational complexity which might help without having to explicitly write $N$ as a product of prime factors. If $N$ is even and $N = x^2 + y^2$ for integers $x$ and $y$, then $\frac{N}{2} = (\frac{x+y}{2})^2 + (\frac{x-y}{2})^2,$ and both these terms are integers, as $x$ and $y$ must have the same parity. On the other hand, if $M$ is an integer with $M = a^2 +b^2$ for integers $a$ and $b,$ then $2M = (a+b)^2 + (a-b)^2.$ Hence if $N$ is even, we can replace $N$ by $\frac{N}{2},$ and the answer to the question " is $N$ a sum of two integer squares" is unchanged, though computationlly easier. Now suppose that $N = LM$ for integers $L$ and $M$ with $1 < L < N.$ If ${\rm gcd}(L , M) = h >1,$ then $N$ is a sum of two integer squares if and only if $\frac{N}{h^2}$ is. If ${\rm gcd}(L,M) = 1,$ then $N$ is a sum of two integer squares if and $L$ and $M$ both are. |
|||
|
|
|
Me again. An algorithm, claimed to be efficient, for finding solutions can be found here. Also, a recent ArXiV paper claims (based on the abstract) to generalize H.J.S. Smith's algorithm for the same based on palindromes. |
||||
|
|
|
Ok, here's my attempt at this. The wikipedia page got better results though :(
|
|||||||||
|
