# Solving a second-order equation by imposing the constraint that the variables are real

I want to solve this equation

$$1 + x + x^2 + y - x y + y^2 = 0$$

under the constraint that both $$x$$ and $$y$$ are real (not complex). (Note that the unique solution is $$(x,y) = (-1, -1)$$.)

I first tested whether Mathematica could find an instance:

Assuming[{x,y}\[Element]Reals,
FindInstance[(1+x+x^2+y-x y+y^2)==0, {x,y}]]


but it gave this unacceptable "instance" in which $$x$$ is not real:

$$\left\{\left\{x\to \frac{1}{2} \left(-1-i \sqrt{3}\right),y\to 0\right\}\right\}$$

Why do we get a "solution" where $$x$$ is complex when we specified that $$x \in \mathbb{R}$$?

I also tried

Assuming[{x,y} \[Element] Reals,
Solve[(1+x+x^2+y-x y+y^2)==0,y, Reals]]


without success.

I can "manually" see that the original equation is symmetric in the interchange $$x \leftrightarrow y$$, and thus force the solution to be symmetric (by x == y) as:

Assuming[{x,y}\[Element]Reals,
FindInstance[(1+x+x^2+y-x y+y^2)==0 && x==y, {x,y}]]


This indeed gives the proper unique solution,

{{x -> -1, y -> -1}}


However this requires my (human) analysis.

Mathematica cannot even find $$x$$ such that the "solution" is real:

Solve[1/2 Im[x-Sqrt[3] Sqrt[-1-2 x-x^2]]==0,x]


{{}}

Is there any way to add constraints or other more general information that will enable Mathematica to find the unique solution to the original equation?

Try with Reduce[] command:

Reduce[(1 + x + x^2 + y - x y + y^2) == 0, {x, y}, Reals]
(*x == -1 && y == -1*)


Solve[] works too:

Solve[(1 + x + x^2 + y - x y + y^2) == 0, {x, y}, Reals]
(*x == -1 && y == -1*)


This also works:

Solve[1 + x + x^2 + y - x y + y^2 == 0 && Element[x | y, Integers], y]
(*{{y-> -1 if x==-1]}}*)


and this too:

Solve[1 + x + x^2 + y - x y + y^2 == 0 && Element[x | y, Rationals],y]
(*{{y-> -1 if x==-1]}}*)

• Oh jeez... so easy! Thanks. ($\checkmark$). But I'm still perplexed/confused why Solve cannot find this. Jul 2 at 5:41
• Solve does it easily if you search for {x,y} and not for only y. Solve[(1 + x + x^2 + y - x y + y^2) == 0, {x, y}, Reals]  Jul 2 at 5:51
• @Akku14: Yes. I now see that. But I wonder why Mathematica can't solve just for $y$. Jul 2 at 17:12