1

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.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
cami
  • 11
  • 3
  • 1
    You have to experiment with the methods and strategies provided with NIntegrate. Check the online manual for more information. – Spawn1701D Apr 15 '13 at 06:37
  • Please provide some codes in your question, so we can exactly know what is your problem. – tenure track job seeker Apr 15 '13 at 06:39
  • @Spawn1701D thank you for your interest! I have tried virtually all methods provided in mathematica documentation, but it seems that my integral doesn't fit into any of the 'patterns' provided there :( – cami Apr 15 '13 at 06:40
  • What version of Mathematica are you using? Can you provide the actual expression? – Spawn1701D Apr 15 '13 at 06:44
  • 1
    Take a look at Advanced Numerical Integration In Mathematica it might give you some pointers. – Spawn1701D Apr 15 '13 at 06:48
  • @Zahra, I have just posted the code. Spawn, I would not have asked here before looking into the tutorial... But you see the limits of the integrations are entangled rather nasty and I cannot see what is the best way to tell mathematica to deal with this. – cami Apr 15 '13 at 06:55
  • At just first look, it seems to me that the problem is with definition of piece[d_,v_]. Probably it is better to seperate Integration, than using If. It might increase the speed of process! – tenure track job seeker Apr 15 '13 at 08:00
  • @Zhara, it takes equally long if I comment out the piece. From investigations I can see that the function is logarithmic so I suspect that perhaps the logarithmic behavior might slow down the integration, but I don't know how to fix it... – cami Apr 15 '13 at 08:04
  • @m_goldberg, thank you for editing the question! do you have an idea how to make the integration more efficient? thank you! – cami Apr 15 '13 at 09:11
  • One thing you could try is turning off symbolic preprocessing. I think you do this by including "SymbolicProcessing"->0 in the Method argument. I've found that symbolic preprocessing can be extremely time consuming if the integrand is complicated or algorithmic (rather than a formula). – Cassini Apr 15 '13 at 13:28
  • @DavidSkulsky, I already did that, as I said I have tried absolutely everything, I just didn't include all my attempts in the code, in the hope that maybe someone will come up with a better idea... There are two things I suspect, first I can see that the results explodes logarithmically, and second the entangling of the variables in the integration limits. But I have no idea how to help mathematica... – cami Apr 15 '13 at 15:53
  • I got to say I gave up doing multidimensional integration using Mathematica long time ago given the lack of importance sampling scheme...see this post for example. I made this decision after trying all possible options and methods provided in NIntegrate as you did. – Leo Fang Jul 31 '13 at 00:23

0 Answers0