ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 02 Jul 2013 03:46:43 -0500- simplifying rational inequality resultshttp://ask.sagemath.org/question/10287/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]]
?
Thu, 27 Jun 2013 22:10:21 -0500http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/
- Comment by kcrisman for <p>The command</p>
<pre><code>solve(abs((2*x-2)/(x-5)) <= 2/3, x)
</code></pre>
<p>yields</p>
<pre><code>#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]]
</code></pre>
<p>Is there a way to simplify that output to get something like</p>
<pre><code>[[-1 <= x, x <= 2]]
</code></pre>
<p>?</p>
http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?comment=17438#post-id-17438Not 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<x,x<2]]` (where `<` means <.Fri, 28 Jun 2013 03:40:34 -0500http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?comment=17438#post-id-17438
- Comment by kcrisman for <p>The command</p>
<pre><code>solve(abs((2*x-2)/(x-5)) <= 2/3, x)
</code></pre>
<p>yields</p>
<pre><code>#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]]
</code></pre>
<p>Is there a way to simplify that output to get something like</p>
<pre><code>[[-1 <= x, x <= 2]]
</code></pre>
<p>?</p>
http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?comment=17430#post-id-17430For 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).Fri, 28 Jun 2013 14:34:39 -0500http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?comment=17430#post-id-17430
- Comment by jondo for <p>The command</p>
<pre><code>solve(abs((2*x-2)/(x-5)) <= 2/3, x)
</code></pre>
<p>yields</p>
<pre><code>#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]]
</code></pre>
<p>Is there a way to simplify that output to get something like</p>
<pre><code>[[-1 <= x, x <= 2]]
</code></pre>
<p>?</p>
http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?comment=17413#post-id-17413@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.Sun, 30 Jun 2013 21:28:40 -0500http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?comment=17413#post-id-17413
- Comment by kcrisman for <p>The command</p>
<pre><code>solve(abs((2*x-2)/(x-5)) <= 2/3, x)
</code></pre>
<p>yields</p>
<pre><code>#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]]
</code></pre>
<p>Is there a way to simplify that output to get something like</p>
<pre><code>[[-1 <= x, x <= 2]]
</code></pre>
<p>?</p>
http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?comment=17406#post-id-17406Well, 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.Mon, 01 Jul 2013 07:04:57 -0500http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?comment=17406#post-id-17406
- Answer by jondo for <p>The command</p>
<pre><code>solve(abs((2*x-2)/(x-5)) <= 2/3, x)
</code></pre>
<p>yields</p>
<pre><code>#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]]
</code></pre>
<p>Is there a way to simplify that output to get something like</p>
<pre><code>[[-1 <= x, x <= 2]]
</code></pre>
<p>?</p>
http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?answer=14517#post-id-14517Yes, now that there's a [QEPCAD package available](http://trac.sagemath.org/ticket/10224) and already installed on http://sagecell.sagemath.org and https://cloud.sagemath.com.
Calling
dnf = solve(abs((2*x-2)/(x-5)) <= 2/3, x)
qf = apply(qepcad_formula.or_, map(qepcad_formula.and_, dnf)) # reformat the solution
qepcad(qf, vars='(x)') # simplify
yields
x + 1 >= 0 /\ x - 2 <= 0
Tue, 02 Jul 2013 03:46:43 -0500http://ask.sagemath.org/question/10287/simplifying-rational-inequality-results/?answer=14517#post-id-14517