# Solve in inequalities return two separate solutions. Could they be gathered ?

In the following code, I wonder if there is a way to ask solve() to return only one solution with $\leq$ and not one for $<$ and one for $=$.

var('x_1','x_2')
eq2=solve(5*x_1+6*x_2<-8,x_1)
eq4=solve(2*x_1-3*x_2<-8,x_1)
l1=solve(eq4.rhs()>eq2.rhs(),x_1)
l2=solve(eq4.rhs()>=eq2.rhs(),x_2)
show(l1)
show(l2)

edit retag close merge delete

Sort by » oldest newest most voted

Sage (9.2.rc0) does exactly what you want :

sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:x_1, x_2=var('x_1','x_2')
:eq2=solve(5*x_1+6*x_2<-8,x_1)
:eq4=solve(2*x_1-3*x_2<-8,x_1)
:l1=solve(eq4.rhs()>eq2.rhs(),x_1)
:l2=solve(eq4.rhs()>=eq2.rhs(),x_2)
:print(l1)
:print(l2)
:--
[[x_2 > (8/9)]]
[[x_2 >= (8/9)]]


The first line is the (single-line) solution to your first inequatio, the second line is the (single-line) solution to your second inequation.

Would you have fries with that ?

more

I use sagecell and in sage cell for pint(l2), the result is :

$left[\left[x_2 =-\frac{5}{6} x_1 -\frac{4}{3}\right],\left[x_2 =-\frac{5}{6} x_1 -\frac{4}{3}\right]\right]$

Indeed...

But Sagecell runs 9.1 ; I run 9.2.rc0. The inequality processing seems to have been somewhat enhanced. See the link...

Emmanuel, I try to make work in line. A huge effort for my student. It takes nearly all my time. Is there any hope that sagecell be powered rapidly by 9.2 ? Do you know who I need to contact because I have seen some differences between notebooks and sagecells. In all cases , one more time thanks for your implications. I am learning Python and Sagemath on the spot. But I have no choice. I will add that up to now, version 9.2 isn't compiled for windows.