In the innermost integral Integrate[ Boole[x <= y + w + z], {w, 0, x}]
is purely symbolic since Integrate
does not know what is x
neither y
and z
, consequently Boole
cannot be evaluated, and at last there is an improper result. What is behind the scene can be noticed acting with Trace
on the nested integrals. This seems to be rather an improper usage of Integrate
, nonetheless there shouldn't appear such issues.
However if we are going to exploit Boole
we have to calculate a multiple integral in an appropriate order:
Integrate[ Boole[x <= y + w + z], {x, 0, 1}, {y, 0, x}, {z, 0, x}, {w, 0, x}]
5/24
If one necessarily needs nested integrals then we have to supersede Boole[x <= y + w + z]
with e.g. UnitStep[y + w + z - x]
or HeavisideTheta[y + w + z - x]
Integrate[
Integrate[
Integrate[
Integrate[ UnitStep[y + w + z - x], {w, 0, x}],
{z, 0, x}],
{y, 0, x}],
{x, 0, 1}]
5/24
Nonetheless it takes much more time to evaluate, on my computer AbsoluteTiming
is 15.2524
, however using Integrate
once it takes 0.864271
while with Boole
it is 0.212867
, even worse timing with HeavisideTheta
. There are instances where HeavisideTheta
is more efficient than Boole
e.g. Double integral over the region enclosed by several lines
Having said that it is remarkable to notice that the most efficient way seems to be one using ImplicitRegion
(since version 10.0
of the system)
AbsoluteTiming[
IR = ImplicitRegion[ x <= y + w + z && 0 <= x <= 1 &&
0 <= y <= x && 0 <= w <= x && 0 <= z <= x, {x, y, w, z}];
Integrate[1, {x, y, w, z} ∈ IR]]
{0.0102903, 5/24}
This ensures that the newer method if quite reliable unlike at the times when it just had appeared, see e.g. answers in Finding length of intersection of two surfaces.
In[417]:= Integrate[ Integrate[ Integrate[ Integrate[Boole[x <= y + w + z], {w, 0, x}, Assumptions -> {0 < z < x, 0 < y < x, 0 < x < 1}], {z, 0, x}, Assumptions -> {0 < y < x, 0 < x < 1}], {y, 0, x}, Assumptions -> {0 < x < 1}], {x, 0, 1}] Out[417]= 5/24
$\endgroup$