4
$\begingroup$

I have to perform definite integration of function of this kind :

f[x_, y_, z_, h_, θ_]=(7695 h x^2 y^2 z^6 Sin[2 θ])/(2 π (h^2 + x^2 + y^2)^(
                      5/2) (h^2 + x^2 + y^2 + 2 h z + z^2)^8);

the integration range is:

$x\in ]-\infty, \infty[$

$y\in ]-\infty, \infty[$

$z\in [0, \infty[$

i know that mathematica looks at all the possible singular points and such during the integration, therefore i perform first the integration along x and y with the following assumptions:

Assuming[θ ∈ Reals && h ∈ Reals && h > 0 && 
  x ∈ Reals && y ∈ Reals && z ∈ Reals && 
  z > 0, Integrate[(7695 h x^2 y^2 z^6 Sin[2 θ])/(
  2 π (h^2 + x^2 + y^2)^(
   5/2) (h^2 + x^2 + y^2 + 2 h z + z^2)^8), {x, -Infinity, 
   Infinity}, {y, -Infinity, Infinity}]]

However, the integration is taking way more than 30 minutes (actually none has finished because i'm getting frustrated and abort the computation before it is finished...). The computational time it's defenitely too much for me (as i need to evaluate many of that); do you have any suggestion to speed up the integration?

(feel free to say if you think i should post the question in the mathematics forum)

$\endgroup$

2 Answers 2

9
$\begingroup$

Converting to polar coordinates helps with the xy integral:

Assuming[θ ∈ Reals && h ∈ Reals && h > 0 && x ∈ Reals && y ∈ Reals && z ∈ Reals && z > 0,
 Integrate[((7695 h x^2 y^2 z^6 Sin[2 θ]) / 
   (2 π (h^2 + x^2 + y^2)^(5/2) (h^2 + x^2 + y^2 + 2 h z + z^2)^8) /.
      {x -> r Cos[t], y -> r Sin[t]}) * r,
  {r, 0, Infinity}, {t, 0, 2 Pi}]]
(*
  (1/(32768 (h + z)^16))2565 h z^6 ((1287 π (h + z)^20 (1 + (56 h^4)/(h + z)^4 +
   (28 h^2)/(h + z)^2))/(z (2 h + z))^(19/2) + (1/(35 (-1 + h^2/(h + z)^2)^9))
   2 h (528395 + (1024 h^12)/(h + z)^12 - (11136 h^10)/(h + z)^10 +
   (58624 h^8)/(h + z)^8 - (212256 h^6)/(h + z)^6 + (741384 h^4)/(h + z)^4 +
   (2722790 h^2)/(h + z)^2 + (45045 (h + z)^2 (1 + (56 h^4)/(h + z)^4 +
   (28 h^2)/(h + z)^2) ArcSin[h/(h + z)])/(h Sqrt[z (2 h + z)]))) Sin[2 θ]
*)

(It took less than 6 seconds.)

$\endgroup$
1
  • 3
    $\begingroup$ Sometimes, I think people who have to deal with this sort of stuff really need to develop a sense of when an integrand is screaming for a change in coordinates… $\endgroup$ Commented May 21, 2015 at 19:50
4
$\begingroup$

Doing the z integration first it takes less than a minute to run

Timing[ Assuming[\[Theta]\[Element]Reals&&h\[Element]Reals&&h>0&&x\[Element]Reals&&y\[Element]Reals&&z\[Element]Reals&&z>0, Integrate[r*Integrate[(7695*h*x^2*y^2*z^6*Sin[2*\[Theta]])/(2*Pi*(h^2 + x^2 + y^2)^(5/2)*(h^2 + x^2 + y^2 + 2*h*z + z^2)^8), {z, 0, Infinity}] /. {x -> r*Cos[t], y -> r*Sin[t]}, {r, 0, Infinity}, {t, 0, 2*Pi}]]]

returning

(* 513*(-157264851 + 110960640*Pi + 97476540*Log[4] + 194953080*Log[h] + (1/Sqrt[Pi])*(14336*(5*MeijerG[{{1/2, 3/2}, {1}}, {{0, 1/2, 4}, {}}, 1] + 140*MeijerG[{{1/2, 5/2}, {1}}, {{0, 1/2, 5}, {}}, 1] + 630*MeijerG[{{1/2, 7/2}, {1}}, {{0, 1/2, 6}, {}}, 1] + 924*MeijerG[{{1/2, 9/2}, {1}}, {{0, 1/2, 7}, {}}, 1] + 429*MeijerG[{{1/2, 11/2}, {1}}, {{0, 1/2, 8}, {}}, 1])))*Sin[2*\[Theta]] *)

The result is kind of useless, since MeijerG[{{1/2, 3/2}, {1}}, {{0, 1/2, 4}, {}}, 1] etc. does not even exist. This type of integrals are too hard to do with Integrate and NIntegrate. You need specialized software to do this.

So the minimal frightening (actually buggy) example is

Integrate[(r^5*z^6*Cos[t]^2*Sin[t]^2)/ ((1 + r^2*Cos[t]^2 + r^2*Sin[t]^2)^(5/2)*(1 + 2*z + z^2 + r^2*Cos[t]^2 + r^2*Sin[t]^2)^8), {r, 0, Infinity}, {t, 0, 2*Pi}, {z, 0, Infinity}]

which returns

(1/286720)*(Pi*((52421617 - 32492180*Log[4])/1024 + (1/(3*Sqrt[Pi]))*(14*(5*MeijerG[{{-(5/2), 1}, {3/2}}, {{0, 1/2, 1}, {}}, 1] + 140*MeijerG[{{-(5/2), 2}, {5/2}}, {{0, 3/2, 2}, {}}, 1] + 630*MeijerG[{{-(5/2), 3}, {7/2}}, {{0, 5/2, 3}, {}}, 1] + 924*MeijerG[{{-(5/2), 4}, {9/2}}, {{0, 7/2, 4}, {}}, 1] + 429*MeijerG[{{-(5/2), 5}, {11/2}}, {{0, 9/2, 5}, {}}, 1]))))

which you cannot numerically evaluate.

$\endgroup$
3
  • $\begingroup$ I am sure there is a nonzero number of people who'd flee in terror after seeing the $G$- function pop up (not part of that group, tho). :D $\endgroup$ Commented May 22, 2015 at 0:40
  • $\begingroup$ @Guesswhoitis. I think it's all the fractions that seem to always accompany it. Hmm, Mathematica might be in that group: ans // FullSimplify yields several messages of the form "MeijerG::hdiv: MeijerG[{{-(5/2),1},{3/2}},{{0,1/2,1},{}},1] does not exist. Arguments are not consistent." Maybe one per $G$. Ditto for ans // N. $\endgroup$
    – Michael E2
    Commented May 22, 2015 at 10:39
  • $\begingroup$ @Michael, sometimes the fractions indicate that it's actually hypergeometric in disguise. Now, if I may conjecture here, it seems to me that the "nonsensical" $G$ terms indicate a failure to properly reassemble the inverse Mellin transform from a complicated sum of ratios of gammas. (Recall that Meijer $G$ is defined as the inverse Mellin transform of a suitable ratio of gamma functions.) $\endgroup$ Commented May 22, 2015 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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