Is there a minimum execution time for the command FindRoot? If so, can I get rid of it?

For example, if I compute the time to solve the fundtion x=0, it takes around 0.27ms per evaluation:

In[581]:= AbsoluteTiming[Do[FindRoot[x, {x, 300}], {try, 1, 100}]]

Out[581]= {0.0270027, Null}

However, this is virtually the same time as it takes to solve a much more complex equation system {x=0,y=0,z=0}

In[580]:= AbsoluteTiming[Do[FindRoot[{x, y, z}, {{x, 300}, {y, 300}, {z, 300}}], {try, 1, 100}]]

Out[580]= {0.0280028, Null}

Since I am running findroot many times (the actual system is more complicated), I care about this "fixed" running cost. Is there a way to get rid of it?


1 Answer 1

AbsoluteTiming[Do[FindRoot[x, {x, 300}, Method -> "Secant"], {100}]]

Returns less than half the time of

AbsoluteTiming[Do[FindRoot[x, {x, 300}], {100}]]

Method, MaxIterations, and Jacobian are options that possibly have a faster alternative than "Automatic". If modifying these doesn't make it, you need to make your own findroot[] algorithm

If you use MachinePrecision, you should add Compiled -> True


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.