Hi,

I am working to get Piecewise to understand intervals.  But I am running
into issues with how Interval and And work.  Here are my notes and
questions:


Boolean Operators
=================

In [39]: e = And(x>0,x<1)

In [40]: e.subs(x,0.5)
Out[40]: And(0 < 0.5, 0.5 < 1)

Shouldn't this be true?  How does And get its truth value and why is this
not True?

Interval
========

In [41]: i = Interval(0,1)

In [42]: 0.5 in i
Out[42]: True

In [43]: 1.5 in i
Out[43]: False

In [45]: -0.5 in i
Out[45]: False

In [44]: x in i
Out[44]: True

This last should not return True!!

This comes from how Interval._contains works by building an And. It returns
the And(x>0,x<1), which evaluates as True even though it remains symbolic:

In [9]: bool(And(0<=x, x<=1))
Out[9]: True

What should __contains__ do if it can't decide the result because it is
symbolic?  Currently it returns the indeterminant And, which Python decides
is True.  Hmm.

Cheers,

Brian

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
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/sympy?hl=en.

Reply via email to