# Supposedly same integral gives different results

I need to compute the number $$\sigma_U$$ for every open bounded subset of $$n$$-dimensional Euclidean space defined as

$$\sigma_U=\iint_Ud(x,y)\mathrm dx\mathrm dy$$

How can I compute this?

For $$n=1$$, at first I thought that, if we define reg as a valid region, for example, reg = RegionUnion[Interval[{-3,-1}], Interval[{1,3}]], then

Integrate[Abs[x-y],{x,y} ∈ RegionProduct[reg,reg]]


and

Integrate[Integrate[Abs[x-y], {x} ∈ reg], {y} ∈ reg]


would result in the same value, but they don't, so, which is it?

I believe it is the latter, but I thought that the first one results in the same value. Thanks.

• In what sense is the result of the second integral problematic? Also, you haven't specify reg, yet. – Henrik Schumacher Jan 21 '19 at 12:43
• Does Integrate[ Integrate[Abs[x - y], {x} ∈ reg, Assumptions -> {y} ∈ reg], {y} ∈ reg] give the same answer as Integrate[Abs[x-y],{x,y} ∈ RegionProduct[reg,reg]]? – Chip Hurst Jan 21 '19 at 14:59
• @HenrikSchumacher reg could be, for example, RegionUnion[Interval[{-3,-1}],Interval[{1,3}]], which gives different answers, one says its $24$, and the other one $112/3$. – Garmekain Jan 21 '19 at 17:10
• @ChipHurst Check the previous comment. It does give different results for the given example. – Garmekain Jan 21 '19 at 17:13
• Please write a title that actually applies to your specific problem and which will help others find it and its associated answers. – David G. Stork Jan 21 '19 at 18:30

Not an answer, just some observations that take up too much room for a comment.

Integrate and NIntegrate give two different answers. Since your integral evaluates to a number, it is always easy to do a spot check on the symbolics side of the house:

Integrate[Abs[x-y],{x,y} ∈ RegionProduct[reg,reg]]
(* 24 *)

NIntegrate[Abs[x-y],{x,y} ∈ RegionProduct[reg,reg]]
(* 37.3333 = N[112/3] *)


Your second integral didn't evaluate cleanly for me until a let MMA know y was a real number for the inner integral.

 Assuming[y∈Reals,Integrate[Integrate[Abs[x - y],{x}∈reg],{y}∈reg]]
(*  112/3 *)


The plot of the region rp=RegionProduct[reg,reg] is a little odd, although the area computation comes out right. Couldn't figure out if the clipped corners are an artifact or not. Doesn't seem like enough area to make up the difference between 24 and 37.333, but suggests something odd is going on behind the curtain.

 Area[rp]
(* 16 *)
Region[rp, PlotRange -> All] Both integrals do fine if the function is just 1.

 Integrate[1, {x, y} ∈ rp]
Integrate[Integrate[Abs[x - y],{x}∈reg],{y}∈reg]
(* 16 *)

• I don't get those clippings using RegionPlot[RegionProduct[reg,reg]], but yes, something odd is happening, I also tried using Norm instead of Abs, but I get the same results. – Garmekain Jan 21 '19 at 18:11
• II am using v11.3.0.0, just for reference. – MikeY Jan 21 '19 at 18:13
• My version is 10.0.0.0 – Garmekain Jan 21 '19 at 18:14