12
$\begingroup$

NIntegrate can do a number of different types of symbolic preprocessing on the integrand before starting the numerical calculations, including changes of variables.

Is there a way to find out what sort of symbolic preprocessing is being done and what is the precise integrand NIntegrate is actually evaluating? For example, is it possible to find out if it does any changes of variables, and if yes, exactly what changes it does?


Motivation: I'm trying to understand what goes wrong here: Why do I get a different value when I change the order of integration? The question describes a simple oscillatory numerical integral in 2D. NIntegrate gives different results depending on the order of integration variables, and no warnings. One result is wrong. Looking at the points sampled by NIntegrate it's clear that Mathematica does a different change of variables depending on the order of integration variables.

$\endgroup$

1 Answer 1

18
$\begingroup$

This does not completely answer the question, but you can get some useful information from the undocumented option IntegrationMonitor. For example:

NIntegrate[Sin[Sqrt[x]], {x, 0, 1}, IntegrationMonitor -> Print]

enter image description here

You can see (in the Experimental`NumericalFunction) that the change of variables $\sqrt{x}\to x$ has been used to convert the integrand to $2 x \sin (x)$, which is then computed using the ClenshawCurtisOscillatoryRule.

Be aware that for complex integrands you will get a lot of output, so Reap/Sow might be better than Print.

$\endgroup$
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.