4
$\begingroup$

Possible Duplicate:
Finding real roots of negative numbers (for example, $\sqrt\[3\]{-8}$)

Yes, I know there are other Threads which have similar questions and yes I read them but I am just not able to solve the problem. Please help me I am totally at the limit with this :(

How do I plot a cubic root in Mathematica, where also the negative graph is shown? cubic root in plot without negative graph

NOTE: Threads I have found and not understood

How to plot imaginary part of a function

Finding real roots of negative numbers (for example, $\sqrt[3]{-8}$)

Plotting Complex Quantity Functions

$\endgroup$
2
  • $\begingroup$ The second question you linked to would definitely be a duplicate. Why not explain what you did not understand about any of those threads? Something you specifically had trouble with, perhaps? $\endgroup$ Sep 28, 2012 at 17:02
  • 1
    $\begingroup$ Using one of the linked questions, one might be inspired to try Plot[Root[#^3 - x &, 1], {x, -2, 2}], which works. $\endgroup$
    – whuber
    Sep 28, 2012 at 17:04

1 Answer 1

10
$\begingroup$

The simplest solution to this type of problem is usually to use a function like Solve or NSolve to generate solutions to an equation, which can then be plotted.

In this case, I would do the following:

Plot[p /. NSolve[p^3 == x, p, Reals], {x, -10, 10}]

a plot of the cube root

All I am doing is plotting p such that p is a solution to p^3 == x. NSolve allows me to force the result to be a real number.

This is a (very) minor variation on the techniques mentioned in solutions that you link in your question.

I recommend that you read this link for more information on why Mathematica does what it does. Essentially, real numbers have unique cube roots, but (non-zero) complex numbers have 3 distinct roots. Mathematica assumes that all symbols are complex, so it has a choice about which of the 3 roots it could return. For reasons explained in the link, Mathematica chooses the complex root with a positive imaginary part.


Addendum by J. M.

In version 9, one now has the new functions CubeRoot[], which returns real-valued cube roots of real numbers (and does not evaluate for complex arguments), and the more general Surd[]. See the documentation for details.

$\endgroup$
0

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