Ask Your Question

Revision history [back]

It seems you would like to extract the inequalities of the hyperplane representation of a polytope as symbolic inequalities (in Sage's symbolic ring).

Maybe this helps.

sage: D = polytopes.dodecahedron()

sage: DH = D.Hrepresentation()
sage: DH[0]
An inequality (0, -1/2, -1/4*sqrt5 - 1/4) x + 1 >= 0

sage: ieq = DH[0]
sage: ieq
An inequality (0, -1/2, -1/4*sqrt5 - 1/4) x + 1 >= 0

sage: ieq.A()
(0, -1/2, -1/4*sqrt5 - 1/4)
sage: parent(ieq.A())
Vector space of dimension 3 over Number Field in sqrt5 with
defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?

sage: ieq.b()
1

sage: x, y, z = SR.var('x, y, z')

sage: symbolic_ieq = ieq.A() * vector([x, y, z]) + ieq.b() >= 0
sage: symbolic_ieq
-1/4*z*(sqrt(5) + 1) - 1/2*y + 1 >= 0

sage: solve(symbolic_ieq, x)
[[y == -1/2*z*(sqrt(5) + 1) + 2],
 [z < -2*y/(sqrt(5) + 1) + 4/(sqrt(5) + 1)]]

It seems you would like to extract the inequalities of the hyperplane representation of a polytope as symbolic inequalities (in Sage's symbolic ring).

Maybe this helps.

sage: D = polytopes.dodecahedron()

sage: DH = D.Hrepresentation()
sage: DH[0]
An inequality (0, -1/2, -1/4*sqrt5 - 1/4) x + 1 >= 0

sage: ieq = DH[0]
sage: ieq
An inequality (0, -1/2, -1/4*sqrt5 - 1/4) x + 1 >= 0

sage: ieq.A()
(0, -1/2, -1/4*sqrt5 - 1/4)
sage: parent(ieq.A())
Vector space of dimension 3 over Number Field in sqrt5 with
defining polynomial x^2 - 5 with sqrt5 = 2.236067977499790?

sage: ieq.b()
1

sage: x, y, z = SR.var('x, y, z')

sage: symbolic_ieq = ieq.A() * vector([x, y, z]) + ieq.b() >= 0
sage: symbolic_ieq
-1/4*z*(sqrt(5) + 1) - 1/2*y + 1 >= 0

sage: solve(symbolic_ieq, x)
[[y == -1/2*z*(sqrt(5) + 1) + 2],
 [z < -2*y/(sqrt(5) + 1) + 4/(sqrt(5) + 1)]]

Using indexed variables instead:

sage: x = vector(SR.var('x', 3))
sage: x
(x0, x1, x2)
sage: symbolic_ieq = ieq.A() * x + ieq.b() >= 0
sage: symbolic_ieq
-1/4*x2*(sqrt(5) + 1) - 1/2*x1 + 1 >= 0
sage: solve(symbolic_ieq, x[0])
[[x1 == -1/2*x2*(sqrt(5) + 1) + 2],
 [x2 < -2*x1/(sqrt(5) + 1) + 4/(sqrt(5) + 1)]]