There is a Mathematica package to evaluate integrals over polytopes:
http://library.wolfram.com/infocenter/Books/3652/
In the documentation (Functions.nb
file) I find:
ipoly::usage = "ipoly[f[x1, x2, I, xn], {x1, x2, I, xn}, {{a11, a12, I, a1n}, {a21, a22, I, a2n}, I, {aJ1, aJ2, I, aJn}}, {b1, b2, I, bJ}] is the n-dimensional integral of f[I] over a finite volume bounded by an n-dimensional convex polytope P. P is defined to be all points which satisfy the J inequalities: aj1 x1 + aj2 x2 + I + ajn xn <= bj, 1 <= j <= J. Input form is ipoly[f, x, {c1 <= c2, c3 <= c4, I}] where ci's are linear in x.";
I am trying a very simple example (similar to the one presented in AboutFunctions.nb
: to integrate the function: f[x,y] = x + y
over the polytope described by the set of inequalities {0 <= x, x <= 1 - y, -1 <= y, x + 2 y <= 2}
.
ipoly[
x+y,
{x,y},
{0 <= x, x <= 1 - y, -1 <= y, x + 2 y <= 2}
]
ipoly[x + y, {x, y}, ..]
I am unable to understand how the output can be the result of an integral? It looks like it is just giving me back the input itself.
If someone knows how to use this function ipoly[...]
, please tell me.
ipoly
needs to be a function that takes as many variables as you provide in the next argument, whereas you've input an expression. For your case above, tryipoly[Plus, {x,y}, ...]
$\endgroup$