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:



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:


Unfortunately, I cannot relabel variables in my setup, due to the large number of occurrences of 1-a

  • 2
    $\begingroup$ I'm inclined to say that the warning CompiledFunction::cfsa is unintended, i.e. it's a bug. Since ff[1-a] still returns a CompiledFunction object, f[1-a]/.a->2 should evaluate using compiled code. $\endgroup$
    – QuantumDot
    Oct 1, 2016 at 12:25

1 Answer 1


This is just a warning message, which is issued because 1 - a is not a variable (it is a normal expression with head Plus) and can be suppressed e.g. by setting "WarningMessages" -> False.

Uncompiled evaluation does not take place in

ff[1 - a] /. a -> 2

which can be checked by setting the "RuntimeErrorHandler" option.

  • $\begingroup$ +1, but it's not particularly obvious what counts as a "variable": ff[Sin[x]], ff[BesselJ[0, x]], ff[Sin[-x]], ff[BesselJ[1/2, x]] -- the latter two giving warnings, presumably because they have the head Times (after evaluating). It seems to be whatever expr is accepted by D in D[1, expr]. (Silly example: D[1, Plot[x, {x, 0, 1}]].) $\endgroup$
    – Michael E2
    Oct 1, 2016 at 17:29
  • 1
    $\begingroup$ @MichaelE2 Yes, D (and several other functions) use the same test to determine what might be a variable. It is a heuristic that explicitly forbids several common heads (including List, Plus, Times, Equal, And, ConditionalExpression etc.) but anything else is let through, and no, it hasn't been taught to care about Sin, BesselJ or Plot. $\endgroup$
    – ilian
    Oct 2, 2016 at 16:14
  • $\begingroup$ Do you think this is a bug? $\endgroup$
    – Szabolcs
    Nov 30, 2016 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.