0
$\begingroup$

This question already has an answer here:

I was trying to plot a very simple polynomial function:

Plot[x^(2./3.),{x,-0.5,-0.2}]

Mathematica tells me that in this region, the result is always imaginary, but from fundamental math the result should be real. So why the difference?

To make the question clear: I know how to get the correct plot, but I want to understand why mathematica gives us imaginary result. How did mathematica do the calculation inside the kernal?

Thanks!

$\endgroup$

marked as duplicate by J. M. will be back soon Aug 30 '17 at 16:10

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Because (see the docs of Power, under Scope) "the principal root is always used. You can use CubeRoot[x^2] or Surd[x^2, 3]. $\endgroup$ – corey979 Aug 30 '17 at 15:13
  • $\begingroup$ Great, that answers my question. Thanks a lot. $\endgroup$ – Y.Du Aug 30 '17 at 15:20
  • 1
    $\begingroup$ As a terminological note: $x^\frac23$ is an algebraic function, but certainly not a polynomial. $\endgroup$ – J. M. will be back soon Aug 30 '17 at 16:11
1
$\begingroup$
Plot[CubeRoot[x]^2, {x, -0.5, -0.2}]

or

Plot[Surd[x, 3]^2, {x, -0.5, -0.2}]
$\endgroup$
  • $\begingroup$ Hi jiaoeyushushu, thanks for your reply. I actually know how to get the correct plot. But do you know why mathamatica gives us imaginary results? Thanks. $\endgroup$ – Y.Du Aug 30 '17 at 15:14
  • $\begingroup$ From the Documentation Center: Power[x,y] has a branch cut discontinuity for y running from -[Infinity] to 0 in the complex x plane for noninteger y. Because of this branch cut, Power[x,1/n] returns a complex root by default instead of the real one for negative real x and odd positive n. To obtain a real-valued n[Null]^th root, Surd[x,n] can be used. The special case CubeRoot[x] corresponds to Surd[x,3]. $\endgroup$ – John Doty Aug 30 '17 at 15:25
  • $\begingroup$ @JohnDoty Thank you John and also corey979, your answers solve my question. $\endgroup$ – Y.Du Aug 30 '17 at 15:38
0
$\begingroup$

Guide Mathematica to the desired result,

Table[(x^(2.))^(1/3.), {x, -0.5, -0.2, 0.1}]

{0.629961, 0.542884, 0.44814, 0.341995}

If you check the internal operation procedure you will see the difference,

FullForm[x^(2./3.)]

enter image description here

compare with this

FullForm[(x^(2.))^(1/3.)]

enter image description here

You can also try with exact form, i.e., 2/3.

$\endgroup$
  • $\begingroup$ Hi zhk, thanks. I know how to get the correct plot, but I want to understand why mathematica gives us imaginary results. Do you have any idea? $\endgroup$ – Y.Du Aug 30 '17 at 15:14
  • $\begingroup$ @Y.Du Check the edit $\endgroup$ – zhk Aug 30 '17 at 15:19

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