# bool returns true to an incorrect function call?

This happened to me by mistake.

sage: var('x1,t1,x2,t2,u,c',domain=RR);assume(u>0);assume(c>u);assume(x2>x1);assume(t2>t1);
(x1, t1, x2, t2, u, c)
sage: T1 = (t1-((u*x1)/(c^2)))/sqrt(1-((u^2)/(c^2)))
sage: T2 = (t2-((u*x2)/(c^2)))/sqrt(1-((u^2)/(c^2)))
sage: dT = T2-T1
sage: bool(dT.full_simplify >= 0)
True
sage: bool(dT.full_simplify() >= 0)
False


When I made the incorrect function call dT.full_simplify , bool returned true. When I made the correct function call dT.full_simplify() , bool returned false. Is this a bug?

Thanks

edit retag close merge delete

Sort by » oldest newest most voted

Observe that:

sage: dT.full_simplify
<built-in method simplify_full of sage.symbolic.expression.Expression object at 0xb1ddb0c>


Which means "dT.full_simplify" is not a function call but the "simplify_full" function itself, and comparing it to zero has no mathematical meaning.

I think the reason sage (actually python) allows comparing very general object is to allow creation of sorted lists containing elements of assorted types. If you sort the list [1,2,dT.full_simplify,3] the result will not be "sorted mathematically" but it will allow binary search nonetheless!

In fact notice that you don't even have to call bool:

sage: dT.full_simplify >= 0
True


whereas for the mathematical comparison you do have to, since doing symbolic computations we don't want every EXPR1 >= EXPR2 expression to evaluate immediately to boolean:

sage: dT.full_simplify() >= 0
-sqrt(c - u)*sqrt(c + u)*(c^2*t1 - c^2*t2 - u*x1 + u*x2)/(c^3 - c*u^2) >= 0
sage: bool(_)
False

more