[sage-devel] Re: Inconsistency in root finding

2007-03-21 Thread Robert Bradshaw
True. (There is a natural coercion into rings of lower precision, and in RDF (real double field = 53 bits of precision) they are equal.) On Mar 21, 2007, at 8:04 PM, Nick Alexander wrote: > Excellent, very good. I just have one change, noted below. The > output of "a == RDF(1)" is needed, be

[sage-devel] Re: Inconsistency in root finding

2007-03-21 Thread Nick Alexander
Excellent, very good. I just have one change, noted below. The output of "a == RDF(1)" is needed, because I don't know what is supposed to happen. Nick On Mar 21, 9:00 am, "William Stein" <[EMAIL PROTECTED]> wrote: > FYI, I've added the following discussion of hashing to the programming > guid

[sage-devel] Re: Inconsistency in root finding

2007-03-21 Thread William Stein
FYI, I've added the following discussion of hashing to the programming guide for the next version of SAGE: > \section{The {\tt \_\_hash\_\_} Special Method} > Here's the definition of \code{__hash__} > from the Python reference manual. > > \begin{quote} > Called for the key object for dictionar

[sage-devel] Re: Inconsistency in root finding

2007-03-21 Thread Robert Bradshaw
It should be noted that hashing should ideally be a very quick operation. Also, it's not possible to have x == y => hash(x) == hash (y) for a useful hash function. (For example, the equalities z == mod (z, 2) and z == mod(z, 3) would force hash() to be constant on the integers.) I think the

[sage-devel] Re: Inconsistency in root finding

2007-03-21 Thread Nick Alexander
So I've read this thread twice, and I can't understand what should happen next. Can someone sketch how algebraic extensions (say L/K/Q) should hash? I suggest: Q.__hash__ tries to __call__ to Z, and if that fails, hashes how it does now. K.__hash__ tries to __call__ to Q, and if that fails, ha

[sage-devel] Re: Inconsistency in root finding

2007-03-21 Thread Robert Bradshaw
On Mar 21, 2007, at 1:02 AM, Nick Alexander wrote: > Are RealField(100) and RealField(200) the same ring? To me, they > aren't, but there is a canonical coercion in one direction. And you > can expect __call__ to map between both. > > Is that right? > Nick No, they are not the same ring. Every

[sage-devel] Re: Inconsistency in root finding

2007-03-21 Thread Robert Bradshaw
On Mar 20, 2007, at 11:04 PM, David Harvey wrote: > On Mar 21, 2007, at 1:37 AM, Robert Bradshaw wrote: > >> One could also force all keys of a >> hashtable to live in a given ring. > > I don't think you'd want to do that. First, it wouldn't even solve > the problem (e.g. because of the precision

[sage-devel] Re: Inconsistency in root finding

2007-03-21 Thread Nick Alexander
On Mar 20, 11:04 pm, David Harvey <[EMAIL PROTECTED]> wrote: > On Mar 21, 2007, at 1:37 AM, Robert Bradshaw wrote: > > > One could also force all keys of a > > hashtable to live in a given ring. > > I don't think you'd want to do that. First, it wouldn't even solve > the problem (e.g. because of

[sage-devel] Re: Inconsistency in root finding

2007-03-20 Thread David Harvey
On Mar 21, 2007, at 1:37 AM, Robert Bradshaw wrote: > One could also force all keys of a > hashtable to live in a given ring. I don't think you'd want to do that. First, it wouldn't even solve the problem (e.g. because of the precision issues you raised before -- you can have two elements o

[sage-devel] Re: Inconsistency in root finding

2007-03-20 Thread David Harvey
On Mar 21, 2007, at 1:38 AM, William Stein wrote: > That said, we simply can't require > (*) "a == b ==> hash(a) == hash(b)" > in SAGE, because mathematics is simply too complicated for this sort > of rule. So what is done in SAGE is to _attempt_ to satisfy (*) > when it > is reasonably eas

[sage-devel] Re: Inconsistency in root finding

2007-03-20 Thread William Stein
On 3/20/07, David Harvey <[EMAIL PROTECTED]> wrote: > On Mar 21, 2007, at 1:19 AM, Nick Alexander wrote: > > On Mar 20, 4:12 pm, William Stein <[EMAIL PROTECTED]> wrote: > >> On Tuesday 20 March 2007 4:00 pm, Nick Alexander wrote: > >>> For some reason, google won't let me grab your patch. Anyway

[sage-devel] Re: Inconsistency in root finding

2007-03-20 Thread Robert Bradshaw
On Mar 20, 2007, at 10:27 PM, David Harvey wrote: > On Mar 21, 2007, at 1:19 AM, Nick Alexander wrote: > >> On Mar 20, 4:12 pm, William Stein <[EMAIL PROTECTED]> wrote: >>> On Tuesday 20 March 2007 4:00 pm, Nick Alexander wrote: >>> For some reason, google won't let me grab your patch. Anyw

[sage-devel] Re: Inconsistency in root finding

2007-03-20 Thread David Harvey
On Mar 21, 2007, at 1:19 AM, Nick Alexander wrote: > On Mar 20, 4:12 pm, William Stein <[EMAIL PROTECTED]> wrote: >> On Tuesday 20 March 2007 4:00 pm, Nick Alexander wrote: >> >>> For some reason, google won't let me grab your patch. Anyway, >>> converting to string is not a good idea. Better

[sage-devel] Re: Inconsistency in root finding

2007-03-20 Thread Nick Alexander
On Mar 20, 4:12 pm, William Stein <[EMAIL PROTECTED]> wrote: > On Tuesday 20 March 2007 4:00 pm, Nick Alexander wrote: > > > For some reason, google won't let me grab your patch. Anyway, > > converting to string is not a good idea. Better to hash a tuple of > > real, imag I think. (Maybe you

[sage-devel] Re: Inconsistency in root finding

2007-03-20 Thread William Stein
On Tuesday 20 March 2007 4:00 pm, Nick Alexander wrote: > For some reason, google won't let me grab your patch. Anyway, > converting to string is not a good idea. Better to hash a tuple of > real, imag I think. (Maybe you did this already?) You have to be really careful, since if a == b, then

[sage-devel] Re: Inconsistency in root finding

2007-03-20 Thread Nick Alexander
For some reason, google won't let me grab your patch. Anyway, converting to string is not a good idea. Better to hash a tuple of real, imag I think. (Maybe you did this already?) I don't seem able to send in a key function sorted; I'll try sort(cmp=) in a moment. I wonder if I hit a Pyrex bug

[sage-devel] Re: Inconsistency in root finding

2007-03-19 Thread William Stein
On 3/19/07, Mike Hansen <[EMAIL PROTECTED]> wrote: > > : unhashable type: > > 'sage.rings.complex_number.ComplexNumber' > > You should be able to just add the following to the ComplexNumber class: > > def __hash__(self): > return str(self).__hash__() > > That should work so long as the complex

[sage-devel] Re: Inconsistency in root finding

2007-03-19 Thread Mike Hansen
> While working on the patch, I came across another problem, one that I > don't want to fix. > > sage: D = {} ; D[CC(0)] = 1 > --- > Traceback (most recent call > last) > > /Users/nalexand/emacs/sage/ in () > > :

[sage-devel] Re: Inconsistency in root finding

2007-03-19 Thread Nick Alexander
While working on the patch, I came across another problem, one that I don't want to fix. sage: D = {} ; D[CC(0)] = 1 --- Traceback (most recent call last) /Users/nalexand/emacs/sage/ in () : unhashable type: 's

[sage-devel] Re: Inconsistency in root finding

2007-03-16 Thread William Stein
On 3/16/07, didier deshommes <[EMAIL PROTECTED]> wrote: > > On Mar 16, 2:23 pm, "Nick Alexander" <[EMAIL PROTECTED]> wrote: > > Do you agree that the current behaviour is brain-dead? 'cuz I'll > > patch it! Please send me a patch, so that it returns multiplicities in all cases. -- William -

[sage-devel] Re: Inconsistency in root finding

2007-03-16 Thread didier deshommes
On Mar 16, 2:23 pm, "Nick Alexander" <[EMAIL PROTECTED]> wrote: > Do you agree that the current behaviour is brain-dead? 'cuz I'll > patch it! Agreed! roots() should always return multiplicity when asked to. didier > > Nick --~--~-~--~~~---~--~~ To post to this

[sage-devel] Re: Inconsistency in root finding

2007-03-16 Thread Nick Alexander
On Mar 15, 11:53 pm, "didier deshommes" <[EMAIL PROTECTED]> wrote: > On Mar 16, 2:37 am, "didier deshommes" <[EMAIL PROTECTED]> wrote: > > > On Mar 16, 2:23 am, "Nick Alexander" <[EMAIL PROTECTED]> wrote: > > > > Is this because of precision issues? In that case, I still think this > > > should

[sage-devel] Re: Inconsistency in root finding

2007-03-15 Thread didier deshommes
On Mar 16, 2:37 am, "didier deshommes" <[EMAIL PROTECTED]> wrote: > On Mar 16, 2:23 am, "Nick Alexander" <[EMAIL PROTECTED]> wrote: > > > Is this because of precision issues? In that case, I still think this > > should return [(1...., 1), (1., 1)] and be documented as > > such. > >

[sage-devel] Re: Inconsistency in root finding

2007-03-15 Thread didier deshommes
On Mar 16, 2:23 am, "Nick Alexander" <[EMAIL PROTECTED]> wrote: > Is this because of precision issues? In that case, I still think this > should return [(1...., 1), (1., 1)] and be documented as > such. > > sage: (CC(1)*(x-1)**2).roots() > [1.00, 1.00] > > sag