# Revision history [back]

From my testing, it appears that foo is evaluating to False. Hence, in the expression "foo and bar", the foo is evaluating as False, so it skips evaluation of bar. As such, it is returning the first operand, foo, which is sin(x) > 0.

In the second expression, "foo or bar", the foo evaluates as False. With an "or" operator, the second operand must be evaluated. As such, it's returning the second operand, bar, cos(x) > 0.

You can see similar behavior of the "and" and "or" operators with the following:

sage: 0.0 and sin(x)
0.000000000000000
sage: 0.0 or sin(x)
sin(x)


From my testing, it appears that foo is evaluating to False. Hence, in the expression "foo and bar", the foo is evaluating as False, so it skips evaluation of bar. As such, it is returning the first operand, foo, which is sin(x) > 0.

In the second expression, "foo or bar", the foo evaluates as False. With an "or" operator, the second operand must be evaluated. As such, it's returning the second operand, bar, cos(x) > 0.

You can see similar behavior of the "and" and "or" operators with the following:

sage: 0.0 and sin(x)
0.000000000000000
sage: 0.0 or sin(x)
sin(x)


Edit: Sorry, this probably didn't answer the original question. I can't tell you why foo is being evaluated as False, given the unknown value of x. However, I can reasonably assume that foo is being evaluated as False. If you plug in a value for x, like foo(2.0), then it correctly evaluates as True.