Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

(Unexpanded) symbolic inequalities yield erroneous results

I'm a SAGE novice, but have at least looked around this forum a bit on this matter. Apologies if this is a FAQ that I missed.

I am working with pretty simple symbolic expressions (type 'sage.symbolic.expression.Expression') involving rational numbers and some square roots. I have encountered several instances in which SAGE returns incorrect booleans when asking about inequalities between these things. For what it's worth, SAGE seems to get the answer right when I expand the expressions (simply by appending a .expand() to the end of them).

In particular, SAGE sometimes returns True when given "A < B" where A and B are symbolic expressions that are (not-obviously) equal. Here's an example that actually came up.

bool((1/8*sqrt(2)*(sqrt(2)*(sqrt(2) - 2) + 4*sqrt(2)) + 1/4*sqrt(2)*(sqrt(2) - 2) + 3/4*sqrt(2) - 1/2) < (1/8*sqrt(2)*(sqrt(2) + 2) + 1/4*sqrt(2) + 1/4))

SAGE returns True to this strict inequality. It also returns True when < is replaced by ==, as it should since these are equal. As mentioned, appending an .expand() to each side causes SAGE to return False to the strict inequality, which it should.

Any idea what's going wrong here?