Re: Real numerical computations

*To*: mathgroup at smc.vnet.net*Subject*: [mg71812] [mg71797] Re: Real numerical computations*From*: "David W. Cantrell" <DWCantrell at sigmaxi.net>*Date*: Thu, 30 Nov 2006 06:05:02 -0500 (EST)*References*: <ekh78f$sa9$1@smc.vnet.net>

"Mark Harder" <harderm at onid.orst.edu> wrote: > Jose, > There are 3 cube roots of unity, all of which can be found using > the Root[] function (look it up). Same thing goes for cube roots of -1. > Run the following: > > Thread[Root[#^3 - 1 &, {1, 2, 3} ] ] > > And > > Thread[Root[#^3 + 1 &, {1, 2, 3} ] ] > > The first gives the cube roots of 1 (i.e. x^3 - 1 ==0). The second gives > the cube roots of -1, so you need only do Root[#^3+1&,1] to get the real > root. > Also, if you use exact math -- (-1)^(1/3) -- you will get the real > root. No, you don't. You get the principal root. FWIW, if you're wanting to work with just real cube roots of reals, rather than bothering to load a package like RealOnly, you could simply define your own function: RealCbrt[x_]:= Sign[x]*Abs[x]^(1/3) David W. Cantrell > Maybe someone else understands why the finite precision math > returns only a complex root, and a rather inaccurate one at that -- try > raising the answer you got (using default precision) to the 3rd power to > see how inaccurate. Play around with extra precision in your expressions > to see how to make this better. > > Mark Harder > > > -----Original Message----- > > From: José Carlos Santos [mailto:jcsantos at fc.up.pt] > > Sent: Monday, November 27, 2006 1:04 AM > > To: mathgroup at smc.vnet.net > > Subject: Real numerical computations > > > > Hi all, > > > > With Mathematica, if I type > > > > N[(-1.)^(1/3)] > > > > I get > > > > 0.5 + 0.866025 i > > > > This is correct, of course, but I would like to get -1. instead. How do > > I tell Mathematica that I want a real result (if there is one)? > > > > Best regards, > > > > Jose Carlos Santos > >