[sage-devel] Re: Bug in positivity test of a real expression
Hi Ralf, On 2018-02-05, Ralf Stephanwrote: > Argh, we cannot return Unknown from bool() because of Python. Still, we can > avoid calling Maxima for numeric questions: > https://trac.sagemath.org/ticket/24658 > > This is a really tiny ticket and should be easy to review. Thanks for opening the ticket! Best regards, Simon -- 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: Bug in positivity test of a real expression
Hi Vincent, On 2018-02-05, Vincent Delecroix <20100.delecr...@gmail.com> wrote: >> So, here is the example: >> sage: val = pi - 2286635172367940241408/1029347477390786609545*sqrt(2) >> sage: bool(val<0) >> False >> sage: bool(val>0) >> True > > > > [SNIP] > > >> So, is that a bug, after all? val being positive, RR(val) being >> negative? > > This is example is definitely a bug. In order to test > positivity/negativity of a real number you would better use interval > field to get provent result such as the following. With the default > precision of 53 bits it fails > > sage: r = 2286635172367940241408/1029347477390786609545 > > sage: R = RIF > sage: (R.pi() - r * R(2).sqrt()) > 0 > False > sage: (R.pi() - r * R(2).sqrt()) < 0 > False > > Note that in the above example R here is consistent with comparison: it > does not know and answers False everywhere. As I said, it'd be OK to answer False in both cases. OK, since you confirm it is a bug, I should soonish open a ticket (although TB pointed me off-list (why?) to #19162, but I think #19162 is just a meta-ticket and thus shouldn't prevent to create a regular ticket). Cheers, Simon -- 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: Bug in positivity test of a real expression
Argh, we cannot return Unknown from bool() because of Python. Still, we can avoid calling Maxima for numeric questions: https://trac.sagemath.org/ticket/24658 This is a really tiny ticket and should be easy to review. -- 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: Bug in positivity test of a real expression
I think we should refrain from calling Maxima with bool(...) because our tests are good enough. Moreover with https://trac.sagemath.org/ticket/24345 we could then simply return Unknown. Please review. On Monday, February 5, 2018 at 8:12:49 AM UTC+1, Ralf Stephan wrote: > > Actually Sage's logic is fine here, the bug with bool(val>0) is in > Maxima.The default with bool(relation) is to use RIF and at the default > setting it cannot decide, so ultimately Maxima is called: > > (%i2) is (%pi-(1116521080257783321*2^(23/2))/1029347477390786609545>0); > (%o2)true > > Regards, > -- 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: Bug in positivity test of a real expression
Actually Sage's logic is fine here, the bug with bool(val>0) is in Maxima.The default with bool(relation) is to use RIF and at the default setting it cannot decide, so ultimately Maxima is called: (%i2) is (%pi-(1116521080257783321*2^(23/2))/1029347477390786609545>0); (%o2)true Regards, -- 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: Bug in positivity test of a real expression
Hi Simon, On 04/02/2018 23:59, Simon King wrote: On 2018-02-04, Simon Kingwrote: On 2018-02-04, Thierry wrote: On Sun, Feb 04, 2018 at 10:24:55PM +, Simon King wrote: What is wrong ? val is a NEGATIVE real number converted into SR. val evaluates POSITIVE, even though the conversion of val into RR still evaluates negative. Ouch, sorry, when I posted I was apparently editing stuff in a wrong way. So, here is the example: sage: val = pi - 2286635172367940241408/1029347477390786609545*sqrt(2) sage: bool(val<0) False sage: bool(val>0) True > > [SNIP] > So, is that a bug, after all? val being positive, RR(val) being negative? This is example is definitely a bug. In order to test positivity/negativity of a real number you would better use interval field to get provent result such as the following. With the default precision of 53 bits it fails sage: r = 2286635172367940241408/1029347477390786609545 sage: R = RIF sage: (R.pi() - r * R(2).sqrt()) > 0 False sage: (R.pi() - r * R(2).sqrt()) < 0 False Note that in the above example R here is consistent with comparison: it does not know and answers False everywhere. But 182 bits is enough sage: R = RealIntervalField(128) sage: (R.pi() - r * R(2).sqrt()) > 0 False sage: (R.pi() - r * R(2).sqrt()) < 0 True Vincent -- 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: Bug in positivity test of a real expression
Hi Ralph, On 2018-02-05, Ralf Stephanwrote: > With bool(val<0) ultimately (val<0).test_relation() is called which does: > > sage: RIF(val) > 0.?e-15 > sage: RIF(val) < 0 > False I could understand if BOTH val>0 and val<0 evaluated to False, as val is almost zero. However, if val < 0 evaluates to False then val > 0 evaluating to True is a bug, IMHO. After all, the number *is* negative (by construction, actually). Best regards, Simon -- 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: Bug in positivity test of a real expression
With bool(val<0) ultimately (val<0).test_relation() is called which does: sage: RIF(val) 0.?e-15 sage: RIF(val) < 0 False Regards. -- 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: Bug in positivity test of a real expression
On 2018-02-04, Simon Kingwrote: > On 2018-02-04, Thierry wrote: >> On Sun, Feb 04, 2018 at 10:24:55PM +, Simon King wrote: >> What is wrong ? > > val is a NEGATIVE real number converted into SR. val evaluates POSITIVE, > even though the conversion of val into RR still evaluates negative. Ouch, sorry, when I posted I was apparently editing stuff in a wrong way. So, here is the example: sage: val = pi - 2286635172367940241408/1029347477390786609545*sqrt(2) sage: bool(val<0) False sage: bool(val>0) True Hence, val evaluates positive. However, it represents a negative real number: sage: RR(val) -4.44089209850063e-16 Sorry, in my original post I was starting from that number and got a couple of things wrong. Note that evaluating val to higher precision still gives a negative number, although a clearly different one: sage: RR(RealField(2000)(val)) -5.68242325601396e-24 Going to even higher precision doesn't change things. So, is that a bug, after all? val being positive, RR(val) being negative? Cheers, Simon -- 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: Bug in positivity test of a real expression
On 2018-02-04, Thierrywrote: > On Sun, Feb 04, 2018 at 10:24:55PM +, Simon King wrote: > What is wrong ? val is a NEGATIVE real number converted into SR. val evaluates POSITIVE, even though the conversion of val into RR still evaluates negative. -- 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.