I have come across a few questions asking about integrating over regions. And while the answers are impressive there should be a better more consistent way. So my question is, are there ways, documented or undocumented, that allow one to expressly integrate over regions in an elegant fashion.


Funny you should ask :), it turns out there is an undocumented use of Integrate that one can leverage to integrate over regions. Unfortunately this does not seem to work for NIntegrate. This usage is better leveraged in conjunction with some other undocumented functions (see here and here). I will show a few examples of how to use this feature.

First, let's compute the area of a circular disk of radius r. This can be achieved by directly integrating over the Disk region as follows: (Note the use of ∈ notation)

Integrate[1, x ∈ Disk[{0, 0}, r]]

Mathematica graphics

How about the perimeter of a circle with radius r? Well,

Integrate[1, x ∈ Circle[{0, 0}, r]]

Mathematica graphics

We can compute the volume of a cylinder of height h and radius r

Integrate[1, x ∈ Cylinder[{{0, 0, 0}, {0, 0, h}}, r], Assumptions -> {h > 0}]

Mathematica graphics

Okay, enough of integrating constants over Graphics primitives. Here I show how to integrate functions over regions:

Integrating over a Tetrahedron

Integrate[x^3 y^3 + z^4, {x, y, z} ∈ 
  Tetrahedron[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}]]

Mathematica graphics

(Note the use of undocumented Tetrahedron I unearthed in one of the links shared above)

Now we load the undocumented Region context see link above (we'll need this going forward)


The above calculation over a Tetrahedron seems to be a little slow, but we can remedy that by using the SimplexRegion function

Integrate[x^3 y^3 + z^4, {x, y, z} ∈ 
  SimplexRegion[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}]]

Mathematica graphics

The result is instantaneous.

So what else can we do other than integrate over standard regions? Well, we can create parametric regions and integrate over them and this can have powerful consequences. I'll show just one use case.

Consider the following curve from which we shall cut a region:

curve = x^3 - 3 x^2 + 1;
region = x^3 - 3 x^2 + 1 <= y && y <= 0 && 1 <= x <= 2

   plot1 = Plot[curve, {x, -1, 3}, PlotStyle -> Thick, Filling -> Axis]

Mathematica graphics

plot2 = RegionPlot[region, {x, 1, 2}, {y, -3, 1}, PlotStyle -> {Darker@Yellow}]

Mathematica graphics Mathematica graphics

Let's compute the centroid of this region.

We first create a ParametricRegion (another undocumented function)

paregion = ParametricRegion[{{x, y}, region}];

Now we compute it's centroid:

centroid = Integrate[p, p ∈ paregion] / Integrate[1, {x, y} ∈ paregion]

Or you can use the undocumented function:


{71/45, -(127/105)}

Show[plot2, Graphics[{PointSize[0.03], Red, Point[centroid]}]]

Mathematica graphics Mathematica graphics

Here's the area:



Which we can obtain with Integrate

Integrate[1, x ∈ paregion]


This is all the fun for now. Hopefully others can come up with clever ways to use this feature.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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