Ask Your Question
0

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

asked 2020-10-07 23:49:01 -0500

Cyrille gravatar image

updated 2020-10-07 23:55:47 -0500

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 01:31:09 -0500

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 04:31:39 -0500 )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 04:50:54 -0500 )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 10:17:43 -0500 )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-07 23:49:01 -0500

Seen: 57 times

Last updated: Oct 08