Assumptions and inequalities
Hello all.
I have some expressions like sums of ratios of real polynomials in a variable t. Mathematically, by assuming t real in a specific interval, each such expression is either always positive, or always non-negative.
For Sage, this is sometimes the case, sometimes not: as you can see, the first one is correct, the second one not
var('t')
expr1 = -1 + (t^2 - 1)/t^2 + 1/t^2
expr2 = (t^2 - 1)/(t^2 - 3)
with assuming(t > 0, t < 1/2):
print(bool(expr1 <= 0), bool(expr1 > 0))
print(bool(expr2 <= 0), bool(expr2 > 0))
Output: (True, False) \n (False, False)
Questions: Why? How can I avoid this problem?
(An answer to the second question would be enough for me)
Thanks in advance :)
It seems that Sage uses Maxima and Pynac for the assumptions framework. The same problem is present in Maxima 5.39.0:
I guess that Sage converts Maxima's
unknown
toFalse
. I tried to track down what Pynac does, but found the code hard to follow.Thanks. About my first question: Could the reason be that sqrt(3) is not rational? (I have no idea).
About my second question: I also tried without assumptions in other ways, like by using solve or solve_ineq. But I have similar problems.
Anyway, an alternative procedure that works (that is, an answer to the second question), for me would be considered as a full answer (and very appreciated).
The bug or "missing feature" in Maxima (first reported in 2011) is indeed because of irrational roots. To work around your problem I would first treat the numerator and denominator separately (or multiply them, as suggested in the answer below, though this gives a polynomial with larger degree) so the problem is reduced to polynomials. Then it depends on what you want to do: to determine the sign in one interval, or to determine all the intervals on which the sign is constant (the latter can be used to answer the former).