Message Boards Message Boards

5 Replies
16 Total Likes
View groups...
Share this post:

Integration method used in NIntegrate

Posted 10 years ago

Is in there any way in Mathematica how to find out which integration method was actually used in NIntegrate[f[x],{x,xmin,xmax}] if no method is explicitly specified by user?

POSTED BY: Tomas Rihacek
5 Replies

I updated the notebook with explanations for this discussion with a new section where it is given and explained NIntegrate methods tracing code.

Here is an example output of the tracing (see the notebook for details): enter image description here

POSTED BY: Anton Antonov

I should have given more explanations in my first response in this discussion. The attached notebook has some more detailed answers.

In many cases I find it helpful to look at the sampling points used by NIntegrate. Using the sampling points plots I can figure out which integration strategy and integration rule has been applied -- each integration strategy and integration rule has a unique pattern of sampling points.

The second section of the attached notebook has some examples that demonstrate the previous statement.

One can also use the "NIntegrate Explorer" to build knowledge or proficiency in determining NIntegrate's methods by the plots of the sampling points. See the tutorial example "GUIKit Example: NIntegrate Explorer" in the documentation. (It can be found by searching for "NIntegrateExplorer" in the help browser.)

Further, we can use the undocumented NIntegrate option IntegrationMonitor in order to obtain more detailed information of the integration rules and integrands used. This is demonstrated in the third section.

We can also look at the definition of the default, automatic integration strategy in order to see which methods are applied and in what order. This shown in the fourth section.

The fifth section shows and describes code for tracing the initialization of NIntegrate's methods for the computation of concrete integrals.

POSTED BY: Anton Antonov

In many cases I find it helpful to look at the sampling points used by NIntegrate. Below are some examples:


NIntegrateProfile[NIntegrate[1/Sqrt[x], {x, 0, 1}]]

NIntegrateSamplingPoints[NIntegrate[1/Sqrt[x], {x, 0, 1}]]

 NIntegrate[1/Sqrt[x], {x, 0, 1}, 
  Method -> {"GlobalAdaptive", "SingularityHandler" -> "IMT"}]]

 NIntegrate[1/Sqrt[x], {x, 0, 1}, 
  Method -> {"LocalAdaptive", "SymbolicProcessing" -> 0, 
    "SingularityHandler" -> "IMT"}]]

 NIntegrate[1/Sqrt[x], {x, 0, 1}, 
  Method -> {"GlobalAdaptive", "SingularityDepth" -> 20}]]

 NIntegrate[1/Sqrt[Abs[x]], {x, -2, 1}, 
  Method -> {"GlobalAdaptive", "SingularityDepth" -> 2}]]

  NIntegrate[1/Sqrt[Sin[x]], {x, 0, \[Pi]}, 
    Method -> {"GlobalAdaptive", "SingularityDepth" -> 2}]]
POSTED BY: Anton Antonov
Posted 9 years ago

Dear Anton Antonov,

In your profile you say that you "implemented and documented the framework and integrators of NIntegrate". Based on this I expect that you as the developer of course have all the tools to obtain such a basic information as the method which is automatically chosen by NIntegrate. But your answer confuses me: is "looking at the sampling points" the best way YOU have to find out which method is chosen by NIntegrate? Or may be you cannot say more just because it is a commercial secret? If the latter is true, why is it considered as a commercial secret?

POSTED BY: Alexey Popkov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract