NIntegrate w/ MaxErrorIncreases in Mathematica 8

  • Mathematica
  • Thread starter muppet
  • Start date
  • Tags
    Mathematica
In summary, the conversation discusses the "MaxErrorIncreases" option for the NIntegrate function in Mathematica 8. The user is attempting to numerically evaluate an integral with an oscillatory integrand and is getting an error message about the global error increasing. They have tried using the recommended option to increase the patience of Mathematica, but it does not seem to be working. They also tried using a different method, "ExtrapolatingOscillatory", and adjusting the "MaxErrorIncreases" option, which seems to work better. However, they are still experiencing slow convergence at small values of the parameter "b". They believe the convergence issue is more of a computational problem rather than an analytic one.
  • #1
muppet
608
1
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):
[tex]\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)[/tex]

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

maxerrinc[b_]:=NIntegrate[i[q,b],{q,0,Infinity}, Method->{"GlobalAdaptive",MaxErrorIncreases->10000}, MaxRecursion->100]

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 :rolleyes:

Is this a bug, or am I doing something dumb?
Thanks in advance.
 
Last edited:
Physics news on Phys.org
  • #2
PostScript: Bizarrely, this option actually works using GlobalAdaptive as a submethod of the "ExtrapolatingOscillatory" method:
extosc[b_]:=NIntegrate[i[q,b],{q,0,Infinity},Method->{"ExtrapolatingOscillatory",Method->{"GlobalAdaptive",MaxErrorIncreases->100000}},MaxRecursion->50]
seems to be working!
 
  • #3
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]}]
 
  • #4
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...
 
  • #5
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.
 
  • #6
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.
 

What is NIntegrate w/ MaxErrorIncreases in Mathematica 8?

NIntegrate w/ MaxErrorIncreases is a function in Mathematica 8 that allows the user to specify a maximum number of error increases during the integration process. This can be useful for highly oscillatory or difficult to integrate functions.

How do I use NIntegrate w/ MaxErrorIncreases?

To use NIntegrate w/ MaxErrorIncreases, simply include the option "MaxErrorIncreases" in your NIntegrate command and specify the desired maximum number of error increases. For example, NIntegrate[f[x], {x, a, b}, MaxErrorIncreases -> 10] will perform the integration with a maximum of 10 error increases.

What is the default value for MaxErrorIncreases?

The default value for MaxErrorIncreases is 100. This means that if the integration process reaches 100 error increases, it will stop and return the current approximation of the integral.

Can I adjust the value of MaxErrorIncreases during the integration process?

Yes, you can dynamically adjust the value of MaxErrorIncreases during the integration process using the option "EvaluationMonitor". This allows you to increase or decrease the maximum error increases based on the progress of the integration.

Are there any potential drawbacks to using NIntegrate w/ MaxErrorIncreases?

Using MaxErrorIncreases can potentially slow down the integration process and may not always improve the accuracy of the result. It is important to experiment with different values to find the optimal balance between speed and accuracy for your specific function.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
34
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
270
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
Back
Top