I am trying to reproduce my mathematica code in java, the problem is that I use FindRoot to solve either equations or non linear systems of equations (3*3 speciically).

For example

f[x_] := Exp[-l]*l^x/x!;
FindRoot[Sum[f[i], {i, 0, 5}] == 0.45, {l, 5}]

Out[4]= {l -> 5.97316}

I am trying to figure out what numerical method is used by FindRoot in order to search Java for an already implemented library.

I suspect that Newton Raphson is used, but what happens with function's derivate?

  • 3
    $\begingroup$ The Documentation Center page tutorial/tutorial/SomeNotesOnInternalImplementation#7441 in Version 11.2 says: "FindRoot uses a damped Newton's method, the secant method, and Brent's method." Good luck trying to port the proprietary internal implementation of FindRoot to a different language using that vague description! $\endgroup$ – murray Oct 10 '17 at 13:55
  • 2
    $\begingroup$ This might be of interest: reference.wolfram.com/language/tutorial/… $\endgroup$ – Michael E2 Oct 10 '17 at 14:01
  • 2
    $\begingroup$ Or more generally, the Unconstrained Optimization Tutorial. $\endgroup$ – Szabolcs Oct 10 '17 at 14:19
  • 2
    $\begingroup$ Root finding is a fairly standard mathematical problem and you should have no problem finding a Java implementation of any of the common root finding algorithms. I would recommend you look for Brent's method because it's very stable. The only disadvantage is that it needs a bracket to start. You can look it up on Wikipedia. $\endgroup$ – Sjoerd Smit Oct 10 '17 at 16:03
  • $\begingroup$ @SjoerdSmit thanks for your reply. Can I use it for systems too? I have found apache commons math library but its not straightforward, neither explains whether it solves systems or not. $\endgroup$ – Fierce82 Oct 10 '17 at 17:06

Your Answer

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

Browse other questions tagged or ask your own question.