Hi everyone. I’m new in Mathematica and that process take 7-8 hours long. I’ve tried to use Method->“MonteCarlo” and “QuasiMonteCarlo” but it gave nothing at all. Please, give some advice to how can Wolfram count up this process quickly.
It appears you can pull 79*1/137*2/(4/3*3.14*R)*Sinh*E^(y/2)/(4 Sinh[4.197/2]) outside of your NIntegrate and thus potentially avoid having that recalculated many times inside NIntegrate.
It appears you can rewrite Piecewise[{{expr,expression>0},{0,expression<=0}}] as Piecewise[{{expr,expression>0},0}] and save some calculations.
What I think holds most promise is to study the values of R, b, Ri, phi and x to eliminate the Piecewise completely and only integrate over the nonzero part of the integrand. When I look at Reduce[(R^2 - (x + b/2)^2) (R^2 - (b/2 - x)^2) == 0, x] I see that the boundary depends fairly simply on the values of your parameters and I suspect that knowing what the values of your parameters are will make this even simpler..
Take a look here, especially the comments and the links within.
The very first things to try is to turn off symbolic processing using Method → {Automatic, “SymbolicProcessing” → 0} For me this speeds up your integral by an order of magnitude. If that’s not enough, the next step is to Compile[] the integrand. I think you’ll need to rewrite the piecewise as an If[] to make sure compilation gives you optimal performance.
EDIT:
Here’s how to compile to integrand for more efficient evaluation:
This gives another 2-3 times speedup on my machine compared to just turning off symbolic processing. If you reduce the accuracy goal, as you did, it can be sped up even more significantly.