# Same integral, NIntegrate gives two different results?

They're the same integral - the bottom integral is simply the top one split up using the identity $$\log(xy) = \log(x) + \log(y)$$. But the results aren't the same. Why?

Code for top integral:

NIntegrate[Exp[Log[Abs[(a - b) (a - c) (b - c) (a - 1) (b - 1) (c - 1)]] +
Log[Abs[a b c]] + 1/2 (-6 (a - b)^2 -
2 (a + b - 2 c)^2 - (a + b + c - 3)^2 - (a + b + c +
1)^2)] Boole[a <= b <= c <= 0], {a, -Infinity, 0}, {b, -Infinity, 0}, {c, -Infinity, 0}]


Code for bottom integral:

NIntegrate[ Exp[Log[Abs[a]] + Log[Abs[a - b]] + Log[Abs[b]] + Log[Abs[a - c]] +
Log[Abs[b - c]] + Log[Abs[c]] + Log[Abs[a - 1]] +
Log[Abs[b - 1]] + Log[Abs[c - 1]] + Log[Abs[1]] +
1/2 (-6 (a - b)^2 -
2 (a + b - 2 c)^2 - (a + b + c - 3 )^2 - (a + b + c +
1)^2)] Boole[a <= b <= c <= 0], {a, -Infinity, 0}, {b, -Infinity, 0}, {c, -Infinity, 0}]


The result seems so much like nonsense that I was sure there was a typo in the two expressions, but I checked that the two are equal using FullSimplify[top integrand - bottom integrand] (need to take out the Exp command for this to evaluate quickly, though). That leaves a numerical effect somewhere, and the fact that I need to not exponentiate both integrands to calculate the FullSimplify + the fact the bottom integral takes significantly longer to evaluate than the top one + the error message in the bottom integration certainly looks like a numerical effect, but I can't see what could possibly cause the numerical effect.

• Is this related? mathematica.stackexchange.com/questions/147906/… – DiSp0sablE_H3r0 Feb 3 at 10:05
• Well, it does give a warning. Try NIntegrate[ Exp[Log[Abs[a]] + Log[Abs[a - b]] + Log[Abs[b]] + Log[Abs[a - c]] + Log[Abs[b - c]] + Log[Abs[c]] + Log[Abs[a - 1]] + Log[Abs[b - 1]] + Log[Abs[c - 1]] + Log[Abs[1]] + 1/2 (-6 (a - b)^2 - 2 (a + b - 2 c)^2 - (a + b + c - 3)^2 - (a + b + c + 1)^2)] (*Boole[a\[LessEqual]b\[LessEqual]c\[LessEqual]0]*), \ {a, -Infinity, 0}, {b, -Infinity, a}, {c, -Infinity, b}], which is a more efficient formulation, too. – Michael E2 Feb 3 at 20:54
• Specifying the singularities due to Boole helps immensely: NIntegrate[ Exp[Log[Abs[a]] + Log[Abs[a - b]] + Log[Abs[b]] + Log[Abs[a - c]] + Log[Abs[b - c]] + Log[Abs[c]] + Log[Abs[a - 1]] + Log[Abs[b - 1]] + Log[Abs[c - 1]] + Log[Abs[1]] + 1/2 (-6 (a - b)^2 - 2 (a + b - 2 c)^2 - (a + b + c - 3)^2 - (a + b + c + 1)^2)] Boole[a <= b <= c <= 0], {a, -Infinity, 0}, {b, -Infinity, a, 0}, {c, -Infinity, b, 0}] – Michael E2 Feb 3 at 20:55

Not an answer but some analysis :

Some definitions to keep things easy to read:

exp1 = Log[Abs[(a - b) (a - c) (b - c) (a - 1) (b - 1) (c - 1)]];

exp2 = Log[Abs[a - b]] + Log[Abs[a - c]] + Log[Abs[b - c]] +
Log[Abs[a - 1]] + Log[Abs[b - 1]] + Log[Abs[c - 1]];

exp3 = Log[Abs[a b c]];

exp4 = Log[Abs[a]] + Log[Abs[b]] + Log[Abs[c]];

const = 1/
2 (-6 (a - b)^2 -
2 (a + b - 2 c)^2 - (a + b + c - 3)^2 - (a + b + c + 1)^2);


Now notice that exp1 and exp2 are expected to be equivalent. So are exp3 and exp4. The following code illustrates some issue with the equivalence of exp3 and exp4 during numerical integration.

In[29]:= NIntegrate[
Exp[exp3 + const] Boole[a <= b <= c <= 0], {a, -Infinity,
0}, {b, -Infinity, 0}, {c, -Infinity, 0}]

Out[29]= 2.73624*10^-7

In[30]:= NIntegrate[
Exp[exp4 + const] Boole[a <= b <= c <= 0], {a, -Infinity,
0}, {b, -Infinity, 0}, {c, -Infinity, 0}]

Out[30]= 2.73624*10^-7


(* Same as expected *)

In[31]:= NIntegrate[
Exp[exp1 + const] Boole[a <= b <= c <= 0], {a, -Infinity,
0}, {b, -Infinity, 0}, {c, -Infinity, 0}]

Out[31]= 3.92715*10^-7

In[32]:= NIntegrate[
Exp[exp2 + const] Boole[a <= b <= c <= 0], {a, -Infinity,
0}, {b, -Infinity, 0}, {c, -Infinity, 0}]

Out[32]= 3.92715*10^-7


(* Same as expected *)

In[33]:= NIntegrate[
Exp[exp1 + exp3 + const] Boole[a <= b <= c <= 0], {a, -Infinity,
0}, {b, -Infinity, 0}, {c, -Infinity, 0}]

Out[33]= 9.66421*10^-9

In[34]:= NIntegrate[
Exp[exp2 + exp4 + const] Boole[a <= b <= c <= 0], {a, -Infinity,
0}, {b, -Infinity, 0}, {c, -Infinity, 0}]

During evaluation of In[34]:= NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small.

Out[34]= 1.51034*10^-9


(* Ouch here it is ! *)

In[35]:= NIntegrate[
Exp[exp2 + exp3 + const] Boole[a <= b <= c <= 0], {a, -Infinity,
0}, {b, -Infinity, 0}, {c, -Infinity, 0}]

Out[35]= 9.66421*10^-9


(* This seems to be fine *)

May be a bug then ??