I would like to pass a CompiledFunction
to a FindRoot
algorithm and therefore I use the option RuntimeOptions -> "EvaluateSymbolically" -> False
. For example:
ff = Compile[x, x, RuntimeOptions -> "EvaluateSymbolically" -> False]
As expected and as demanded, the function does not evaluate when passing a non-numerical argument:
ff[a]
CompiledFunction[..][a]
However, when passing "1-a" the following warning appears:
ff[1 - a]
CompiledFunction::cfsa: Argument 1-a at position 1 should be a machine-size real number. >>
My question: Does MMA now use an uncompiled evaluation when returning:
ff[1-a]/.a->2
Unfortunately, I cannot relabel variables in my setup, due to the large number of occurrences of 1-a
CompiledFunction::cfsa
is unintended, i.e. it's a bug. Sinceff[1-a]
still returns aCompiledFunction
object,f[1-a]/.a->2
should evaluate using compiled code. $\endgroup$