3
votes

Why does Modelica's nonlinear solver Modelica.Math.Nonlinear.solveOneNonlinearEquation take more time to solve a nonlinear equation than traditional fixed point iterative (FPI) scheme? The equation

y= arctan(1-x/1+x)-x 

solved by the solveOneNonlinearEquation solver (which basically uses Brent's Method) solves the above equation in 6 iterations whereas traditional iterative approach takes 111 iterations. However, the CPU time taken by the iterative scheme is lesser than that taken by the solveOneNonlinearEquation solver (see image).

Why is this? Could be due to computational efficiency of the iterative scheme i.e., to say lesser event generation in the iterative scheme?

CPU Time of nonlinear equation solved by Brent's method (solveOneNonlinearEquation solver) and typical fixed point iterative (FPI) scheme

1
I guess you mean Modelica.Math.Nonlinear.solveOneNonlinearEquation with oneSolveNonlinearEquation, right?marco
Yes it basically uses Brent's methodsairam.nagareddy

1 Answers

6
votes

The different root finding methods have different properties. Convergence speed is just one, and it can be counted in number of iterations, or in CPU time. Both will greatly depend on start values, curvature and monotonicity of the function, bounds, cost to evaluate the function, availability of analytic derivatives etc.. Other interesting properties could be guarantee of convergence, or whether derivatives are required.
The Wikipedia article on root finding algorithms gives a good overview of the advantages and disadvantages of the different methods:

If one method works much better than others for your special case, you should just implement and use it! Be careful when benchmarking, it is very easy to find examples where each method can shine. For this reason, you should test each algorithm on a variety of functions, maybe 10 different ones, and each one with different intervals. Bisection will perform worse for the same function but larger start interval. Brent is a good and proven method, that is why it is used in the MSL. You could even think about sending a Pull Request to the MSL and add alternatives.