[sage-support] Re: cube roots

2009-05-14 Thread John Cremona
This debate has been going on for as long as computers have been in existence. Yes, there is a case to be made the odd roots of negative reals should return a negative real instead of the principal complex root. But that leads to more subtle problems in other places. If all of mathematica,

[sage-support] Re: cube roots

2009-05-14 Thread Bill Page
On Thu, May 14, 2009 at 1:56 AM, Robert Bradshaw wrote: On May 13, 2009, at 9:11 PM, Bill Page wrote: On Wed, May 13, 2009 at 11:54 PM, Robert Bradshaw wrote: This is because the branch in which the positive real root is real is taken. We're opting for continuity and consistency with

[sage-support] Re: cube roots

2009-05-14 Thread Bill Page
On Thu, May 14, 2009 at 4:59 AM, John Cremona wrote: This debate has been going on for as long as computers have been in existence.  Yes, there is a case to be made the odd roots of negative reals should return a negative real instead of the principal complex root.  But that leads to more

[sage-support] Re: cube roots

2009-05-14 Thread Jason Grout
Bill Page wrote: On Thu, May 14, 2009 at 4:59 AM, John Cremona wrote: This debate has been going on for as long as computers have been in existence. Yes, there is a case to be made the odd roots of negative reals should return a negative real instead of the principal complex root. But that

[sage-support] Re: cube roots

2009-05-14 Thread Bill Page
On Thu, May 14, 2009 at 11:06 AM, Jason Grout wrote: Bill Page wrote: Consider the problem to define   f(x) = x^(1/3) so that it takes the real branch for x 0.  The best I have been able to come up with so far is: sage: f = lambda x:

[sage-support] Re: cube roots

2009-05-14 Thread Jason Grout
Bill Page wrote: On Thu, May 14, 2009 at 11:06 AM, Jason Grout wrote: Bill Page wrote: Consider the problem to define f(x) = x^(1/3) so that it takes the real branch for x 0. The best I have been able to come up with so far is: sage: f = lambda x:

[sage-support] Re: cube roots

2009-05-14 Thread Bill Page
On Thu, May 14, 2009 at 12:34 PM, Jason Grout wrote: Bill Page wrote: Ok thanks. I recall the discussion and I can indeed write: sage: f=lambda x:RR(x).nth_root(3) sage: f(-2.0) -1.25992104989487 but I think I'll let my earlier comment stand: I think there should be a more obvious way.

[sage-support] Re: cube roots

2009-05-14 Thread kcrisman
I like Jason's idea (specifically real_nth_root) as a method. However, to me the real issue is plotting. If someone tries to get a cube root of -1 and gets a complex number, at least they see there is an output! And then someone can help them understand why they get that answer. But there is

[sage-support] Re: cube roots

2009-05-13 Thread Mike Hansen
On Wed, May 13, 2009 at 6:58 PM, Bill Page bill.p...@newsynthesis.org wrote: Can someone explain this apparently inconsistent result? It's just operator precedence: sage: -(2.0^(1/3)) -1.25992104989487 sage: (-2.0)^(1/3) 0.629960524947437 + 1.09112363597172*I --Mike

[sage-support] Re: cube roots

2009-05-13 Thread Bill Page
On Wed, May 13, 2009 at 10:46 PM, Mike Hansen wrote: On Wed, May 13, 2009 at 6:58 PM, Bill Page wrote: Can someone explain this apparently inconsistent result? It's just operator precedence: sage: -(2.0^(1/3)) -1.25992104989487 sage: (-2.0)^(1/3) 0.629960524947437 + 1.09112363597172*I

[sage-support] Re: cube roots

2009-05-13 Thread Alex Ghitza
On Thu, May 14, 2009 at 1:19 PM, Bill Page bill.p...@newsynthesis.org wrote: On Wed, May 13, 2009 at 10:46 PM, Mike Hansen wrote: On Wed, May 13, 2009 at 6:58 PM, Bill Page wrote: Can someone explain this apparently inconsistent result? It's just operator precedence: sage: -(2.0^(1/3))

[sage-support] Re: cube roots

2009-05-13 Thread Bill Page
On Wed, May 13, 2009 at 11:23 PM, Alex Ghitza wrote: On Thu, May 14, 2009 at 1:19 PM, Bill Page wrote: On Wed, May 13, 2009 at 10:46 PM, Mike Hansen wrote: On Wed, May 13, 2009 at 6:58 PM, Bill Page wrote: Can someone explain this apparently inconsistent result? It's just operator

[sage-support] Re: cube roots

2009-05-13 Thread Robert Bradshaw
On May 13, 2009, at 8:49 PM, Bill Page wrote: On Wed, May 13, 2009 at 11:23 PM, Alex Ghitza wrote: On Thu, May 14, 2009 at 1:19 PM, Bill Page wrote: On Wed, May 13, 2009 at 10:46 PM, Mike Hansen wrote: On Wed, May 13, 2009 at 6:58 PM, Bill Page wrote: Can someone explain this apparently

[sage-support] Re: cube roots

2009-05-13 Thread Bill Page
On Wed, May 13, 2009 at 11:54 PM, Robert Bradshaw wrote: This is because the branch in which the positive real root is real is taken. We're opting for continuity and consistency with complex numbers. If I wrote: sage: ComplexField(53)(-2.0)^(1/3) 0.629960524947437 + 1.09112363597172*I that

[sage-support] Re: cube roots

2009-05-13 Thread Robert Bradshaw
On May 13, 2009, at 9:11 PM, Bill Page wrote: On Wed, May 13, 2009 at 11:54 PM, Robert Bradshaw wrote: This is because the branch in which the positive real root is real is taken. We're opting for continuity and consistency with complex numbers. If I wrote: sage: