Ask Your Question
0

Seemingly false answer by bool()

asked 2020-10-08 06:41:28 +0200

Cyrille gravatar image

updated 2020-10-08 09:38:36 +0200

slelievre gravatar image

I plot the inequalities

var("x_1","x_2")
eq1=solve(3*x_1+4*x_2==14,x_2)
eq2=solve(5*x_1+6*x_2==-8,x_2)
eq3=solve(4*x_1-7*x_2==18,x_2)
eq4=solve(2*x_1-3*x_2==-8,x_2)
b=10
p=plot([eq1[0].rhs(),eq2[0].rhs(),eq3[0].rhs(),eq4[0].rhs()], (x_1, 0,b),color=["#c72b91","#2b37c7", "#cb7b2b","#2bcb4b"],axes_labels=["$x_1$","$x_2$"],legend_label=[r"$%s$"%latex(eq1[0].rhs()),r"$%s$"%latex(eq2[0].rhs()),r"$%s$"%latex(eq3[0].rhs()),r"$%s$"%latex(eq4[0].rhs())])
show(p)

which shows that the eq1 is always above for any $x\geq 0$ to eq2. The same for eq4. But there is an intersection with eq3. So the following code shoud return true for both bool. And this is not the case.

assume(x_1 >0)
show(bool(eq1[0][0].rhs()>eq2[0][0].rhs()))
show(bool(eq3[0][0].rhs()>eq2[0][0].rhs()))

and this is confirmed by the fact that

solve(eq3[0][0].rhs()>eq3[0][0].rhs()

return for solution eq2[0][0], which is a way to answer to the same question that the one ask with bool. Is it my error ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2020-10-08 08:21:53 +0200

Emmanuel Charpentier gravatar image

Your test bool(eq1[0][0].rhs()>eq2[0][0].rhs()) doesn't make any hypothesis onx_1. But :

sage: solve(eq1[0].rhs()>eq2[0].rhs(),x)
[[x_1 > -58]]

Since there are values of x_1 for which your predicate is false, bool is right to return False. Checking other cases is left as an exercise to the reader.

HTH,

PS : your notations could be somewhat streamlined. Learning a bit of Python would be a very wise investment...

edit flag offensive delete link more

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:41:28 +0200

Seen: 48 times

Last updated: Oct 08 '20