# Calculating volume of convex polytopes generated by inequalities

I have a set of inequalities, I am looking for a way to compute its volume. More specifically, I would like to compute the ratio of its volume with the volume if some more inequalities were added. I have seen this question, I think however that half-plane intersections can be general convex polytopes (not just simplexes, am I wrong?).

I do not think I can expect a formula, an efficient algorithm would do (even an efficient one would be nice). Numerical method suggestions are also welcome.

-

## 1 Answer

If you are ok with approximate result, just use Monte Carlo method and if you want exact solution (like a rational number) then I think you will need to enumerate all the vertices (each vertex is given as a solution of set of some $n$ independent linear equations taken from those inequalities) and split into $n$-cells (like triangulation of some polygon) and sum the volume of those $n$-cells.

I think there might be some more efficient method by splitting this polytope by hyperplanes parallel to $\{x = 0\}$ or $\{y = 0\}$ or something similar, but this looks like a more complicated approach.

Finally there is yet another approach that splits your polytope by $|V|$ hyperplanes parallel to $\{x = 0\}$ passing through each vertex, and then volume of such slice can be computed by manipulating the $(n-1)$-volumes of the two sides, which can be computed by recursive call in a smaller dimension. This is not an efficient algorithm, but it will give a precise result and I think it won't be a nightmare to code (after all, I guess, the number of inequalities and the dimension of the space may vary, so it might be a good approach to code it independently of those two).

Edit: To answer your comment: Well, I don't have much time right now, but I will sketch a possible solution (there may be a better one, but I don't know, this is just a simple approach that came to me at the time of writing the post). Let $A \subset \mathbb{R}^n$ be your $n$-dimensional polytope, and $\mu_k$ be the $k$-dimentional Lebesgue measure (i.e. $k$-volume). Consider a function $$f(x) = \mu_{n-1}(\{p\in A \mid p_0 = x\}).$$ This is a piecewise $(n-1)$-th degree polynomial, e.g. if $n=2$ then you can split your polygon into trapezoids, and $f$ would be piecewise linear, if $n=3$ then you can split your polygon into prismatoids and $f$ would be piecewise quadratic. To obtain the volume of $A$ just integrate $f$ and you are done (this is a polynomial, so it is easy to get the exact result). And how to get $f$? Pieces are exactly created by the vertices, so in $n=3$ case you will need both sides (which you are computing anyway) and something in-between (actually you need $n$ points total for each piece, that means $n-2$ additional points). However, each of these can be solved using a recursive call to this algorithm for smaller dimension, and after that you have $n=3$ data points that uniquely describe a polynomial of $(n-1=2)$-nd degree.

Edit 2: After some reconsideration instead of integration consider just using some quadrature, the result still will be precise (if the order is high enough) and this should skip you the polynomial-fitting part.

However, I think that the approach using $n$-cells may be better. It is simple to calculate the volume of $n$-cell, so the algorithm could be as follows: take random $n$ points and split the polytope by resulting hyperplane into two parts and compute the results recursively. When the number of points is small, just do not take random points (choose them, so the resulting split is good), and finally for each part you will end up with $n+1$ points from which you can easily compute the volume.

Hope this helps!

-

I am interested in the last suggestion, I just don't fully understand it.. Can you maybe explain it in 3D as an example, or can you link to a longer description? – aelguindy Apr 23 '12 at 13:09
@aelguindy The comment was too short. I hope this helps ;-) – dtldarek Apr 23 '12 at 19:23
– aelguindy Apr 24 '12 at 9:45
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 30, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9529070258140564, "perplexity_flag": "head"}