Ask Your Question
0

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

asked 2020-10-08 06:49:01 +0100

Cyrille gravatar image

updated 2020-10-08 06:55:47 +0100

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[0][0].rhs()>eq2[0][0].rhs(),x_1)
l2=solve(eq4[0][0].rhs()>=eq2[0][0].rhs(),x_2)
show(l1) 
show(l2)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-10-08 08:31:09 +0100

Emmanuel Charpentier gravatar image

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[0][0].rhs()>eq2[0][0].rhs(),x_1)
:l2=solve(eq4[0][0].rhs()>=eq2[0][0].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 ?

edit flag offensive delete link more

Comments

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]$

Cyrille gravatar imageCyrille ( 2020-10-08 11:31:39 +0100 )edit

Indeed...

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

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2020-10-08 11:50:54 +0100 )edit

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.

Cyrille gravatar imageCyrille ( 2020-10-08 17:17:43 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-10-08 06:49:01 +0100

Seen: 203 times

Last updated: Oct 08 '20