In general, a typical root of a negative number is complex, so you need to get rid of most roots. A nice approach would be Root
, e.g.
Root[ x^3 + 8, #] & /@ Range[3]
{-2, 1 - I Sqrt[3], 1 + I Sqrt[3]}
To get only real roots you can do :
Select[Root[ x^3 + 8, #] & /@ Range[3], Re[#] == # &]
{-2}
This is a handy approach when you have roots of lower orders.
However you'd rather use Reduce
or Solve
for higher order roots, in this case it works like this :
Reduce[ x^3 + 8 == 0, x]
x == -2 || x == 1 - I Sqrt[3] || x == 1 + I Sqrt[3]
Solve[ x^3 + 8 == 0, x]
{{x -> -2}, {x -> 2 (-1)^(1/3)}, {x -> -2 (-1)^(2/3)}}
To get only real roots one can use for example : Reduce[x^3 + 8 == 0, x, Reals]
or Solve[x^3 + 8 == 0, x, Reals]
. They do almost the same, but their outputs are a bit different, respectively : in the boolean form and in the form of rules.
As a more appropriate example of what you want to do I could choose this one : (-3)^(1/7)
. Mathematica treats variables (in general) as complex. So one gets seven roots
and there is the only one real.
Solve[ x^7 + 3 == 0, x, Reals]
{{x -> -3^(1/7)}}
To get the full output one can do this :
points = {Re @ #, Im @ #} & /@ Last @@@ Solve[x^7 + 3 == 0, x]

Absolute values of the roots are the same, so they are found on the circle of a given radius (== 3^(1/7)
) :
{ Equal @@ #, radius = #[[1]] } & @ Simplify @ (Norm /@ points)
{True, 3^(1/7)}
To visualize the structure of the output one makes use of ContourPlot
of real and imaginary parts of the function (x + I y)^7 + 3
(we write the function explicitly in the complex form since we make plots in real domains of x
and y
) :
GraphicsRow[{
ContourPlot[ Re[(x + I y)^7 + 3], {x, -2, 2}, {y, -2, 2}, PlotPoints -> 25, MaxRecursion -> 5,
Epilog -> {Darker@Green, Thick, Line[{{0, 0}, #}] & /@ points,
Gray, Dashed, Circle[{0, 0}, radius], PointSize[0.02], Blue, Point[points]}],
ContourPlot[ Im[(x + I y)^7 + 3], {x, -2, 2}, {y, -2, 2}, PlotPoints -> 25, MaxRecursion -> 5,
Epilog -> {Darker@Green, Thick, Line[{{0, 0}, #}] & /@ points,
Gray, Dashed, Circle[{0, 0}, radius], PointSize[0.02], Blue, Point[points]}]}]

Clarification
- The blue points --- roots
- lengths of the green lines --- absolute values of the roots
- the dashed circle --- a set of all complex numbers
z
such that Abs[z] == radius
The only one real root lies on the line y == 0
.
In[99] := NumericalMath`CubeRoot[-8] Out[99] = -2
$\endgroup$