certain multiple integrals should give the same result but do not .
It is a problem in statistical mechanics.
(1) There is no reason to not have the explicit code in the post. It’s simple code.
(2) Integrate gives results consistent with NIntegrate. That’s a fairly strong indication that the two should in fact not give the same result.
Here is the function, rewritten to use Piecewise (which is better suited for use in Integrate and NIntegrate).
f[x_] := Piecewise[{{0,
x < -2}, {a, -2 <= x < -1}, {-1, -1 <= x < 1}, {a, 1 <= x < 2}}]
Here are the computations.
In[21]:= beta1 =
Integrate[
f[x1] f[x2 - x1] f[x3 - x2] f[x3], {x1, -2, 2}, {x2, -2,
2}, {x3, -2, 2}]
Out[21]= 4/3 (4 - 7 a + 13 a^2 - 2 a^3 + 2 a^4)
In[22]:= beta2 =
Integrate[
f[x1] f[x3 - x1] f[x2] f[x3 - x2], {x1, -2, 2}, {x2, -2,
2}, {x3, -6, 6}]
Out[22]= 4/3 (4 - 7 a + 15 a^2 - 3 a^3 + 3 a^4)
Numerical consistency checks:
In[18]:= NIntegrate[
f[x1] f[x2 - x1] f[x3 - x2] f[x3] /. a -> 3.3, {x1, -2, 2}, {x2, -2,
2}, {x3, -6, 6}]
Out[18]= 383.706933333
In[23]:= beta1 /. a -> 3.3
Out[23]= 383.706933333
In[19]:= NIntegrate[
f[x1] f[x3 - x1] f[x2] f[x3 - x2] /. a -> 3.3, {x1, -2, 2}, {x2, -2,
2}, {x3, -6, 6}]
Out[19]= 522.953733333
In[24]:= beta2 /. a -> 3.3
Out[24]= 522.953733333
A couple of things to note. In the case of your 2nd integral, your x3 limits of integration are between -6 and 6 rather than -2 and 2. Changing the limits to all be between -2 and 2 results in identical results in your first two integrals.
One thing that you may be doing which makes it seem that you are getting inconsistent results is choosing your limits of integration to be between -2 and 2. In the convolutions that you are computing the actual expressions in the argument of the integral may have non-zero support outside of those limits. My guess is that the actual integrals should be between -Infinity and Infinity. In that case you will always integrate over the full support of the function. If you do that, your integration results are the same in your two cases.
In[1]:= f[x_] :=
Piecewise[{
{0, x < -2},
{a, -2 < x < -1},
{-1, -1 < x < 1},
{a, 1 < x < 2},
{0, x > 2}
}]
In[2]:= \[Beta]31 =
Integrate[
f[x1] f[x2 - x1] f[x3 - x2] f[
x3], {x1, -\[Infinity], \[Infinity]}, {x2, -\[Infinity], \
\[Infinity]}, {x3, -\[Infinity], \[Infinity]}]
Out[2]= 4/3 (4 - 7 a + 15 a^2 - 3 a^3 + 3 a^4)
In[3]:= \[Beta]31 =
Integrate[
f[x1] f[x3 - x1] f[x2] f[
x3 - x2], {x1, -\[Infinity], \[Infinity]}, {x2, -\[Infinity], \
\[Infinity]}, {x3, -\[Infinity], \[Infinity]}]
Out[3]= 4/3 (4 - 7 a + 15 a^2 - 3 a^3 + 3 a^4)
In[4]:= \[Beta]32 =
Integrate[
f[x1] f[x2 - x1] f[x3 - x1] f[x3 - x2] f[
x3], {x1, -\[Infinity], \[Infinity]}, {x2, -\[Infinity], \
\[Infinity]}, {x3, -\[Infinity], \[Infinity]}]
Out[4]= -(2/3) (7 - 9 a + 20 a^2 - 16 a^3 + 4 a^4)
In[5]:= \[Beta]32 =
Integrate[
f[x1] f[x2 - x1] f[x2] f[x3 - x2] f[
x3], {x1, -\[Infinity], \[Infinity]}, {x2, -\[Infinity], \
\[Infinity]}, {x3, -\[Infinity], \[Infinity]}]
Out[5]= -(2/3) (7 - 9 a + 20 a^2 - 16 a^3 + 4 a^4)