In every CAS I've used, the tendency to reduce true symbolic equations to
boolean True drives me nuts.
What if the user wants to start from a known true equation and then
manipulate both sides to obtain an identity of some sort? Automatic
reduction to a boolean value disallows this use case.
I vote for requiring the bool cast previously mentioned.
- Rhys
On Fri, May 16, 2008 at 12:57 AM, William Stein <[EMAIL PROTECTED]> 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.
>
> >
> >> 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 [email protected]
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
-~----------~----~----~----~------~----~------~--~---