On Thu, 15 May 2008, William Stein wrote:

>
> On Thu, May 15, 2008 at 10:42 PM, John H Palmieri
> <[EMAIL PROTECTED]> wrote:
>>
>>
>>
>> On May 15, 9:56 pm, "William Stein" <[EMAIL PROTECTED]> wrote:
>>> On Thu, May 15, 2008 at 9:48 PM, John H Palmieri <[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>
>>>> Is this a bug?
>>>
>>>> sage: 3 == pi
>>>> 3 == pi
>>>> sage: i == i
>>>> I == I
>>>
>>>> Shouldn't this return "False" and "True", respectively?
>>>
>>> Those are symbolic equations:
>>>
>>> sage: type(I == I)
>>> <class 'sage.calculus.equations.SymbolicEquation'>
>>>
>>> It's just a more general case of:
>>>
>>> sage: var('a,b,c,x')
>>> (a, b, c, x)
>>> sage: a*x^2 + b*x + c == 0
>>> a*x^2 + b*x + c == 0
>>> sage: type(a*x^2 + b*x + c == 0)
>>> <class 'sage.calculus.equations.SymbolicEquation'>
>>> sage: solve(a*x^2 + b*x + c == 0, x)
>>> [x == (-sqrt(b^2 - 4*a*c) - b)/(2*a), x == (sqrt(b^2 - 4*a*c) - b)/(2*a)]
>>
>> Yes, except I, pi, and e are constants, not variables.
>
> They are elements of the symbolic ring:
>
> sage: parent(I)
> Symbolic Ring
> sage: parent(pi)
> Symbolic Ring
> sage: parent(e)
> Symbolic Ring
>
> I'm not claiming to tell you the ultimate way things "should be".  I'm only
> explaining why they work the way they were and they do.
>
>> I suppose "bug" is not the right word, but I would content that this
>> behavior is not at all what beginning users will expect.  I mean, if I
>> can do 'e**(i * pi)' and get -1, I would expect to be able to do '3 ==
>> pi' and get "False".
>>
>> Or maybe I should say, if I can do 'a = 5; a == 7' and get "False", I
>> would expect to be able to do '3 == pi' and get "False".  Why is pi
>> treated as a symbolic variable and not as a number?
>
> Pi is an element of the symbolic ring.  What ring would you want
> it to be part of?  There is no "ring of numbers" in Sage.   There could
> be I suppose, but there isn't at present.
>
>> (Think about this from the beginning user's point of view.  If they
>> see odd behavior, they're going to be confused.  A goal should be to
>> not let this happen, or to provide a good way for them to figure out
>> why the behavior was actually reasonable in the first place. How do
>> you expect someone to react when they type in '3 == pi'?  If they're
>> puzzled, what do you reasonably expect them to be able to do to
>> clarify things?)
>
> I would prefer "3 == pi" to return False.  See below.   Want to make
> a Sage Enhancement Proposal and implement it?  :-)  It would
> go something like this:
>
> Sage Enhancement Proposal: Change comparisons that involve
> elements of the symbolic ring to return True or False if both sides
> of the symbolic comparison are constants and the comparison can
> be definitely determined. [...]   There would be a discussion on sage-devel,
> probably some voting, and then it would get done.

+1!  Robert Miller and I were discussing creating a language today.  No matter 
what was input, it would return an affirmative answer.  Perhaps this is a 
better idea:

{{{
class do_what_i_say:
     def eval(self,str):
         return str
doit = do_what_i_say()
}}}

{{{
%doit
foo bar
baz
///
foo bar
baz
}}}

Hey, check it out!  Thanks to the Sage notebook, one can implement a 
feature-rich computer algebra system in 3 lines!  It computes anything you ask 
for almost instantaneously!

Seriously though, I understand *why* the following happens:

sage: sqrt(2)
sqrt(2)
sage: sqrt(2) < 2
sqrt(2) < 2

I even know how to disable it.  But it seriously drives me nuts every time I 
run into it.


>
>>
>>> That said, maybe something so obvious as I == I would best be simplified
>>> to True.  But then people would argue that it is very inconsistent that
>>> sometimes symbolic equations are simplified to True/False and sometimes
>>> they aren't.
>>>
>>> In all cases you can do bool( a symbolic equation ) to get True or False.
>>>
>>> sage: bool(I == I)
>>> True
>>>
>>>> I know this
>>>> works:
>>>
>>>> sage: 3 == pi.n()
>>>> False
>>>> sage: 3 == RR(pi)
>>>> False
>>>
>>>> but I sort of expect pi to act like the number pi when used with
>>>> things like == or <, without using the .n() decoration.
>>>
>>> Nope.  Pi is symbolic.
>>>
>>> I'm certainly open to doing some simplification to True/False of symbolic
>>> equalities though, when we can do so.  I think the main reason we don't
>>> now is simply that nobody implemented it.  Comments welcome.
>>>
>>>  -- William
>>>
>>
>
>
>
> --
> William Stein
> Associate Professor of Mathematics
> University of Washington
> http://wstein.org
>
> >
>



--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to