       Re: Why is this so?

• To: mathgroup at smc.vnet.net
• Subject: [mg15310] Re: Why is this so?
• From: "Allan Hayes" <hay at haystack.demon.co.uk>
• Date: Fri, 8 Jan 1999 04:15:04 -0500
• References: <76pq9g\$e0n@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Chester Lin wrote in message <76pq9g\$e0n at smc.vnet.net>...
>The following in/out does not make sense to me:
>
>Clear[f, x]
>f[x_] := x^(1/3)
>Plot[f[x], {x, -125, 125}]
>
>Plot::plnr : f[x] is not a machine-size real number at x = -125..
>Plot::plnr : f[x] is not a machine-size real number at x = -114.858.
>Plot::plnr : f[x] is not a machine-size real number at x = -103.798.
>General::stop :
> Further output of Plot::plnr will be suppressed during this
>calculation.
>
>Isn't it true that (-125)^(1/3) == -5?
>
>Why do I get this strange result?
>
>I am using Mathematica 3.01 for Students on Macintosh.
>
>Thanks for any info.
>
>Chester Lin
>chester at nicco.sscnet.ucla.edu
>
>

Chester,

>Isn't it true that (-125)^(1/3) == -5?

Yes, provided that we are restricting to real numbers, but Mathemetica
normally works with complex  numbers, and with these we get

ComplexExpand[5*(-1)^(1/3)]

5/2 + (5*I*Sqrt)/2

(please look up complex numbers in some math text - this is the
Principal Value of 5*(-1)^(1/3)], the other values are  5/2 -
(5*I*Sqrt)/2 and -1)

All of these do the the job required of a cube root, for example

Expand[(5/2 + (5*I*Sqrt)/2)^3]

-125

and the full complex math lets us handle z^w for all complex z and w
(except z = 0)

For your immediate problem: Mathematica comes with a standard package
that helps keep things real:

(-125)^(1/3)

-5

and your plot will now come out as you expected

Clear[f, x]
f[x_] := x^(1/3)
Plot[f[x], {x, -125, 125}]

Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

```

• Prev by Date: How to save a file in package (*.m) format
• Next by Date: Baby mathlink question.
• Previous by thread: Re: Why is this so?
• Next by thread: Re: Why is this so?