# Is there a way to automatically find the limits of integration given a set of constraints?

I have a complicated function $F(x,y,z)$ which I want to integrate subject to these constraints:

$y\geq z\geq-y, y \geq 0, y \leq \frac{x+z}{3}$.

It's only a 3D problem, so it's possible to draw a diagram to figure out the limits of integration. If I draw the lines $z=y$, $z=-y$, and $z=3y-x$ on pen and paper, the volume being integrated can be constrained. The answer turns out to be

$\int^{x/4}_0 dy \int^y_{-y} F(x,y,z)dz + \int^{x/2}_{x/4} dy \int^y_{3y-x} F(x,y,z) dz$

I am wondering if there's a way to do this automatically via Mathematica, especially since in 4 dimensions and higher I can't draw a diagram to visualize the limits of integration. The obvious way is to use a Mathematica command of the form:

Integrate[F, y, z, Assumptions -> (the conditions above)]


However adding the assumptions doesn't do anything and the result is the same as when the assumptions aren't there.

Is there a way to do it?

You can directly integrate over the region defined by the conditions:

R = ImplicitRegion[x^2 + y^2 <= 1, {x, y}]
Integrate[x^2, {x, y} ∈ R]


π/4

If this does not evaluate symbolically, you can still do it numerically with

NIntegrate[x^2, {x, y} ∈ R]


0.785398

Apparently, this does also work when the integration domain is a 2-dimensional surface in $\mathbb{R}^3$:

NIntegrate[x^2, {x, y, z} ∈ Sphere[]]


4.18879

Compare also to the following integral over the solid ball (a three-dimensional domain of integration):

Integrate[x^2, {x, y, z} ∈ Ball[]]


(4 π)/15

I haven't checked it thouroughly, though.

• Could instead use Boole and integrate over R^3. – Daniel Lichtblau Jul 20 '18 at 15:15
• @DanielLichtblau If you want to integrate over a surface (which is a null set for the three-dimensional Lebesgue measure), then you get result 0 from NIntegrate[ x^2 Boole[x^2 + y^2 + z^2 == 1], {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]. – Henrik Schumacher Jul 20 '18 at 16:25
• Good point...(you gonna share that extra third of pie?) – Daniel Lichtblau Jul 20 '18 at 21:11
• @DanielLichtblau Do you mean this third of pi: NIntegrate[1, {x, y, z} \[Element] ImplicitRegion[0 <= z <= 1 && x^2 + y^2 <= z^2, {x, y, z}]]? – Henrik Schumacher Jul 20 '18 at 22:01
• DiscretizeRegion approximates the region by small triangles or tetrahedra. Numerical integration over a triangle or a tetrahedron is simple. In fact, NIntegrate has to discretize the region anyway. But doing that by hand with DiscretizeRegion gives one the opportunity to tune the discretization (have a look at the options of DiscretizeRegion) and one can see what went wrong with the discretization. – Henrik Schumacher Aug 17 '18 at 5:53