<s>[INST] 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!
 [/INST] 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...
</s>