# In mathematica 8

• Mathematica
muppet
MaxErrorIncreases option for NIntegrate in Mathematica 8

Hi all,

I'm trying to do the following integral numerically in Mathematica 8 (defining a function of the parameter b):
$$\int^{\infty}_0 dq q J_0(b q) \left(\left(1-q^2\right)^{3/2} \theta \left(1-q^2\right) \left(\frac{3 q^2+2}{15 q^4}-\frac{\frac{1}{q^2}+\sqrt{1-\frac{1}{q^2}} \tanh ^{-1}\left(\sqrt{1-\frac{1}{q^2}}\right)-1}{\left(1-\frac{1}{q^2}\right)^2 q^2}\right)-\frac{2}{15 q^4}\right)$$

I'm getting the NIntegrate::eincr error message, to the effect that the global error has increased more than 400 times when it's expected to go down with repeated recursive bisections of the integration region. It says that I should be able to work around this by using the method option Method->{GlobalAdaptive,MaxErrorIncreases->10000} to increase the patience of Mathematica in waiting for the oscillatory integral to converge. However, on using this option I'm still getting the same error message, still quoting the default value for MaxErrorIncreases of 400. I'm defining a function

where i[q,b] is just the integrand above, and I get the standard error message when I try and plot it. I tried to test my syntax on the simple example given in the mathematica documentation, but it turns out that it evaluates fine without ever generating that error message

Is this a bug, or am I doing something dumb?

Last edited:

muppet
PostScript: Bizarrely, this option actually works using GlobalAdaptive as a submethod of the "ExtrapolatingOscillatory" method:
seems to be working!

Gold Member
I put in this function into mathematica. What value of "b" are you using that this error occurs?

Code:
FX[b_] := NIntegrate[q BesselJ[0, b q] ((1 - q^2)^(3/2) HeavisideTheta[1 - q^2] ((3 q^2 + 2)/(15 q^4) - (1/q^2 + Sqrt[1 - 1/q^2] ArcTanh[Sqrt[1 - 1/q^2]] - 1)/((1 - 1/q^2)^2 q^2)) - 2/(15 q^4)), {q, 0, \[Infinity]}]

muppet
The problems of large global error seem to occur for b between 0 and 1; in the case of the extrapolating oscillatory method where I can actually change the 'MaxErrorIncreases' option successfully, I'm still getting the error message after increasing this variable from 400 to 500 000 (shortly before my computer runs out of memory). I've no idea why, because I've good reason to think the answer is neither zero nor infinite...

Gold Member
For a high "b" this is a VERY highly oscillatory function. I'm not sure you can trust its convergence numerically. Basically with that theta function, the first integral is only from 0 to 1, which mathematica is telling me doesn't converge algebraically.

If you expand it near "q" is zero, you get 1/q^3 behavior, which is divergent in the integral at q = 0.

muppet
Actually, I think for small q it should vanish like q. I checked in mathematica that the limit as q->0 is 0; the term in brackets (i.e. everything apart from q*J_0(bq)) is a special case of a more general function depending on an additional variable n, which here is set to three, and I have a finite analytic result for the q->0 limit for general n. (It doesn't work if you try and do the integral from 0 to 1 separately, because it depends on a cancellation with the term you integrate over the full region.) This function also behaves for large q like 1/q^4, so I really don't think convergence should be a problem from an analytic point of view, just from a computational one.

Like I say, the problem is really occurring at small values of b, between zero and one. The kinds of algorithms used to evaluate oscillatory integrals over infinite regions I think typically converge faster at higher frequencies, which explains why I'd expect slow convergence at small values of b. The trouble is that it seems to be converging too[\i] slowly to be practicable, and I can't find a way of speeding it up; it was starting from scratch and trying to build up from the default settings that I encountered the problem of not being able to adjust "MaxErrorIncreases" for the default Global Adaptive method.