# Seemingly false answer by bool()

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 close merge delete

Sort by ยป oldest newest most voted

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...

more