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 getRoots
would build a polynomial and use Solve[]
to solve it.
I need to integrate f
numerically, 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?
NIntegrate[.., Method -> {Automatic, "SymbolicProcessing" -> False}]
and define the function usingf[param1_?NumericQ,param2_?NumericQ,param3_?NumericQ]:=...
! $\endgroup$_
afterparam3
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? $\endgroup$