ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 27 Aug 2019 22:24:47 +0200Computing the volume of a polytope that is not full-dimensionalhttps://ask.sagemath.org/question/10780/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?Tue, 26 Nov 2013 11:29:09 +0100https://ask.sagemath.org/question/10780/computing-the-volume-of-a-polytope-that-is-not-full-dimensional/Answer by slelievre for <p>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?</p>
https://ask.sagemath.org/question/10780/computing-the-volume-of-a-polytope-that-is-not-full-dimensional/?answer=15757#post-id-15757I 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.Wed, 04 Dec 2013 06:51:26 +0100https://ask.sagemath.org/question/10780/computing-the-volume-of-a-polytope-that-is-not-full-dimensional/?answer=15757#post-id-15757Answer by jipilab for <p>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?</p>
https://ask.sagemath.org/question/10780/computing-the-volume-of-a-polytope-that-is-not-full-dimensional/?answer=47631#post-id-47631There 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.Tue, 27 Aug 2019 22:24:47 +0200https://ask.sagemath.org/question/10780/computing-the-volume-of-a-polytope-that-is-not-full-dimensional/?answer=47631#post-id-47631