# Integrate not restricting variable with Assumptions option?

I am integrating g over the region:

RegionPlot[ 0 <= x <= 3 && 1 - x <= y < -(2/3) x + 2, {x, 0, 3}, {y, 0, 2}]


The limits of integration are

$$\int _0^1\int _{1-x}^{2-\frac{2 x}{3}}g[x,y]dydx+\int _1^3\int _0^{2-\frac{2 x}{3}}g[x,y]dydx$$

The expected answer is obtained from evaluating these integrals.

g[x_, y_] := 3 x + y^2

Integrate[g[x, y], {x, 0, 1}, {y, 1 - x, -(2/3) x + 2}] +
Integrate[g[x, y], {x, 1, 3}, {y, 0, -(2/3) x + 2}]
(* 125/12 *)


I then had the idea that I could use the Assumptions option to restrict y and only evaluate one Integration. However, the answer is returned is the same as an unrestricted y integration.

Integrate[g[x, y], {x, 0, 3}, {y, 1 - x, -(2/3) x + 2},
Assumptions -> y >= 0]
(* 103/4 *)

Integrate[g[x, y], {x, 0, 3}, {y, 1 - x, -(2/3) x + 2}]
(* 103/4 *)


Why doesn't Integrate restrict y with the Assumption option?

• It appears that Assumptions is intended only to eliminate generated conditions, not to reduce the range of an integration variable. Thus, Integrate[1, {y, -1, 1}] and Integrate[1, {y, -1, 1}, Assumptions -> y > 0] produce the same answer Commented Dec 5, 2015 at 18:10

Another clean approach to performing a single integration builds on the input to the plot in the question.

r = ImplicitRegion[0 <= x <= 3 && 0 <= y <= 2 && 1 - x <= y < -(2/3) x + 2, {x, y}]
Integrate [3 x + y^2, {x, y} ∈ r]
(* 125/12 *)

• This is it! (+1) I will hold out for a while before accepting. Just in case. :-) Commented Dec 5, 2015 at 18:20

Here you loose the control of proper integration limits and the result is different since the region of integration is different.
In general using another variable as a limit of integration is a bad idea moreover using Assumptions to restrict integration (or summation) variables is not reasonable, you can find an analogous mistake in a different context here: Double series over primes.

If you want to get the correct result in one integral there are many different approaches. Let's provide two the most natural and reliable, both working in earlier versions of Mathematica :

Integrate[ g[x, y] Boole[1 - x <= y <= -(2/3) x + 2], {x, 0, 3}, {y, 0, 2}]

125/12


One can use also HeavisideTheta appropriately, which sometimes may appear more efficient (see e.g. this post How to plot and find the volume of a solid?), equivalent calculation with HeavisideTheta:

Integrate[ g[x, y] HeavisideTheta[y + x - 1] HeavisideTheta[-y - 2/3 x + 2],
{x, 0, 3}, {y, 0, 2}]

• The second integral is just restricting $y >= 0$ on $x ∈ [1 ,3]$. Why doesn't an Assumption -> y >= 0 achieve this in the single Integral evaluation. Commented Dec 5, 2015 at 18:09
• Apparently your understanding of Assumptions is incorrect, you cannot limit another variable in this way, this is a common mistake. Read e.g. the second answer (by Sektor) to this question Double series over primes. Is it clear? Commented Dec 5, 2015 at 18:13
• @Edmund In Assumptions you can limit constants, not variables of integration! Commented Dec 5, 2015 at 18:19
• Yes. My understanding of Assumptions was off. Your solution works (+1) but is not the conceptual approach I am seeking. Commented Dec 5, 2015 at 18:23
• @Edmund This had been the best approach until the version 10 of Mathematica (remember my previous remarks) and in various cases it is still the best. I remember several cases when new functionality worked incorrectly, so I'm not sure ImplicitRegion is a perfect approach. Read this answer Finding length of intersection of two surfaces paying attention to its earlier versions and comments beneath. For this reason I'm not quite convinced to ImplicitRegion. Commented Dec 5, 2015 at 18:30

Amplifying on the answer by @bbgodfrey

rgn = ImplicitRegion[0 <= x <= 3 && 1 - x <= y < -(2/3) x + 2, {x, y}];


What you plotted was

RegionPlot[rgn, PlotRange -> {{0, 3}, {0, 2}}]


However, restricting the portion of the region displayed does not change the region. The region defined by the inequalities is larger than the region that you displayed.

RegionPlot[rgn]


g[x_, y_] := 3 x + y^2

Integrate[g[x, y], {x, y} ∈ rgn]

(*  103/4  *)


Restricting the region to that corresponding to the region displayed in the original plot

rgn2 = ImplicitRegion[
0 <= x <= 3 && 0 <= y <= 2 && 1 - x <= y < -(2/3) x + 2, {x, y}];

Integrate[g[x, y], {x, y} ∈ rgn2]

(*  125/12  *)

• Yes. I think I will change to plotting the regions without bounding the variables so I don't overlook this again. (+1) Commented Dec 5, 2015 at 18:45