# If $x^2+y^2-xy-x-y+1=0$ ($x,y$ real) then calculate $x+y$

If $x^2+y^2-xy-x-y+1=0$ ($x,y$ real) then calculate $x+y$

Ideas for solution include factorizing the expression into a multiple of $x+y$ and expressing the left hand side as a sum of some perfect square expressions.

• If it is required that $(x,y) \in \mathbb{R}^2$, then you should add this requirement to your post. – miracle173 Feb 16 '16 at 21:33

Let $s=x+y$ and $d=x-y$. Then $x=(s+d)/2$ and $y=(s-d)/2$. Making this substitution, we find that $$x^2+y^2-xy-x-y+1=\frac{3d^2}{4}+\frac{(s-2)^2}{4}.$$

Hence, being a sum of squares, if the original expression is zero, $d=0$ and $s-2=0$. This means that $s=x+y=2$, with $x=y$.

We have $$2(x^2+y^2-xy-x-y+1)=(x-y)^2+(x-1)^2+(y-1)^2.$$ The right-hand side (for real $x$ and $y$) is equal to $0$ if and only if $x=y=1$.

I'll assume $x$ and $y$ are supposed to be real.

Let $s=x+y$ and $p=xy$; then your equation becomes $$s^2-2p-p-s+1=0$$ or $$p=\frac{s^2-s+1}{3}$$ The equation $$z^2-sz+p=0$$ must have real roots; its discriminant is $$s^2-4p=-\frac{(s-2)^2}{3}\le0$$ so we have $s=2$ (and $p=1$).

• What does z stand for? – Hamid Reza Ebrahimi Feb 19 '16 at 15:57
• @HamidRezaEbrahimi Any variable; the roots of the equation are precisely two numbers whose sum is $s$ and product is $p$. – egreg Feb 19 '16 at 16:01

The value of $x+y$ is not determined by the first equation. For $x=0$ we obtain $y^2-y+1=0$, so that $x+y=\frac{\pm \sqrt{-3}+1}{2}$. This is certainly not equal to $2$.

• For $x=0$ there's no real value for $y$ – Hamid Reza Ebrahimi Feb 16 '16 at 21:04
• Doe it say somewhere that $y$ need to be real ? – Dietrich Burde Feb 16 '16 at 21:20
• In your opinion,what's wrong with the above two Correct answers? – Hamid Reza Ebrahimi Feb 16 '16 at 21:22
• They only hold for real numbers. But Andre is saying this explicitly, so the answers are not wrong. You could just add "for real $x,y$". – Dietrich Burde Feb 16 '16 at 21:23