Solve $2(x+y)+xy=x^2+y^2$ where $x,y \in \mathbb{Z}$ Solve the equation: $$2(x+y)+xy=x^2+y^2$$
How should I go about solving this? Any guidance appreciated.
Thanks!
 A: $$8(x+y)=4(x^2-xy+y^2)\\8(x+y)=3(x-y)^2+(x+y)^2\\8z=3w^2+z^2\\16=3w^2+(z-4)^2$$
where $w=x-y$ and $z=x+y$
A: The given equation can be rewritten as
$$(x-2)^2+(y-2)^2+(x-y)^2=8$$
Now you want integer solutions. The left side is a sum of three integer squares, so there are only very few ways this can be accomplished. Each component has to be an integer between $-\sqrt{8}$ and $\sqrt{8}$.
Let me add further that: if we take $a=x-2$ and $b=y-2$, then we can rewrite the above equation as:
$$a^2+b^2+(a-b)^2=8.$$
This implies the only possibilities for $a$ and $b$ are in the set $\{0,\pm1,\pm2\}$. Now you can check which one of these will work and use that to get $x,y$.
A: Apply Cauchy-Schwarz inequality twice to both left and right sides of the equation:
$2(x+y) + \dfrac{(x+y)^2}{4} \geq LHS = RHS \geq \dfrac{(x+y)^2}{2} \Rightarrow 2(x+y) + \dfrac{(x+y)^2}{4} \geq \dfrac{(x+y)^2}{2} \Rightarrow 2(x+y) - \dfrac{(x+y)^2}{4} \geq 0 \Rightarrow (x+y)(8-(x+y)) \geq 0 \Rightarrow 8 \geq x+y \geq 0$. So there are a total of $9$ cases to consider. I will do a few ones and you do the rest.
Case 1: $x+y = 0 \Rightarrow x = -y \Rightarrow 2\cdot 0 + xy = x^2+y^2 \Rightarrow -x^2 = 2x^2 \Rightarrow 3x^2 = 0 \Rightarrow x = 0 = y$.
Case 2: $x+y = 1 \Rightarrow 2\cdot 1 + xy = (x+y)^2 - 2xy = 1 - 2xy \Rightarrow 3xy = -1 \Rightarrow$ no solution for this case.
etc...
A: $ 2(x+y) + xy = x^2 + y^2 $
$ 2(x+y) + 3xy = (x+y)^2 $
$ u = x + y, v = xy $
$ 2u + 3v = u^2 $
$ u^2 - 2u - 3v = 0 $
$ \frac{1}{2}u^2 - u - \frac{3}{2}v = 0 $
$ D = 1 + 3v $
$ u = 1 + \sqrt{1 + 3v} $ or $ u = 1 - \sqrt{1 + 3v} $
Let $ \sqrt{1+3v} = k $, hence $ v = \frac{k^2 - 1}{3} $
First case $ u = 1 + \sqrt{1+3v} $
$ x + y = 1 + k $
$ xy = \frac{k^2 - 1}{3} $
$ y = 1 + k - x $
$ 3x(1+k-x) = k^2 - 1 $
$ 3x + 3kx - 3x^2 = k^2 - 1 $
$ 3x^2 - 3(k+1)x + k^2 - 1 = 0 $
$ D = 9(k+1)^2 - 12 (k^2 - 1) = -3k^2 + 18k + 21 = -3(k^2 - 6k - 7) = -3(k+1)(k-7) $
$ -3(k+1)(k-7) >= 0 $, hence $ k \in [-1, 7] $ and $ k \in \mathbb N $
$x = \frac{3(k+1) \pm \sqrt{-3(k+1)(k-7)}}{6}$
Because of this $ k $ may be 1, 5 or 7 for $ \sqrt{-3(k+1)(k-7)} \in \mathbb Z $
$ k = 1 $, hence $ x = 2 $ and $ y = 0 $ OR $ x = 0 $ and $ y = 2 $
Similarly you can regard cases $ k = 5 $ and $ k = 7 $ AND $ u = 1 - \sqrt{1 + 3v} $.
In summary the answer will be $ (0, 0) $, $ (0, 2) $, $ (2, 0) $, $ (2, 4) $, $ (4, 2) $, $ (4, 4) $.
