NIntegrate - why is it much slower in Mathematica 8 in this given case?

后端 未结 3 541
没有蜡笔的小新
没有蜡笔的小新 2021-02-01 10:06

I have a Mathematica code where I have to evaluate numerically thousands of integrals similar to this one

NIntegrate[
    (Pi*Cos[(Pi*(-2*x + y))/(1 + y)] + (1 +         


        
3条回答
  •  后悔当初
    2021-02-01 10:35

    Here is a workaround:

    NIntegrate[(Pi*
          Cos[(Pi*(-2*x + y))/(1 + y)] + (1 + y)*(-Sin[(2*Pi*x)/(1 + y)] +
             Sin[(Pi*(-2*x + y))/(1 + y)]))/(E^x*(1 + y)), {x, 0, 
       100}, {y, 0, 100}, 
      Method -> "AdaptiveMonteCarlo"] // AbsoluteTiming
    

    You can also use ParallelTry to tests various methods in parallel.

    Slowdowns for specific arguments can happen when new methods are implemented or heuristics are modified. Those may help to solve a new class of problems at the expense that some others get slower. One would have to investigate exactly what is going on here.

    You might want to change the topic of your question - it indicates that all integrals evaluate slower in V8 which is not true.

    Edit 1: I think it get's stuck in LevinRule (new in V8 for oscillatory integrands) so, I think, this should switch that off.

    NIntegrate[(Pi*
          Cos[(Pi*(-2*x + y))/(1 + y)] + (1 + y)*(-Sin[(2*Pi*x)/(1 + y)] +
             Sin[(Pi*(-2*x + y))/(1 + y)]))/(E^x*(1 + y)), {x, 0, 
       100}, {y, 0, 100}, 
      Method -> {"SymbolicPreprocessing", 
        "OscillatorySelection" -> False}] // AbsoluteTiming
    

提交回复
热议问题