ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Wed, 12 Dec 2018 09:46:42 +0100Verifying inequalitieshttps://ask.sagemath.org/question/44645/verifying-inequalities/ I would like to give SageMath some inequalities, and then ask it if other inequalities follow from them.
For example, I would like to tell SageMath "a > 2*b > 0" and then ask it whether "a - b > b/2" and the answer should be "True", but if I ask whether "a - b > 3*b/2" the answer should be "False" (since it is not implied by the given inequalities).
How can I do this?
Wed, 12 Dec 2018 05:41:14 +0100https://ask.sagemath.org/question/44645/verifying-inequalities/Answer by tmonteil for <p>I would like to give SageMath some inequalities, and then ask it if other inequalities follow from them.</p>
<p>For example, I would like to tell SageMath "a > 2<em>b > 0" and then ask it whether "a - b > b/2" and the answer should be "True", but if I ask whether "a - b > 3</em>b/2" the answer should be "False" (since it is not implied by the given inequalities).</p>
<p>How can I do this?</p>
https://ask.sagemath.org/question/44645/verifying-inequalities/?answer=44647#post-id-44647If the inequalities are linear (as in your example), you can define a polyhedron `P` from them. Then given a new inequality, it also defines a polyhedron `Q` (a half space), and ask wether this new polyhedron `Q` contains the initial one `P`.
You can define polytopes fro inequalities using the `Polyhedron(ieqs=...)` syntax, see, for example:
- https://doc.sagemath.org/html/en/thematic_tutorials/geometry/polyhedra_quicktutorial.html
- https://doc.sagemath.org/html/en/reference/discrete_geometry/sage/geometry/polyhedron/constructor.html
To test that `Q` contains `P`, you can do:
sage: P.intersection(Q) == P
Note that inequalities have to be large (`<=`), not strict (`<`). If you absolutely want to test strict inequalities, you can use vertices and test inclusion in the interior, using `P.interior_contains` method.
Wed, 12 Dec 2018 09:46:42 +0100https://ask.sagemath.org/question/44645/verifying-inequalities/?answer=44647#post-id-44647