1
$\begingroup$

This question already has an answer here:

How to compile this function or any function that uses lists and Part[] ?

f[x_?NumberQ] := FindRoot[x == Sin[t] - t, {t, 1}][[1, -1]];
$\endgroup$

marked as duplicate by halirutan Jun 16 '18 at 1:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    $\begingroup$ FindRoot is not compilable: Compile`CompilerFunctions[] // Sort $\endgroup$ – Ulrich Neumann Jun 13 '18 at 8:47
  • $\begingroup$ Also, when you call it like this, FindRoot is probably/hopefully sufficiently optimized that you won't gain anything by Compileing. $\endgroup$ – Marius Ladegård Meyer Jun 13 '18 at 20:19
  • 1
    $\begingroup$ I closed this as a duplicate of our "list of compilable functions" post. There is really not much more to say except that in basically all cases, you should not try to put FindRoot in a compiled function. There might be some rare exceptions but usually, it is a bad idea. In general, you should be concerned about the speed of the function you want to find the roots for. If you have a very complex expression that can be compiled, then this might be worth a shot. $\endgroup$ – halirutan Jun 16 '18 at 1:35

Browse other questions tagged or ask your own question.