Ask Your Question

Revision history [back]

You can construct the 3-dimensional cube as follows:

sage: P = polytopes.n_cube(3) ; P
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices
sage: P.vertices()
(A vertex at (-1, -1, -1),
 A vertex at (-1, -1, 1),
 A vertex at (-1, 1, -1),
 A vertex at (-1, 1, 1),
 A vertex at (1, -1, -1),
 A vertex at (1, -1, 1),
 A vertex at (1, 1, -1),
 A vertex at (1, 1, 1))

Then construct the polyhedron with the last vertex removed:

sage: Q = Polyhedron(P.vertices()[:-1]) ; Q
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 7 vertices
sage: Q.vertices()
(A vertex at (-1, -1, -1),
 A vertex at (-1, -1, 1),
 A vertex at (-1, 1, -1),
 A vertex at (-1, 1, 1),
 A vertex at (1, -1, -1),
 A vertex at (1, -1, 1),
 A vertex at (1, 1, -1))

Then compute its volume:

sage: Q.volume()
20/3

In our case, the length of the edge is 2. If you want to replace it by a, it suffice to multipliy the result by by (a/2)^3:

sage: a = var('a')
sage: Q.volume()* (a/2)^3
5/6*a^3

You can construct the 3-dimensional cube as follows:

sage: P = polytopes.n_cube(3) ; P
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 8 vertices
sage: P.vertices()
(A vertex at (-1, -1, -1),
 A vertex at (-1, -1, 1),
 A vertex at (-1, 1, -1),
 A vertex at (-1, 1, 1),
 A vertex at (1, -1, -1),
 A vertex at (1, -1, 1),
 A vertex at (1, 1, -1),
 A vertex at (1, 1, 1))

Then construct the polyhedron with the last vertex removed:

sage: Q = Polyhedron(P.vertices()[:-1]) ; Q
A 3-dimensional polyhedron in ZZ^3 defined as the convex hull of 7 vertices
sage: Q.vertices()
(A vertex at (-1, -1, -1),
 A vertex at (-1, -1, 1),
 A vertex at (-1, 1, -1),
 A vertex at (-1, 1, 1),
 A vertex at (1, -1, -1),
 A vertex at (1, -1, 1),
 A vertex at (1, 1, -1))

Then compute its volume:

sage: Q.volume()
20/3

In our case, the length of the edge is 2. If you want to replace it by a, it suffice to multipliy the result by by (a/2)^3:

sage: a = var('a')
sage: Q.volume()* (a/2)^3
5/6*a^3

If you want to have a plot of the polyhedron Q, just do:

sage: Q.plot()