RE: Real numerical computations
- To: mathgroup at smc.vnet.net
- Subject: [mg71762] RE: [mg71701] Real numerical computations
- From: "Mark Harder" <harderm at onid.orst.edu>
- Date: Tue, 28 Nov 2006 06:04:16 -0500 (EST)
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. 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: [mg71701] 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 >