Module root

Source
Expand description

Bracketed scalar root finding with guaranteed convergence.

find_root is Brent’s method (inverse quadratic interpolation, the secant step, and bisection), as in Brent, Algorithms for Minimization without Derivatives (1973), chapter 4, and OCCT math_BracketedRoot. An interpolation step is accepted only if it is less than half the step before last and stays inside the bracket; otherwise the step bisects. Convergence is therefore guaranteed for any continuous function with a sign change, in at most about the square of the bisection count and in practice far fewer.

The answer is a bracket, not a point: the function changes sign across [lower, upper] (or vanishes exactly at x), so for a continuous function a root lies inside and |x - root| <= upper - lower.

Structs§

Root
A root located inside a sign-change bracket.

Functions§

find_root
Find a root of f in [lower, upper] by Brent’s method.