# Extracting inequalities for polytopes

Here is a buckyball

bb = polytopes.buckyball()
rep = bb.Hrepresentation()
show(rep)


and its Hrepresentation. When i ask for say

rep


Sagemath returns the 10th inequality in a way that i coud not use it. Is there a way to obtain explicit inequalities for the polytopes ?

If i type

eq0 = rep


I have an acceptable answer with $x_1$ and $x_2$, but I do not know how to call either $x_1$ or $x_2$ to reuse that inequality in say a linear program.

edit retag close merge delete

reveals many other questions and answers which might give some insight.

Sort by » oldest newest most voted Comme ça :

sage: P = polytopes.simplex(4)
sage: P.inequalities_list()
[[1, 0, -1, -1, -1, -1],
[0, 0, 1, 0, 0, 0],
[0, 0, 0, 1, 0, 0],
[0, 0, 0, 0, 1, 0],
[0, 0, 0, 0, 0, 1]]

more

Thanks for your answer FrédéricC. But I do not understand the format of the list. As I understand it, the simplex in dimension 4. So why 6 enters not 5 ?

C'est pas interdit de parler français. Le 4-simplexe vit en dimension 5. Chaque inégalité contient un scalaire et un vecteur, donc 6 composants. Merci de lire la documentation.

Merci. En ce qui concerne le français, je pensais que tout le monde devait pouvoir lire les messages et qu'un langage universel était souhaitable.

Les traducteurs automatiques sont devenus très performants.

Citons par exemple DeepL accessible via linguee.

The documentation for Polyhedron can be accessed using ?:

sage: Polyhedron?


or online:

See some examples at

Let us look at the specific polytope in the question.

The H-representation consists in

• equalities of the form A * x + b = 0
• inequalities of the form A * x + b >= 0

To get the vector A and the scalar b, use the A and b methods of equalities and inequalities.

sage: eq0 = rep
sage: eq0

sage: eq0.A()
(0, -3, -3/2*sqrt5 - 3/2)
sage: eq0.b()
3/4*sqrt5 + 11/4

sage: eq10 = rep
sage: eq10
An inequality (-132*sqrt5 - 300, 0, -84*sqrt5 - 180) x + 122*sqrt5 + 270 >= 0

sage: eq10.A()
(-132*sqrt5 - 300, 0, -84*sqrt5 - 180)
sage: eq0.b()
3/4*sqrt5 + 11/4


If you need radical expressions (when they exist), change to the symbolic ring:

sage: A10, b10 = eq10.A(), eq10.b()
sage: A10.change_ring(SR), SR(b10)
((-132*sqrt(5) - 300, 0, -84*sqrt(5) - 180), 122*sqrt(5) + 270)

more

Note: @FrédéricC's answer explains how to list the $[b, a_0, a_1, ..., a_n]$ of all inequalities at once.