10

Is there a general method to expressing integers as the sum of two squares or do you just need to be good with numbers? For example, consider the following problem:

Express 605 as the sum of two squares

Now I believe that a solution to this problem exists because $605 = 5 \cdot 11^2$ and $11 \equiv 3 \pmod 4$ which appears an even number of times and $11$ is the only number in the prime factorization that is congruent to $3 \pmod 4$.

So looking at this problem, what are the first steps that you should take to try and solve this problem? Is there a quick way to go about this?

not all wrong
  • 16,568
  • 2
  • 37
  • 58
Benzne_O
  • 857

1 Answers1

6

I'm not an expert, but from memory something which it turns out is called the Brahmagupta–Fibonacci identity or occasionally Diophantus identity (used constructively in the proof of the result of Fermat) might be useful: see Wikipedia.

$$\left(a^2 + b^2\right)\left(c^2 + d^2\right) = \left(ac-bd\right)^2 + \left(ad+bc\right)^2 = \left(ac+bd\right)^2 + \left(ad-bc\right)^2$$

This allows you to strip off factors one at a time.

Where you have squares in the factorization, as in the $5\cdot 11^2$ case, note that the square can be factored out as $(p^2+q^2)m^2 = (pm)^2 + (qm)^2$

not all wrong
  • 16,568
  • 2
  • 37
  • 58
  • For a natural number $n$ and a prime number $p$ let $\deg_p n$ be a maximal integer number $l$ such that $p^l|n$. Then I suppose that there is an expression of $n$ as a sum of two squares (which is obtainable by the above method) iff $\deg_p$ is even for each prime $p$ of the form $4k+1$. – Alex Ravsky Apr 19 '13 at 13:37
  • I think you can restrict the number of things you have to try but this amounts to experimentation. (Judging by the proofs at http://en.m.wikipedia.org/wiki/Proofs_of_Fermat's_theorem_on_sums_of_two_squares ) I'll leave it to others to translate these into algorithms, but finding (10,9) in this case I would do by inspection. – not all wrong Apr 19 '13 at 14:00
  • 1
    @Alex Your last sentence should be $4k+3$. – Calvin Lin Apr 19 '13 at 14:26
  • Yes, it was a mispint. Thanks. – Alex Ravsky Apr 19 '13 at 14:59