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?


1 Answer 1


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]


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

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


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[]]


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.

  • 3
    $\begingroup$ Could instead use Boole and integrate over R^3. $\endgroup$ Jul 20, 2018 at 15:15
  • 2
    $\begingroup$ @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}]. $\endgroup$ Jul 20, 2018 at 16:25
  • $\begingroup$ Good point...(you gonna share that extra third of pie?) $\endgroup$ Jul 20, 2018 at 21:11
  • 2
    $\begingroup$ @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}]]? $\endgroup$ Jul 20, 2018 at 22:01
  • 1
    $\begingroup$ 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. $\endgroup$ Aug 17, 2018 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.