1
$\begingroup$

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?

$\endgroup$
2
$\begingroup$

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]}}*)
$\endgroup$
3
  • $\begingroup$ Oh jeez... so easy! Thanks. ($\checkmark$). But I'm still perplexed/confused why Solve cannot find this. $\endgroup$ Jul 2 at 5:41
  • 1
    $\begingroup$ 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] $\endgroup$
    – Akku14
    Jul 2 at 5:51
  • $\begingroup$ @Akku14: Yes. I now see that. But I wonder why Mathematica can't solve just for $y$. $\endgroup$ Jul 2 at 17:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.