# simplifying rational inequality results

The command

solve(abs((2*x-2)/(x-5)) <= 2/3, x)


yields

#0: solve_rat_ineq(ineq=2*abs(x-1)/abs(x-5)-2/3 <= 0)
[[x == -1, -6 != 0, -6 != 0], [x == -1, -6 != 0, -6 != 0, -6 != 0], [x
== -1, -6 != 0, -6 != 0], [x == -1, -6 != 0, -6 != 0, -6 != 0], [x == 2,
-3 != 0, -3 != 0], [x == 2, -3 != 0, -3 != 0, -3 != 0], [x == 2, -3 !=
0, -3 != 0], [x == 2, -3 != 0, -3 != 0, -3 != 0], [x == 1], [1 < x, x
< 2], [-1 < x, x < 1]]


Is there a way to simplify that output to get something like

[[-1 <= x, x <= 2]]


?

edit retag close merge delete

Not directly within Sage, I think, though as you'll note the union of all those results is indeed the answer you are looking for. Even solve(abs((x-1)/x)<=1,x) gives several answers, which union to the correct one. That said, it would be nice to "sanitize" the ones above so that it looks more like [[x == -1],[-1<x,x\<1],[x =="1],[1&lt;x,x&lt;2]]" (where="" <="" means="" <.<="" p="">

For other readers - note the same question was asked [here on the Maxima list](http://www.math.utexas.edu/pipermail/maxima/2013/033339.html), with inconclusive results for now (other than what does/doesn't work in Maxima, and which Maxima function creates this).

@kcrisman, since my question was just a boolean one ("is there a way ..."), I would accept your "not directly within Sage" as an Askbot answer, if you care.

Well, I guess I lied, since Python is presumably Turing-complete! But it's not an easy one-liner, though probably someone could write a tricky one-liner.

Sort by » oldest newest most voted

Yes, now that there's a QEPCAD package availableand already installed on http://sagecell.sagemath.org and https://cloud.sagemath.com.

Calling

dnf = solve(abs((2*x-2)/(x-5)) <= 2/3, x)


yields

x + 1 >= 0 /\ x - 2 <= 0

more