# can't solve inequality for independent variable

One of the frustrations I'm always having with Sage is how it tries to "solve" inequalities. For a random example:

sage: var('a b x')
sage: f = (a - b * x^2) / (x-1)
sage: solve(f > 0, x)
[[x < 1, b*x^2 - a > 0], [1 < x, -b*x^2 + a > 0]]


Which I knew already (since it's just the numerator). Ok, so various signs and things matter, but the fact that it can't even tell me

x^2 > a/b


is frustrating. Is there a reason, or a way to convince Sage to actually "solve" these in some way?

edit retag close merge delete

Sort by ยป oldest newest most voted

Not directly. You may try :

sage: S1=solve_ineq([(a-b*x^2)/(x-1)>0],[x]);S1
[[x < 1, b*x^2 - a > 0], [1 < x, -b*x^2 + a > 0]]


But there, you're on your own:

sage: solve_ineq([(S1[0][1]+a)/b],[x])
[[b > 0, b*x^2 - a > 0], [-b > 0, -b*x^2 + a > 0]]


sage: S2=(S1[0][1]+a)/b; S2
x^2 > a/b


but

sage: solve_ineq([S2],[x])
[[b > 0, b*x^2 - a > 0], [-b > 0, -b*x^2 + a > 0]]


Note that "the competition" isn't very helpful, either :

sage: mathematica("Reduce[Element[a, Reals] && Element[b, Reals] && Element[x, Reals] && (a-b*x^2)/(x-1)>0 ,x]")
(b < 0 && ((a < b && (Inequality[-Sqrt[a/b], Less, x, Less, 1] ||
x > Sqrt[a/b])) || (a == b && (Inequality[-Sqrt[a/b], Less, x, Less,
1] || x > 1)) || (Inequality[b, Less, a, LessEqual, 0] &&
(Inequality[-Sqrt[a/b], Less, x, Less, Sqrt[a/b]] || x > 1)) ||
(a > 0 && x > 1))) || (b == 0 && ((a < 0 && x < 1) ||
(a > 0 && x > 1))) || (b > 0 && ((a < 0 && x < 1) ||
(Inequality[0, LessEqual, a, Less, b] && (x < -Sqrt[a/b] ||
Inequality[Sqrt[a/b], Less, x, Less, 1])) ||
(a == b && x < -Sqrt[a/b]) || (a > b && (x < -Sqrt[a/b] ||
Inequality[1, Less, x, Less, Sqrt[a/b]]))))


Current progress in sympy may someday get us more helpful answere, but we're not here yet.

Another possibility is to use one of the linear prograpping packages available in Sage, bu I do not know them well enough to point you in the right direction...

HTH,

more

Unfortunately, it does help demonstrating that Mathematica does no better. I guess this is the answer ("Sage can't do what you want"), but I'll give a few days to see if anyone knows more. Thanks.

( 2020-07-24 15:18:24 +0200 )edit