# Integration method used in NIntegrate

**URL:** <https://community.wolfram.com/t/integration-method-used-in-nintegrate/2885>\
**Category:** Questions\
**Tags:** mathematica, calculus, numerical-computation\
**Created:** [August 7, 2014, 5:52pm UTC](https://community.wolfram.com/t/integration-method-used-in-nintegrate/2885 "2014-08-07T17:52:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rihacek](https://avatars.discourse-cdn.com/v4/letter/r/f0a364/32.png) [@rihacek](https://community.wolfram.com/u/rihacek)\
**Post date:** [August 7, 2014, 5:52pm UTC](https://community.wolfram.com/t/integration-method-used-in-nintegrate/2885/1 "2014-08-07T17:52:04Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/szhorvat/32/3531_2.png) [@szhorvat](https://community.wolfram.com/u/szhorvat)\
**Post date:** [August 7, 2014, 6:33pm UTC](https://community.wolfram.com/t/integration-method-used-in-nintegrate/2885/2 "2014-08-07T18:33:02Z")

</div>

This is a good question.

These are related posts:

[http://mathematica.stackexchange.com/questions/26401/determining-which-rule-nintegrate-selects-automatically](http://mathematica.stackexchange.com/questions/26401/determining-which-rule-nintegrate-selects-automatically)  
[http://mathematica.stackexchange.com/questions/41504/is-there-a-way-to-see-the-result-of-nintegrates-symbolic-preprocessing](http://mathematica.stackexchange.com/questions/41504/is-there-a-way-to-see-the-result-of-nintegrates-symbolic-preprocessing)

---

<div class="post-metadata">

**Author:** ![antononcube](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/antononcube/32/7348_2.png) [@antononcube](https://community.wolfram.com/u/antononcube)\
**Post date:** [October 13, 2014, 1:32am UTC](https://community.wolfram.com/t/integration-method-used-in-nintegrate/2885/3 "2014-10-13T01:32:36Z")

</div>

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

```
Needs["Integration`NIntegrateUtilities`"]

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

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

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

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

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

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

NIntegrateSamplingPoints[
  NIntegrate[1/Sqrt[Sin[x]], {x, 0, \[Pi]}, 
    Method -> {"GlobalAdaptive", "SingularityDepth" -> 2}]]

```

---

<div class="post-metadata">

**Author:** ![lehinp](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/lehinp/32/8056_2.png) [@lehinp](https://community.wolfram.com/u/lehinp)\
**Post date:** [October 15, 2014, 2:58pm UTC](https://community.wolfram.com/t/integration-method-used-in-nintegrate/2885/4 "2014-10-15T14:58:56Z")

</div>

Dear Anton Antonov,

In your [profile](http://community.wolfram.com/web/antononcube) 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?

---

<div class="post-metadata">

**Author:** ![antononcube](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/antononcube/32/7348_2.png) [@antononcube](https://community.wolfram.com/u/antononcube)\
**Post date:** [October 16, 2014, 4:02pm UTC](https://community.wolfram.com/t/integration-method-used-in-nintegrate/2885/5 "2014-10-16T16:02:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![antononcube](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/antononcube/32/7348_2.png) [@antononcube](https://community.wolfram.com/u/antononcube)\
**Post date:** [November 4, 2015, 12:41pm UTC](https://community.wolfram.com/t/integration-method-used-in-nintegrate/2885/6 "2015-11-04T12:41:05Z")

</div>

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

 ![ScreenShot2015-11-04at7.33.34AM.png](https://global.discourse-cdn.com/wolfram/original/3X/8/5/85f9b1efe73caacbaf6a37a27af07b591280af96.png)
