# How can I reduce my work to get the result automatically?

I want to find the locus of point present of the complex z so that $$|z + 2| + |z - 2| = 18.$$ I tried by hand

ComplexExpand[Abs[z + 2] == 18 - Abs[z - 2] /. z :> (x + y I)];
Simplify[#^2 & /@ %]
Expand[Simplify[(9 Sqrt[4 - 4 x + x^2 + y^2])^2 - (81 - 2 x)^2]]
Simplify[1/6237 (-6237 + 77 x^2 + 81 y^2)]


-1 + x^2/81 + y^2/77

How can I reduce my work to get the result automatically?

GroebnerBasis[] does the job:

First[GroebnerBasis[ComplexExpand[Abs[z + 2] + Abs[z - 2] == 18 /. z :> (x + I y)], {x, y}]]
-6237 + 77 x^2 + 81 y^2

ContourPlot[% == 0, {x, -9, 9}, {y, -9, 9}, AspectRatio -> Automatic]


• Is it always the first element? I admit I don't understand the documentation on GroebnerBasis very well: "The Gröbner basis in general depends on the ordering assigned to monomials. This ordering is affected by the ordering of the $x_i$." And then there's the MonomialOrder option too. How to tell which one to pick? Mar 12, 2019 at 9:01
• @Roman, often it is, but sometimes you have to look for the "rationalized" expression in the list returned by GroebnerBasis[]. The reason for someone wanting to set MonomialOrder is that both the efficiency of the method and the simplicity of the results (that is, the basis) can depend on the choice of order in eliminating the variables. Mar 12, 2019 at 9:18

In general, you can use Solve:

Solve[ComplexExpand[Abs[z + 2] + Abs[z - 2] == 18 /. z -> x + I y], y]


$$\left\{\left\{y\to -\frac{1}{9} \sqrt{77} \sqrt{81-x^2}\right\},\left\{y\to \frac{1}{9}\sqrt{77} \sqrt{81-x^2}\right\}\right\}$$

Then you can for example do

DeleteDuplicates[y^2 /. %]


{77/81 (81 - x^2)}

to find something close to your result.

Reduce[Abs[z + 2] + Abs[z - 2] == 18, z]


-9 <= Re[z] <= 9 && (Im[z] == -(1/9) Sqrt[6237 - 77 Re[z]^2] || Im[z] == 1/9 Sqrt[6237 - 77 Re[z]^2])