# Computing the volume of a polytope that is not full-dimensional

Let us assume we are given a polytope in $\mathbb{R}^d$ which is $k$-dimensional. How can we compute its $k$-dimensional volume in Sage?

edit retag close merge delete

Sort by » oldest newest most voted

There is a simple way to do so directly in Sage:

sage: p = polytopes.permutahedron(4); p
A 3-dimensional polyhedron in ZZ^4 defined as the convex hull of 24 vertices


Naturally, it is lower dimensional, so its volume is zero:

sage: p.volume()
0


But, changing the measure to 'induced', we can directly compute the Lebesgue measure inside of the affine hull, without doing any transformation:

sage: p.volume(measure='induced')
32


The .volume method can use different algorithms and other measures (for example for lattice polytopes) whose performance may vary, you can check the accessible algorithms by typing p.volume? and read the documentation for more details.

more

I would do the following:

1. Translate the polytope to have one vertex at the origin. This way it lives in a $k$-dimensional vector subspace, not only affine subspace.

2. Find an orthonormal basis of this subspace.

3. Express the polytope in that basis.

4. Now work in $\mathbb{R}^k$ and find the volume of the polytope.

more