# The difference between “SymbolicProcessing” -> 0 and restricting the function definition to numeric values only

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?

-

f[x_] := (Print[x]; Nest[Sin[# + Sin[2 #]] &, x, 2])

"SymbolicProcessing" doesn't affect whether or not symbolic integration is tried (AFAICT, with NIntegrate, it never is). Rather, preprocessing is aimed at making certain classes of integral easier to deal with numerically. For example, it checks for and tries to remove oscillatory behaviour, splits integrands piecewise and selects a method for each section, transforms integrals over infinite intervals into ones over the unit (hyper)cube, etc. – Oleksandr R. Aug 29 '12 at 10:14