6
$\begingroup$

How can I compute this triple integral?

$$I=\underset{V}{\iiint}\frac{(y-1)^3}{x^2+y^2+z^2+1}\,\mathrm dx\,\mathrm dy\,\mathrm dz\qquad V\begin{cases}x^2+y^2+z^2\le 4\\x\ge 0\end{cases}$$

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}]
$\endgroup$
3
  • 1
    $\begingroup$ NIntegrate will give a numerical value (-16.755...) $\endgroup$
    – mikado
    Apr 16 at 20:26
  • 1
    $\begingroup$ @mikado that seems right. Someone got -16π/3, why is it hard for Mathematica to get the exact result? $\endgroup$
    – hana
    Apr 16 at 20:29
  • 2
    $\begingroup$ @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. $\endgroup$
    – Zibadawa
    Apr 17 at 11:53

2 Answers 2

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

-((16 π)/3)

$\endgroup$
1
  • $\begingroup$ In theory, Integrate[(y - 1)^3/(x^2 + y^2 + z^2 + 1), {x, y, z} ∈ RegionIntersection[HalfSpace[{-1, 0, 0}, {0, 0, 0}], Ball[{0, 0, 0}, 2]]] should work just as well, but this version is quite a bit slower than the one in this answer. $\endgroup$ Jun 10 at 14:34
12
$\begingroup$

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.

$\endgroup$
2
  • 2
    $\begingroup$ Using the coordinate transformation functionality of Mathematica: ff = Simplify[((y - 1)^3/(x^2 + y^2 + z^2 + 1) /. Thread[{x, y, z} -> CoordinateTransform["Spherical" -> "Cartesian", {r, φ, θ}]]) CoordinateTransformData["Spherical" -> "Cartesian", "MappingJacobianDeterminant", {r, φ, θ}]]; Integrate[ff, {r, 0, 2}, {φ, 0, π}, {θ, -π/2, π/2}] $\endgroup$ Jun 10 at 14:49
  • $\begingroup$ Although I did not try, version 13.1 has IntegrateChangeVariables as can be checked from this page $\endgroup$ Oct 11 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.