The Documentation tells us that there are two ways to disable symbolic processing of the integrand by the NIntegrate
function when it is known that it just slows down the computation. One way is documented and heavily used on the Documentation page "NIntegrate Integration Strategies" and some other Documentation pages:
Method -> {Automatic, "SymbolicProcessing" -> 0}
Another approach is to define the integrand as a "black-box" function and this way is recommended in the "Possible Issues" section of the NIntegrate
documentation page.
Let us compare:
f[x_] := Nest[Sin[# + Sin[2 #]] &, x, 20]
NIntegrate[f[x], {x, 0, 1},
Method -> {Automatic, "SymbolicProcessing" -> 0}] // Timing
(* => {2.797, 0.947747} *)
g[x_?NumericQ] := Nest[Sin[# + Sin[2 #]] &, x, 20]
NIntegrate[g[x], {x, 0, 1}] // Timing
(* => {0.032, 0.947747} *)
One can see the two-order speedup of the "black-box" over the Method
option. What is the reason? Are there cases when the Method
option have advantages over the "black-box" approach? In which cases it is recommended to use one or another?