1

Is there a general method for expressing $x^2 - 2y^2$ as a sum of 2 squares when we know for some reason that it must be possible?

I was solving a problem for which once you get to the end, you're asked to express the answer as a sum of 2 squares. I got to $169^2 - 2 \cdot 80^2$ and couldn't continue. Instead, I expanded it to $p = 15761,$ found that $p$ is prime, and used the usual quadratic residue algorithm to express $p$ as a sum of squares.

With the answer in mind, we can use the power of hindsight bias to notice that $169^2 - 120^2$ is a perfect square. This leads to the general observation that if $y$ is even and $x^2 - (3y/2)^2 = z^2,$ then $x^2 - 2y^2 = z^2 + (y/2)^2.$

But what if we don't have hindsight bias and $x, y$ are much larger? Is there a general method for spotting what to subtract and add so that we get a sum of squares?

Display name
  • 5,310
  • Do you only want to find the squares or factorize the nuumber $x^2-2y^2$ ? – Peter Jun 24 '24 at 12:17
  • @Peter, I don't think OP wants to factor $x^2-2y^2$ in the usual sense of the word, which is to express it as a product (in a non-trivial way). Instead, I think OP wants to partition $x^2-2y^2$. Of course, this is very easy to do in a bunch of ways, hence the requirement "as a sum of two squares" to make the problem interesting. – Ennar Jun 24 '24 at 12:30
  • @Peter The squares. I don't think I even used the word factor except for a single typo which I just fixed – Display name Jun 24 '24 at 12:37
  • 1
    You wrote Is there a general method for factorizing $x^2-2y^2$ (see the edit history). I think this is why Peter made his comment. And yes, there is a way to find integer solutions to $x^2-2y^2=z^2+w^2$, using Pell's equation and Fermat's result on the sum of two squares. – Dietrich Burde Jun 24 '24 at 12:52
  • According to OEIS sequence A155562, nonnegative integer $N$ can be expressed as both $x^2 + y^2$ and $z^2 - 2 w^2$ iff there exist nonnegative integers $p,q,r,s$ such that $$ \eqalign{N &= (p^2-q^2-2 r s)^2+(r^2-s^2-2 p q)^2 \cr &= (p^2+q^2+r^2+s^2)^2-2 (p r+p s+q r-q s)^2}$$ – Robert Israel Jun 24 '24 at 14:15
  • @DietrichBurde That's the typo which I fixed. Nowhere else did I use the word – Display name Jun 26 '24 at 02:00
  • Right, but Peter made the comment immediately, reading your typo. – Dietrich Burde Jun 26 '24 at 11:10

1 Answers1

1

It is not true that $x^2-2y^2$ is always a sum of two squares. Consider $$ 3^2-2\cdot 1^2=7, $$ which is not the sum of two squares.

On the other hand, we can consider integer solutions to the Diophantine equation $$ x^2-2y^2=z^2+w^2. $$ For the RHS and LHS we know which integers are the sum of two squares, respectively of the form $x^2-2y^2$, see here, for example:

Is there any variation known to the sum of two squares theorem?

Dietrich Burde
  • 140,055