# Why does this triple integral take so long?

How can I compute this triple integral? I tried this but it has been running for a long time and not return result yet.

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

• NIntegrate will give a numerical value (-16.755...) Apr 16 at 20:26
• @mikado that seems right. Someone got -16π/3, why is it hard for Mathematica to get the exact result?
– hana
Apr 16 at 20:29
• @hana If I had to guess (and I would be), because "work over this prism and then test membership in a hemisphere" is harder to work with than "work over this sphere and then test membership in a hemisphere", and that the latter likely makes Mathematica more likely to try certain methods (e.g. it knows a sphere is relevant from the domain specification, so will try spherical coordinates etc.). The domain as a prism doesn't lead it to realize a sphere is present, as that's been coded into the function rather than the domain, so it doesn't try those methods. But, again: just a guess. Apr 17 at 11:53

Integrate[
Boole[x >= 0]*((y - 1)^3/(x^2 + y^2 + z^2 + 1)), {x, y,
z} ∈ Ball[{0, 0, 0}, 2]]


-((16 π)/3)

Changing to spherical polar coordinates gives an answer that agrees numerically

π Integrate[(r^2 Cos[θ] (r Sin[θ] - 1)^3)/(r^2 + 1), {r, 0, 2}, {θ, -π/2, π/2}]
(* -((16 π)/3) *)


But doesn't explain why Mathematica struggles with the Cartesian formulation.