Reputation: 6854
Let us assume I have a smooth, nonlinear function f: R^n -> R with the (known) maximum number of roots N. How can I find the roots efficiently? Right now I have calculated the function on the grid on a preselected area, refined the grid where the function is below a predefined threshold and continued that routine, but this does not seem to be very efficient, though, because I have noticed that it is difficult to select the area correctly before and to define the threshold accordingly.
Upvotes: 0
Views: 1386
Reputation: 1
You can square the function and use global optimization software to locate all the minima inside a domain and pick those with a zero value. Stochastic multistart based global optimization methods with clustering are quite proper for this task.
Upvotes: 0
Reputation: 1378
there are several ways to go about this of course, scipy is known to contain the safest and most efficient method for finding a single root provided you know the interval: scipy.optimize.brentq
to find more roots using some estimate you can use: scipy.optimize.fsolve
de Moivre's formulae to use for root finding that is fairly quick in comparison to others (in case you would rather build your own method): given a complex number
the n roots are given by:
where k varies over the integer values from 0 to n − 1.
Upvotes: 1