I am numerically solving an integral equation that contains a double integral. I have managed to get a solution but it takes forever. I am wondering if there is a way to speed up numerical integration of multidimensional integrals.
Here is the code:
First a couple of functions that enter the calculation (if I don't include them, the integration will be faster)
g = Pi
cs[x_] := 2*ArcCos[x]/Sqrt[1 - x^2];
csh[x_] := 2*ArcCosh[x]/Sqrt[x^2 - 1];
pref[t_, v_, d_] :=
1/d^2*(1 + 10^(2*(v - t)) (1 - 1/d^2)) /
Sqrt[1 - 1/4*((10^(2*t) + 10^(2*v))/10^(t + v) - 10^(v - t)/d^2)^2]
piece[d_,v_] :=
If[d Astart[v] < 1, cs[d Astart[v]], If[d Astart[v] > 1, csh[d Astart[v]], 2]]
Here is the actual iteration
Clear[Astart, A, precision, values]
precision = 10^-1;
Astart[t_] = -g*t + 1;
values = ParallelTable[{t,
1 + g/(Pi^3*2)
(NIntegrate[Log[10]*10^(v - t)*pref[t, v, d]*((d^2*Astart[v] - 1)*(Pi - g*piece[d,v]) +
d*Astart[v]*g^2*csh[g])/(d^2*Astart[v]+ g^2 - 1),
{v, -Infinity, 0},
{d, 1/(10^(t - v) + 1), 1/Abs[10^(t - v) - 1]},
WorkingPrecision -> 12,
PrecisionGoal -> 3,
MaxRecursion -> 20,
AccuracyGoal -> 12,
Method -> {"SymbolicPreprocessing", "OscillatorySelection"-> False, "SymbolicProcessing"->0}
])},
{t, Union[Range[-5.6,-1.6, 0.5]~Join~Log10[Range[0.08, 0.98, 0.1]]]}];
A[t_] = Interpolation[Re@values, t, InterpolationOrder -> 2, Method-> "Spline"]
Perhaps I should also mention that this later on iterated into a while loop until convergence is achieved (just to give a better picture on the amount of total waiting time...)
EDIT: I have added in the code also the method the 'fastest' method that I could find, however it still runs for ages... Given the particular form of the integration limits, is there any better trick to help mathematica? Also, by inspection I can see that the result explodes logarithmically which might be another reason why it is so slow.
NIntegrate. Check the online manual for more information. – Spawn1701D Apr 15 '13 at 06:37piece[d_,v_]. Probably it is better to seperate Integration, than usingIf. It might increase the speed of process! – tenure track job seeker Apr 15 '13 at 08:00NIntegrateas you did. – Leo Fang Jul 31 '13 at 00:23