# 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[10]

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[0]

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.

( 2020-10-11 23:19:22 +0200 )edit

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 ?

( 2020-10-11 09:24:09 +0200 )edit

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.

( 2020-10-11 09:51:04 +0200 )edit

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.

( 2020-10-11 11:09:03 +0200 )edit

Les traducteurs automatiques sont devenus très performants.

Citons par exemple DeepL accessible via linguee.

( 2020-10-11 22:57:31 +0200 )edit

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[0]
sage: eq0

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

sage: eq10 = rep[10]
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.

( 2020-10-11 23:01:04 +0200 )edit