# Help in NIntegration Methods - Takes too long, why?

I have this code. It is a triple integral, and using the automatic method gives me a wrong answer for $T=0.1$ (the correct answer is $5.44$, while I got $3.73$ ). I've tried to change the integral method to GaussKronrodRule, but it takes too long (until now, hours) and also I received a message

Return::nofunc: Function Module not found enclosing Return[False,Module].ParallelDeveloperQueueRun::hmm: Received unexpected result .

And for $T > 1$ gives the correct results, in the automatic method mode. I think it is a problem in the method of NIntegrate, right ?

1) How can I solve that ?

2) In Fortran, I have a gausslegendre method. Is this option available in Mathematica?

σ = 0.6;

minroot[g_?NumericQ,b_?NumericQ]:=
Module[{rts,r},
rts=r/.Solve[1-(b/r)^2-g^-2*(2/15*σ^9 (1/(r-1)^9-1/(r+1)^9-9/(8r)
(1/(r-1)^8-1/(r+1)^8))-σ^3 (1/(r-1)^3-1/(r+1)^3-3/(2r)
(1/(r-1)^2-1/(r+1)^2)))==0,r];
rts=Select[rts,With[{nval=N[#,100]},Im[nval]==0&&nval>0]&];
Max[rts]];

aA[g_?NumberQ,b_?NumberQ,i_]:=Pi-2 b
NIntegrate[
1/(r^2*Sqrt[1-(b/r)^2-g^-2*(2/15* σ^9 (1/(r-1)^9-1/(r+1)^9-9/(8r) (1/(r-1)^8-1/(r+1)^8)) -
σ^3 (1/(r-1)^3 - 1/(r+1)^3-3/(2r) (1/(r-1)^2-1/(r+1)^2)))]),
{r,minroot[g,b],Infinity},
Exclusions->
{r^2*Sqrt[1-(b/r)^2-g^-2*(2/15*σ^9 (1/(r-1)^9-1/(r+1)^9-9/(8r) (1/(r-1)^8- 1/(r+1)^8))-
σ^3 (1/(r-1)^3-1/(r+1)^3-3/(2r) (1/(r-1)^2-  1/(r+1)^2)))]==0},
MaxRecursion->i,Method->{Automatic,"SymbolicProcessing"->0}];

qQ[g_?NumberQ,i_]:=
NIntegrate[2*(1-Cos[aA[g,b,i]]) b,
{b,0,10},
MaxRecursion->i, Method-> {Automatic,"SymbolicProcessing"->0}];

o[T_,i_,j_]:=
(1/T^3) NIntegrate[(g^5*qQ[g,i])/E^(g^2/T),
{g,0,Infinity},
MaxRecursion->j,
Method->{Automatic,"SymbolicProcessing"->0}];

• You might be able to answer your problem if you study the page here. – Ted Ersek Jul 13 '13 at 19:06
• @TedErsek , do you think that is a problem only about the integration method ? – Lucas G Leite F Pollito Jul 13 '13 at 19:26

## 1 Answer

Go to the NIntegrate documentation, then from that page go to Options -> Methods -> Integration Rules, scroll to the bottom of Integration Rules, and there are examples that suggest NIntegrate will use a Cartesian product of Gaussian points if you used Method->{“GaussKronrodRule”,”GaussKronrodRule”,”GaussKronrodRule”} It seems you did that in Fortran except with MaxRecursion->0 assuming you didn't use Kronrod's extension. However, GaussKronrodRule may not be a good method for your problem. You will find MonteCarlo methods implemented in Mma here and here. MonteCarlo methods are good for quadrature in multiple dimensions when a few digits of precision are needed. Earlier I sent you here. That describes some advanced methods that can be used for quadrature in multiple dimensions. I am not familiar those methods, I don’t have access to Mma today and I haven’t had a close look at the function you want to integrate. Hence I can’t be much more help.

• that didnt help, because it take hours to solve , and i didnt have this time ... really i cant wait, so i abort the command evaluate after 1 hour .. any ideas ? – Lucas G Leite F Pollito Jul 15 '13 at 0:59