[sage-devel] Re: making a reset() makes it impossible to "quit"

2017-03-29 Thread Aidan
My bad, I misread what John meant. 
I thought he was asking whether what should be preserved under reset was 
defined by IPython, or sage. He was asking about the commands themselves 
though.

On Wednesday, March 29, 2017 at 11:01:50 AM UTC-7, Aidan wrote:
>
>
> It looks like they are a mix of IPython and Sage.
>
> From sage.misc.reset:
>
> # Exclude these from the reset command.
> # DATA, base64 -- needed by the notebook
> EXCLUDE = set(['sage_mode', '__DIR__', 'DIR', 'DATA', 'base64'])
>
>
> I may be completely wrong, but that's my guess.
>
>
>
> On Wednesday, March 29, 2017 at 10:48:57 AM UTC-7, John H Palmieri wrote:
>>
>> It looks like a bug to me.
>>
>> ┌┐
>> │ SageMath version 7.6, Release Date: 2017-03-25 │
>> │ Type "notebook()" for the browser-based notebook interface.│
>>   Type "help()" for help.│
>> └┘
>> sage: show_identifiers()
>> ['Out', 'get_ipython', 'In', 'exit', 'quit']
>> sage: reset()
>> sage: show_identifiers()
>> []
>>
>> I think that exit, quit, possibly get_ipython, Out, and In, should be 
>> preserved under 'reset'. Are all of these defined by IPython, or are some 
>> Sage-specific?
>>
>> -- 
>> John
>>
>>
>> On Wednesday, March 29, 2017 at 8:49:38 AM UTC-7, jplab wrote:
>>>
>>> Hi,
>>>
>>> Is the following normal:
>>>
>>> sage: a=2; a
>>> 2
>>> sage: reset()
>>> sage: a
>>> Traceback (most recent call last):
>>> ...
>>> NameError: name 'a' is not defined
>>> sage: quit
>>> Traceback (most recent call last):
>>> ...
>>> NameError: name 'quit' is not defined
>>>
>>>
>>> See the question on AskSage:
>>>
>>>
>>> https://ask.sagemath.org/question/9643/clearing-all-user-defined-variables-from-current-session/
>>>
>>> It not really practical then...
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: making a reset() makes it impossible to "quit"

2017-03-29 Thread Aidan

It looks like they are a mix of IPython and Sage.

>From sage.misc.reset:

# Exclude these from the reset command.
# DATA, base64 -- needed by the notebook
EXCLUDE = set(['sage_mode', '__DIR__', 'DIR', 'DATA', 'base64'])


I may be completely wrong, but that's my guess.



On Wednesday, March 29, 2017 at 10:48:57 AM UTC-7, John H Palmieri wrote:
>
> It looks like a bug to me.
>
> ┌┐
> │ SageMath version 7.6, Release Date: 2017-03-25 │
> │ Type "notebook()" for the browser-based notebook interface.│
>   Type "help()" for help.│
> └┘
> sage: show_identifiers()
> ['Out', 'get_ipython', 'In', 'exit', 'quit']
> sage: reset()
> sage: show_identifiers()
> []
>
> I think that exit, quit, possibly get_ipython, Out, and In, should be 
> preserved under 'reset'. Are all of these defined by IPython, or are some 
> Sage-specific?
>
> -- 
> John
>
>
> On Wednesday, March 29, 2017 at 8:49:38 AM UTC-7, jplab wrote:
>>
>> Hi,
>>
>> Is the following normal:
>>
>> sage: a=2; a
>> 2
>> sage: reset()
>> sage: a
>> Traceback (most recent call last):
>> ...
>> NameError: name 'a' is not defined
>> sage: quit
>> Traceback (most recent call last):
>> ...
>> NameError: name 'quit' is not defined
>>
>>
>> See the question on AskSage:
>>
>>
>> https://ask.sagemath.org/question/9643/clearing-all-user-defined-variables-from-current-session/
>>
>> It not really practical then...
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] Re: making a reset() makes it impossible to "quit"

2017-03-29 Thread William Stein
On Wed, Mar 29, 2017 at 10:48 AM, John H Palmieri
 wrote:
> It looks like a bug to me.
>
> ┌┐
> │ SageMath version 7.6, Release Date: 2017-03-25 │
> │ Type "notebook()" for the browser-based notebook interface.│
>   Type "help()" for help.│
> └┘
> sage: show_identifiers()
> ['Out', 'get_ipython', 'In', 'exit', 'quit']
> sage: reset()
> sage: show_identifiers()
> []
>
> I think that exit, quit, possibly get_ipython, Out, and In, should be
> preserved under 'reset'. Are all of these defined by IPython, or are some
> Sage-specific?

I think they used to be some special thing handled by the sage
preparser -- it was one of the first things I added, since I found
IPython too hard to exit from (compared to Magma).  However, they are
now implemented in a nice way inside IPython:

sage: quit??
Type:   ExitAutocall
String form:
File:
/projects/sage/sage-7.5/local/lib/python2.7/site-packages/IPython/core/autocall.py
Signature:  quit(self)
Source:
class ExitAutocall(IPyAutocall):
"""An autocallable object which will be added to the user namespace so that
exit, exit(), quit or quit() are all valid ways to close the shell."""
rewrite = False

def __call__(self):
self._ip.ask_exit()
Call signature: quit()

>
> --
> John
>
>
>
> On Wednesday, March 29, 2017 at 8:49:38 AM UTC-7, jplab wrote:
>>
>> Hi,
>>
>> Is the following normal:
>>
>> sage: a=2; a
>> 2
>> sage: reset()
>> sage: a
>> Traceback (most recent call last):
>> ...
>> NameError: name 'a' is not defined
>> sage: quit
>> Traceback (most recent call last):
>> ...
>> NameError: name 'quit' is not defined
>>
>>
>> See the question on AskSage:
>>
>>
>> https://ask.sagemath.org/question/9643/clearing-all-user-defined-variables-from-current-session/
>>
>> It not really practical then...
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.



-- 
William (http://wstein.org)

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] Re: making a reset() makes it impossible to "quit"

2017-03-29 Thread John H Palmieri
It looks like a bug to me.

┌┐
│ SageMath version 7.6, Release Date: 2017-03-25 │
│ Type "notebook()" for the browser-based notebook interface.│
  Type "help()" for help.│
└┘
sage: show_identifiers()
['Out', 'get_ipython', 'In', 'exit', 'quit']
sage: reset()
sage: show_identifiers()
[]

I think that exit, quit, possibly get_ipython, Out, and In, should be 
preserved under 'reset'. Are all of these defined by IPython, or are some 
Sage-specific?

-- 
John


On Wednesday, March 29, 2017 at 8:49:38 AM UTC-7, jplab wrote:
>
> Hi,
>
> Is the following normal:
>
> sage: a=2; a
> 2
> sage: reset()
> sage: a
> Traceback (most recent call last):
> ...
> NameError: name 'a' is not defined
> sage: quit
> Traceback (most recent call last):
> ...
> NameError: name 'quit' is not defined
>
>
> See the question on AskSage:
>
>
> https://ask.sagemath.org/question/9643/clearing-all-user-defined-variables-from-current-session/
>
> It not really practical then...
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] algdep (PARI) with clang on FreeBSD

2017-03-29 Thread Thierry
Hi,

On Wed, Mar 29, 2017 at 08:00:14AM -0700, Dima Pasechnik wrote:
> 
> 
> On Wednesday, March 29, 2017 at 2:23:14 PM UTC+1, Jeroen Demeyer wrote:
> >
> > On 2017-03-29 11:24, Dima Pasechnik wrote: 
> > > Is the following a bug, or  not: 
> >
> > A bug in what :-) 
> >
> 
> in pari (why don't they chop off a factor of x^j, it costs next to nothing) 
> (or Sage can do this, too)
> 
> 
> > This is already interesting (on Linux): 
> >
> > sage: float(RR(3).sqrt()) 
> > 1.7320508075688772 
> > sage: float(RDF(3).sqrt()) 
> > 1.7320508075688772 
> > sage: float(RR(sqrt(3))) 
> > 1.7320508075688772 
> > sage: float(RDF(sqrt(3))) 
> > 1.7320508075688774 

Note that the difference exists already in the representation of the
numbers (no relation with conversion into floats):

sage: RR(3).sqrt().sign_mantissa_exponent()
(1, 7800463371553962, -52)
sage: RDF(3).sqrt().sign_mantissa_exponent()
(1, 7800463371553962, -52)
sage: RR(sqrt(3)).sign_mantissa_exponent()
(1, 7800463371553962, -52)
sage: RDF(sqrt(3)).sign_mantissa_exponent()
(1, 7800463371553963, -52)

I do not remember where i read that (correct me if i am wrong, or provide
a reference if you know where it is), but RDF is supposed to round towards
the nearest floating-point number. However:

sage: a2 = 7800463371553962*2^-52
sage: a3 = 7800463371553963*2^-52
sage: R = RealIntervalField(1000)
sage: R(a2 -sqrt(3)).endpoints()
(-1.00350842218069026527919215165919755628055806979451933016908800037081146186757248575675626141415406703029969945094998952478811655512094373648528093231902305582067974820101084674923265015312343266903322886650672254668921837971227047131660367861588019049986537379859389467650347506576050819683258448262e-16,
 
-1.00350842218069026527919215165919755628055806979451933016908800037081146186757248575675626141415406703029969945094998952478811655512094373648528093231902305582067974820101084674923265015312343266903322886650672254668921837971227047131660367861588019049986537379859389467650347506576050446377811046973e-16)

sage: R(a3 -sqrt(3)).endpoints()
(1.21693762706962281556807118452244306871944193020548066983091199962918853813242751424324373858584593296970030054905001047521188344487905626351471906768097694417932025179898915325076734984687656733096677113349327745331078162028772952868339632138411980950013462620140610532349652493423949180316741551738e-16,
 
1.21693762706962281556807118452244306871944193020548066983091199962918853813242751424324373858584593296970030054905001047521188344487905626351471906768097694417932025179898915325076734984687656733096677113349327745331078162028772952868339632138411980950013462620140610532349652493423949553622188953027e-16)

I would vote for having conversions to round the same way than operations.
Realfield seems to take care of rounding modes when converting from SR:

sage: R = RealField(53,rnd='RNDZ')
sage: R(sqrt(3)).sign_mantissa_exponent()
(1, 7800463371553962, -52)
sage: R = RealField(53,rnd='RNDN')
sage: R(sqrt(3)).sign_mantissa_exponent()
(1, 7800463371553962, -52)
sage: R = RealField(53,rnd='RNDD')
sage: R(sqrt(3)).sign_mantissa_exponent()
(1, 7800463371553962, -52)

sage: R = RealField(53,rnd='RNDU')
sage: R(sqrt(3)).sign_mantissa_exponent()
(1, 7800463371553963, -52)
sage: R = RealField(53,rnd='RNDA')
sage: R(sqrt(3)).sign_mantissa_exponent()
(1, 7800463371553963, -52)

Where is the conversion from SR to RDF defined ?

Ciao,
Thierry



> > The last one is actually more wrong (error: 0.55 ulp) than the first 
> > three (error: 0.45 ulp). Interestingly, it is precisely this wrong 
> > answer which is used in the doctest. 
> >
> > I think it's fair to say that the doctest isn't robust. 
> >
> 
> Actually, on FreeBSD I get 
> sage: float(RDF(sqrt(3)))
> 1.7320508075688772
> 
> Do you mean to say that Linux's (g)libm is not as good? :-)
>   
>  
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-devel+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-devel@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-devel.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] making a reset() makes it impossible to "quit"

2017-03-29 Thread jplab
Hi,

Is the following normal:

sage: a=2; a
2
sage: reset()
sage: a
Traceback (most recent call last):
...
NameError: name 'a' is not defined
sage: quit
Traceback (most recent call last):
...
NameError: name 'quit' is not defined


See the question on AskSage:

https://ask.sagemath.org/question/9643/clearing-all-user-defined-variables-from-current-session/

It not really practical then...

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] algdep (PARI) with clang on FreeBSD

2017-03-29 Thread Dima Pasechnik


On Wednesday, March 29, 2017 at 2:23:14 PM UTC+1, Jeroen Demeyer wrote:
>
> On 2017-03-29 11:24, Dima Pasechnik wrote: 
> > Is the following a bug, or  not: 
>
> A bug in what :-) 
>

in pari (why don't they chop off a factor of x^j, it costs next to nothing) 
(or Sage can do this, too)


> This is already interesting (on Linux): 
>
> sage: float(RR(3).sqrt()) 
> 1.7320508075688772 
> sage: float(RDF(3).sqrt()) 
> 1.7320508075688772 
> sage: float(RR(sqrt(3))) 
> 1.7320508075688772 
> sage: float(RDF(sqrt(3))) 
> 1.7320508075688774 
>
> The last one is actually more wrong (error: 0.55 ulp) than the first 
> three (error: 0.45 ulp). Interestingly, it is precisely this wrong 
> answer which is used in the doctest. 
>
> I think it's fair to say that the doctest isn't robust. 
>

Actually, on FreeBSD I get 
sage: float(RDF(sqrt(3)))
1.7320508075688772

Do you mean to say that Linux's (g)libm is not as good? :-)
  
 

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-devel] algdep (PARI) with clang on FreeBSD

2017-03-29 Thread Jeroen Demeyer

On 2017-03-29 11:24, Dima Pasechnik wrote:

Is the following a bug, or  not:


A bug in what :-)

This is already interesting (on Linux):

sage: float(RR(3).sqrt())
1.7320508075688772
sage: float(RDF(3).sqrt())
1.7320508075688772
sage: float(RR(sqrt(3)))
1.7320508075688772
sage: float(RDF(sqrt(3)))
1.7320508075688774

The last one is actually more wrong (error: 0.55 ulp) than the first 
three (error: 0.45 ulp). Interestingly, it is precisely this wrong 
answer which is used in the doctest.


I think it's fair to say that the doctest isn't robust.

--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.


[sage-devel] algdep (PARI) with clang on FreeBSD

2017-03-29 Thread Dima Pasechnik
Is the following a bug, or  not:

# Sage 7.6 built with clang 3.8 on x86_64 FreeBSD 11.0 (see #22679)
sage: z=(1/2)*(1+RDF(sqrt(3))*CDF.0); z
0.5 + 0.8660254037844386*I
sage: [z.algdep(k) for k in [2..6]]
[x^2 - x + 1, x^3 - x^2 + x, x^3 - x^2 + x, x^5 + x^2, x^5 + x^2]

# Sage 7.6 on x86_64 Linux wth gcc:
sage: z=(1/2)*(1+RDF(sqrt(3))*CDF.0); z
0.5 + 0.8660254037844387*I
sage: [z.algdep(k) for k in [2..6]]
[x^2 - x + 1, x^3 + 1, x^3 + 1, x^3 + 1, x^3 + 1]

Interestingly, clang/FreeBSD does a better job in computing the last 
(approx.) digit, '6' of z. Indeed:
sage: t=(1/2)*(1+I*sqrt(3)); t
1/2*I*sqrt(3) + 1/2
sage: t.n(prec=100)
0.5 + 0.86602540378443864676372317075*I

and so it should indeed round to '6', and not to '7'.

Also I find it funny that factors of the form x^j are not removed by PARI...

Thanks,
Dima






-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.