optimization - Finding multiple roots on an interval with Python -


i'm looking efficient method find roots of function f on interval [a,b]. problem have nice methods scipy.optimize require either f(a) , f(b) have different signs, or provide initial guess x0, know nothing roots before running code.

note: function f smooth (at least c1), , doesn't have pathological behaviour [nothing sin(1/x)]. however, requires building matrix a(x) , finding eigenvalues, , therefore time-consuming. expected have between 0 , 10 roots on [a,b], position arbitrary. can't afford missing of them (e.g. can't take 100 initial guesses x0 , hope i'll catch roots).

i thinking implementing this:

  1. find extrema {m_1, m_2.., m_k} of f scipy.optimize [maybe fmin, don't know method efficient]:
    • search minimum m_1 starting point [initial guess gradient algorithm]
    • search maximum m_2 starting point m_1 + dx [forcing gradient algorithm go forward]
    • search minimum m_3...
  2. if 2 consecutive extrema m_i , m_(i+1) have opposite signs, apply brentq on interval [m_i, m_(i+1)] find root.

  • is there better way of solving problem?

  • if not, fmin , brentq best choices among scipy.optimize library in order minimize number of calls function f?

one "usual" approach find approximant function, root finding easy, , find roots of approximant.

for instance, can sample function values @ number of points, fit spline points, , find roots of spline (which easy problem). @ least provide initial guesses roots.

the more tricky part determining sampling points. if know function c1, can sample more densely @ points function appears non-smooth, based on function values. needed years back, here's heuristic cooking approach problem way: https://gist.github.com/pv/acc71bafede0a84b074c7751985ecc6f worked me, ymmv.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -