I'm hearing some scary proposals in this thread, like crippling symbolic processing, or introducing a whole new set of comparison relations. At the same time I feel that the behaviour John is describing is indeed confusing to newcomers and off-putting enough to be worth doing something about. I believe we can easily have our cake and eat it too. see below.
On May 15, 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. > > 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". this is a good point. why should "e**(i*pi)" evaluate and "i==i" should not? granted, one is an expression and one is an equation. but it makes no more or less sense to evaluate a symbolic expression by default than to evaluate a symbolic equation by default. (an equation is just a boolean expression, is it not?) perhaps it is this inconsistency that is the real source of confusion. > > 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? > > (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?) agreed. and here is my proposal. there should be a symbolic constant "pi", as there already is, and a floating point constant "Pi", an element of the default floating point field RR, probably defined as "Pi = RR(pi)". then a user who types "pi==3" and is confused by the psychoanalytic "the question is the answer" style response, can do: sage: pi? Type: Pi Base Class: <class 'sage.functions.constants.Pi'> String Form: pi Namespace: Interactive Docstring: The ratio of a circle's circumference to its diameter. ...... SEE ALSO: Pi (although i now see that "Pi" is already defined as a type, but if i enter "Pi" at the sage prompt, i am informed that there is no such thing, so would it be a problem to also use "Pi" as the name of a predefined constant? if so, can we change the type's name?) and likewise sage: Pi? ....... SEE ALSO: pi (i'm trying to emphasize not only that there is an easy way to do what you want, but also an easy way to discover how to do that if you try the wrong thing first.) > > > 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. my opinion is that symbolic equations should never be evaluated by default. this would be a disaster even from a design point of view, never mind the implementation nightmare. things like equations and statements are perfectly valid mathematical objects, and one should be able to represent them without regard to their truth value. if one wants to attempt to evaluate an equation, one can type "eval(a==b)" or "bool(a==b)" or whatever. HOWEVER...... perhaps the right way to construct a symbolic equation/ expression is something like "symbolic(a==b)" or "symbolic(e^(i*pi))", and in the absence of this explicit constructor, sage can attempt to evaluate the expression when it is reasonable to do so (and construct a symbolic expression when evaluation looks too hard). comments? > > > -- William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@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-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---