# How to use NIntegrate in a purely numerical mode?

I have a function that is defined as the smallest root of a given polynomial. Something like this:

f[param1_,param2_,param3]:= Module[{roots},
roots = getRoots[param1,param2,param3];
Return[Min[roots]];
]


The function getRootswould build a polynomial and use Solve[] to solve it.

I need to integrate fnumerically, but I keep getting errors:

 NIntegrate::inumr: "The integrand Min[<<1>>] has evaluated to non-numerical values for all sampling points in the region with boundaries {{0,300000}}"


Using Manipulate, I can calculate values along the integration range, that is, the function indeed has numerical values.

I suspect that the symbolic preprocessor tries to analyze the argument of Min[], but it get stuck because the argument is a list of roots of a polynomial.

Since the function f[]can be evaluated numerically, it should be possible to integrate it in a purely numerical way, without the symbolic analysis. Is there any way, any choice of integration method to do that?

-
Try NIntegrate[.., Method -> {Automatic, "SymbolicProcessing" -> False}] and define the function using f[param1_?NumericQ,param2_?NumericQ,param3_?NumericQ]:=...! –  PlatoManiac Oct 21 '13 at 19:04
See also this pitfalls answer, and these q&a linked there: 1, 2, and less closely related 3. –  Michael E2 Oct 23 '13 at 0:39
Did you put a _ after param3 in your real code? As posted here, it seems it shouldn't work. Also, have you checked that e.g. f[1.,2.,3.] returns a number not some more complex expression? –  Ruslan Nov 21 '13 at 10:36

Here is an example: let us take one equation, simple enough for a trial. Let it be

 Clear[x, y];
eq = y^5 - y^3 + x == 0;
sl = Solve[eq, y]


The result is:

(*  {{y -> Root[x - #1^3 + #1^5 &, 1]}, {y ->
Root[x - #1^3 + #1^5 &, 2]}, {y ->
Root[x - #1^3 + #1^5 &, 3]}, {y ->
Root[x - #1^3 + #1^5 &, 4]}, {y -> Root[x - #1^3 + #1^5 &, 5]}}  *)


The first of them, for example, is real at 0<=x<=1. Let us check it:

Plot[sl[[1, 1, 2]], {x, 0, 1}]


Here it is shown:

Now let us integrate:

NIntegrate[sl[[1, 1, 2]], {x, 0, 1}]