2

From Lagranges'celebrated four-squares theorem we know that any number is the sum of four squares ( not necessarily nonzero and distinct). But it's an existence theorem and gives no idea of how to generate this expression. In a similar vein, one of Fermat's theorem states that a prime of form 4k + 1 is the sum of two squares. But how do we go about finding the pair of squares ? On a more general scale, given some number N expressible as a sum of two squares a^2 + b^2, what is the method for computing pair(s) (a, b) ?

  • (see also http://math.stackexchange.com/q/366673) – Zev Chonoles May 26 '15 at 05:51
  • There are good algorithms for representing primes. Names to look for are Hermite, Serret, and (in the computer age) Brillhart. – André Nicolas May 26 '15 at 06:09
  • For a number $n$ which is a product of two large primes of the form $4k+1$, if we can find two really different representations, then we can efficiently factor $n$. Since the factorization problem appears to be computationally difficult, the general two squares problem may also be. – André Nicolas May 26 '15 at 06:16
  • The posts so far mentioned as possible duplicates do not deal with the algorithmic part of the question. – André Nicolas May 26 '15 at 06:27
  • Lagrange's proof might not lead to a computationally efficient algorithm, but it is completely constructive, I believe. (Then again, so is brute force....) – Greg Martin May 26 '15 at 06:50

0 Answers0