2008/9/2 Jason Merrill <[EMAIL PROTECTED]>:
>
> Be careful with bool. It will return False for equations that may be
> true. Simple example:
>
> sage: bool(x == 0)
> False
>
> I believe in some cases it will return False for equations that are
> actually True if sage doesn't know how to make the necessary
> simplifications. But if it returns True, you can generally trust that
> the equation is true.
>
> See http://trac.sagemath.org/sage_trac/ticket/3369
In evaluating bool(eqn) where eqn is an equation such as
sage: eqn = x==x
Sage is actually evaluating eqn.__iszero__. the docstring there says:
def __nonzero__(self):
"""
Return True if this (in)equality is definitely true. Return False
if it is false or the algorithm for testing (in)equality is
inconclusive.
The main thing which Sage does to decide is to convert the equation
into maxima format and then get maxima to evaluate "is m_eqn" where
m_eqn is the maxima-ised eqn. And maxima is not infallible in
deciding. It is probably best, therefore, to look at maxima's
documentation to see what will happen. For example,
sage: eqn = x^2==x
sage: eqn
x^2 == x
sage: bool(eqn)
False
sage: solve(eqn)
[x == 0, x == 1]
eqn evaluates to False under bool() because it is not always true,
i.e. is not an identy. Of course it is true for some x, as we see
using solve().
sage: eqn = (x+y)^2 == x^2+2*x*y+y^2
sage: eqn
(y + x)^2 == y^2 + 2*x*y + x^2
sage: bool(eqn)
True
sage: eqn = cos(x)^2+sin(x)^2==1
sage: bool(eqn)
True
sage: bool(exp(pi*I)==-1)
True
John
>
> JM
>
>
> On Sep 2, 11:38 am, John H Palmieri <[EMAIL PROTECTED]> wrote:
>> On Sep 2, 8:19 am, "John Cremona" <[EMAIL PROTECTED]> wrote:
>>
>> > Putting == between two symbol expressions creates a symbolic equation,
>> > not a test for equality. There is there fore a difference between
>> > these:
>>
>> > sage: 3 == 3
>> > True
>> > sage: x == x
>> > x == x
>>
>> In the same category as the latter:
>>
>> sage: 3 == pi
>> 3 == pi
>> sage: bool(3 == pi)
>> False
>>
>> In your situation, 'bool(dSv==dSvq)' returns True. (bool is a
>> function which 'Returns True when the argument x is true, False
>> otherwise'.)
>>
>> > This behaviour of == is (I think) unique to the symbolic ring in Sage.
>> > You can test for equality like this:
>>
>> > sage: dSv-dSvq
>> > 0
>> > sage: (dSv-dSvq).is_zero()
>> > True
>>
>> > though in more complicated examples the expessions might have to be
>> > simplified manually.
>>
>> > In general in computer algebra, simplifying an expression which
>> > simplifies to 0 is easier than trying to find two simplifications of
>> > two expressions which appear to be the same.
>>
>> > I'm sure there are computer algebra experts reading this who can
>> > explain it better.
>>
>> > John
>>
>> > 2008/9/2 Stan Schymanski <[EMAIL PROTECTED]>:
>>
>> > > Dear all,
>>
>> > > I must be doing something wrong here, but I don't know what. I'm sure
>> > > someone will see it straight away:
>>
>> > > ----------------------------------------------------------------------
>> > > | SAGE Version 3.1.1, Release Date: 2008-08-17 |
>> > > | Type notebook() for the GUI, and license() for information. |
>> > > ----------------------------------------------------------------------
>>
>> > > sage: var('myuv myub q qvb qbv')
>> > > (myuv, myub, q, qvb, qbv)
>> > > sage: dSv=myuv*qvb - myuv*qbv
>> > > sage: dSvq=myuv*qvb - myuv*qbv
>> > > sage: dsage: dSv-dSvq
>> > > myuv*qvb - myuv*qbv == myuv*qvb - myuv*qbv
>>
>> > > Why does SAGE not return 'true'?
>>
>> > > Just pointing me to the right page in the docu would help, too! Thanks
>> > > already.
>>
>> > > Stan
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---