On Aug 5, 2004, at 9:21 AM, Josh wrote:
> I am having trouble plotting the following function:
>
> Plot[x^(1/3)*(x + 4), {x, -10, 10}]
>
> Mathematica won't plot this function for negative x, although it is
> obviously defined for negative x. It seems to be evaluating the
> negative part of this function to imaginary numbers for some odd
> reason.If I do:
>
> f[x_] := (x^(1/3))*(x + 4)
>
> and then:
>
> f[-5] // N
>
> I get:
>
> -0.854988 - 1.48088 \[ImaginaryI]
>
> when the correct answer is the negative cube root of negative 5, which
> is approximately - (-1.70998) = 1.70998
>
> I can send a copy of the notebook that shows where this is happening
> to anyone who requests it...
>
> Can anyone explain what is going on here? Is this a bug or am I
> missing something?
>
> Thanks in advance for any help ...
>
>
Josh,
This is actually typical behavior of software that do computations with
complex numbers. When x is negative, x^(1/3) returns the "principle"
cube root of x, which is Abs[x](Cos[Pi/3] + I Sin[Pi/3]). You can
verify this as follows:
In: ComplexExpand[ (Cos[Pi/3] + I Sin[Pi/3])^3 ]
Out: -1
Since you want to get the real cube root, you should use
Sign[x]Abs[x]^(1/3) in place of x^(1/3). You might want to use that to
define a function with a name analogous to Sqrt:
Cbrt[x_]:= Sign[x]Abs[x]^(1/3)
-----
Selwyn Hollis
http://www.appliedsymbols.com
(edit reply-to to reply)