# How to integrate in the region between graphs?

Sometimes when dealing with multiple integrals we need to integrate inside a region bounded by graphs of functions. This leads to integrals of the form:

$$I=\int_{a}^b\int_{f(x)}^{g(x)}\xi(x,y)dydx.$$

One concrete example I came accross recently is the following, consider the region $R$ defined by

$$R=\{(x,y)\in \mathbb{R}^2 : 0\leq x\leq \operatorname{arcsinh}(2), 0\leq y\leq \arctan(\sinh(x))\}$$

This region is bounded by the graph $y = 0$ and $y = \arctan(\sinh(x))$.

If I want to integrate one function of two variables in a region like this, how can I proceed? How Mathematica deals with this?

You need to specify the integrand, of course, but for a simple integrand the numerical integration is straightforward:

NIntegrate[x - y,
{x, 0, ArcSinh},
{y, 0, ArcTan[Sinh[x]]}]


$0.48775$

Some functions give analytic results:

Integrate[x,
{x, 0, ArcSinh},
{y, 0, ArcTan[Sinh[x]]}]


$\frac{1}{16} \left(8 \left(\log ^2\left(2+\sqrt{5}\right) \tan ^{-1}(2)-i \left(-2 \text{Li}_3\left(-i \left(-2+\sqrt{5}\right)\right)+2 \text{Li}_3\left(i \left(-2+\sqrt{5}\right)\right)- 2 \text{Li}_2\left(-i \left(-2+\sqrt{5}\right)\right) \log \left(2+\sqrt{5}\right)+2 \text{Li}_2\left(i \left(-2+\sqrt{5}\right)\right) \log \left(2+\sqrt{5}\right)+\log \left((1-2 i)+i \sqrt{5}\right) \log ^2\left(2+\sqrt{5}\right)-\log \left(i \left(\sqrt{5}+(-2+i)\right)\right) \log ^2\left(2+\sqrt{5}\right)\right)\right)-\pi ^3+8 \pi \log ^2\left(2+\sqrt{5}\right)\right)$

One can define a region

reg = ImplicitRegion[0 <= x <= ArcSinh && 0 <= y <= ArcTan[Sinh[x]], {x, y}]


that looks like this

RegionPlot[reg] and integrate a function over it:

int1 = Integrate[x, {x, y} ∈ reg] Or the old style:

int2 = Integrate[
x Boole[0 <= x <= ArcSinh && 0 <= y <= ArcTan[Sinh[x]]],
{x, -∞, ∞}, {y, -∞, ∞}] int1 and int2 have different forms; some machinery (like ComplexExpand etc.) can be employed to show they are equivalent, but let's just simply

N /@ {int1, int2} // Chop


{0.84757, 0.84757}

to show that they are the same.

This works also for numerical integrals:

int3 = NIntegrate[x - y, {x, y} ∈ reg]


0.48775

int4 = NIntegrate[(x - y) Boole[0 <= x <= ArcSinh && 0 <= y <= ArcTan[Sinh[x]]],
{x, -∞, ∞}, {y, -∞, ∞}]


0.48775

• Actually, if one is using Boole[], one can be lazy and use -∞ and ∞ as the limits, since Boole[] zeroes out everything that doesn't satisfy the condition inside it. Dec 16, 2016 at 2:09