Hi I have a function that has a sharp spike. I need to NIntegrate over the peak but it seems that NIntegrate does not handle it well. Actually as far as I can tell, even the evaluation of the integrand at the location of the peak does not look right. It seems mathematica cannot catch the peak at all...

tmpfuncc[EE_] :=  1/((mtau^2 + mu^2 - (0.1*GeV)^2 - 2*mtau*EE*GeV)^2 + 10^-20)

N[tmpfuncc[(mtau^2 + mu^2 - (0.1*GeV)^2)/2/mtau/GeV], 10]

Out[]= 3.8147*10^-6

NIntegrate[tmpfuncc[EE], {EE, mu/GeV, (mtau^2 + mu^2)/2/mtau/GeV}, WorkingPrecision -> 10]

NIntegrate::slwcon: Numerical integration converging too slowly; suspect one of the following: singularity, value of the integration is 0, highly oscillatory integrand, or WorkingPrecision too small. >>
NIntegrate::ncvb: "NIntegrate failed to converge to prescribed accuracy after 9 recursive bisections in EE near {EE} = {0.888490766789827039531500380004219625181210150361343500025939}. NIntegrate obtained 6.44593788819743726491916378537481240607040208793872845350532`60.*^-33 and 2.6600745931201861160799097164004168287092390168480454978388`60.*^-33 for the integral and error estimates."

The variables are listed below

In[2162]:= mu






Out[2162]= 105660000

Out[2163]= 1776860000

Out[2164]= 1000000000

Out[2165]= [Infinity]

Out[2166]= [Infinity]

Out[2167]= [Infinity]

Any idea about how to improve?


closed as off-topic by MarcoB, Anton Antonov, corey979, m_goldberg, Bob Hanlon Feb 22 '17 at 15:42

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Anton Antonov, corey979, m_goldberg, Bob Hanlon
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ You are explicitly setting the working precision to 10; have you tried increasing it significantly? $\endgroup$ – MarcoB Feb 22 '17 at 3:55
mu = 105660000;
mtau = 1776860000;
GeV = 1000000000;

Use exact numbers when defining tmpfuncc, i.e., 1/10 rather than 0.1

tmpfuncc[EE_] := 1/((mtau^2 + mu^2 - (GeV/10)^2 - 2*mtau*EE*GeV)^2 + 10^-20);

tmpfuncc[(mtau^2 + mu^2 - (GeV/10)^2)/2/mtau/GeV]

(*  100000000000000000000  *)

The integral can be done exactly

int = Integrate[tmpfuncc[EE], {EE, mu/GeV, (mtau^2 + mu^2)/2/mtau/GeV}]

(*  (1/355372000)(ArcTan[100000000000000000000000000] + 
  ArcTan[27829094400000000000000000000])  *)

You can get a numerical approximation to any desired precision

int // N[#, 10] &

(*  8.840293140*10^-9  *)

The working precision in OP's question is too small. Increasing the working precision and min/max recursion gives a result close to that of Bob Hanion's answer.

 tmpfuncc[EE], {EE, mu/GeV, (mtau^2 + mu^2)/2/mtau/GeV}, 
 WorkingPrecision -> 40, PrecisionGoal -> 12, MinRecursion -> 30, 
 MaxRecursion -> 200]

(* 8.840293139554588539520642615458365446312*10^-9 *)

Not the answer you're looking for? Browse other questions tagged or ask your own question.