# NIntegrate fails to converge

I am trying to compute this integral for different a with 0.0001<a<0.5,

 int[a_?NumericQ, r_?NumericQ]:=NIntegrate[Exp[-a/Sqrt[1-x^2]]/(x^2-r^2)^2, {x, 0, r, 1},Method ->"PrincipalValue"]


where 0<r<1. For high a, the calculation don't display errors,

int[100, 0.8]
(*  1.1619041*10^-44  *)


But for a={0.1,0.01,0.0001} I get this message error.

int[0.1, 0.8]


NIntegrate::inumri: The integrand E^(-(0.1/Sqrt[1-Power[<<2>>]]))/(-0.64+(0.8 -x)^2)^2+E^(-(0.1/Sqrt[1-Power[<<2>>]]))/(-0.64+(0.8 +x)^2)^2 has evaluated to Overflow, Indeterminate, or Infinity for all sampling points in the region with boundaries {{0.,2.7247563*10^-30}}.

I still can't control the accuracy of the calculation. I proceeded by increasing WorkingPrecision, PrecisionGoal, MaxRecursion but it gives each time different values, I do not even know if it gives the true value.

Please, how to increase the precision of this computation?

• Maybe this could help: mathematica.stackexchange.com/questions/16254/… Oct 3, 2018 at 8:18
• I already tried with Method ->"PrincipalValue" included in my code, thank you @Ofek. Oct 3, 2018 at 8:30
• For a near 0, you are effectively trying to evaluate the integral of $1/(x-r)^2$. No wonder it goes south. Oct 3, 2018 at 9:04
• Exectute this code:Integrate[ Exp[-a/Sqrt[1 - x^2]]/(x^2 - r^2)^2 /. r -> 1/2 /. a -> 1/10, {x, 0, 1}] then you see the answer ? Oct 3, 2018 at 19:24
• "not the correct value" - do you have a reference for this integral, and why you expect the answer to be finite? Oct 4, 2018 at 2:55

Looking at the lowest order terms of the Laurant series of the integrand reveals that there are two issues:

Series[Exp[-a/Sqrt[1 - x^2]]/(x^2 - r^2)^2, {x, r, -1}] // Simplify


$$\frac{e^{-\frac{a}{\sqrt{1-r^2}}}}{4 r^2 (x-r)^2}-\frac{e^{-\frac{a}{\sqrt{1-r^2}}} \left(a r^2+\left(1-r^2\right)^{3/2}\right)}{4 \left(r^3 \left(1-r^2\right)^{3/2}\right) (x-r)}+O\left((x-r)^0\right)$$

The first issue is that the $$(x-r)^{-2}$$ term is not integrable, even not int he principle values sense: It is even so that terms on the left and on the right of the singularity at $$x=r$$ cannot cancel. The second issue is that term $$(x-r)^{-1}$$ term is integrable in the principal values sense but that the integration domain lies entirely to the left of the singularity $$x = r$$; so cancellation also cannot happen.

The only reason why int[100, 0.8] the terms $$e^{-\frac{a}{\sqrt{1-r^2}}}$$ are numerically so dominant: At $$x = r$$, you get numerically $$\frac{0}{0}$$ and at the first quadrature point to the left of $$x =r$$ you get numerically $$0$$ for the integrand. That might be the reason why NIntegrate decided to evaluate to 0. It could also be that NIntegrate uses a quadrature rule in this case that does not use interval boundaries as quadrature points (because you warned it that there might be a singularity).

• Thank you @Schumacher, so this integral never converges? Oct 3, 2018 at 19:09
• That's what I tried to explain, yes. Oct 3, 2018 at 19:10
• Serious problem! Oct 3, 2018 at 19:15
• lol. Yes. Fortunately, not mine ;) Oct 3, 2018 at 19:17
• Thank you @Schumacher. ;) Oct 3, 2018 at 19:20