In [42]: bool(1/(-ln(35) + 2*sqrt(4)) > 0.1) TypeError: cannot determine truth value of Relational
It works if I explicitly tell it to evalf: In [43]: 1/(-ln(35) + 2*sqrt(4)).evalf() > 0.1 Out[43]: True
I don't understand the logic of how sympy/python determine whether or not to evaluate the inequality. I'm not sure what is going wrong in this instance to keep the evaluation from occurring. If I change the numbers, it sometimes works, sometimes doesn't.
In [53]: 1/(-ln(35) + 2*sqrt(3)) > 0.1 Out[53]: False
I can't find anything mathematically special about the cases that don't automatically evaluate to a boolean (and therefore cannot be explicitly evaluated to a boolean, either, as they get a TypeError), so I am mystified by this behavior and the source of what appears to be a bug.
Any ideas?
Duane Nykamp
Aaron Meurer
unread,
Oct 29, 2015, 3:37:07 PM10/29/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to sy...@googlegroups.com
It looks like a bug.
I dug into it, and it looks like this is the source:
In [6]: (-0.1 + 1/(-log(35) + 4))._eval_evalf(2)
Out[6]: zoo
In the meantime, you can use simplify() to evaluate expressions like
this, and as far as I know, simplify() will work even in cases where
relationals don't automatically evaluate on purpose (not due to a
bug).