triqs.utility.dichotomy.dichotomy
- triqs.utility.dichotomy.dichotomy(function, x_init, y_value, precision_on_y, delta_x, max_loops=1000, x_name='', y_name='', verbosity=1)[source]
Finds \(x\) that solves \(y = f(x)\).
Starting at
x_init
, which is used as the lower upper/bound, dichotomy finds first the upper/lower bound by adding/subtractingdelta_x
. Then bisection is used to refine \(x\) untilabs(f(x) - y_value) < precision_on_y
ormax_loops
is reached.- Parameters:
function (function, real valued) – Function \(f(x)\). It must take only one real parameter.
x_init (double) – Initial guess for x. On success, returns the new value of x.
y_value (double) – Target value for y.
precision_on_y (double) – Stops if
abs(f(x) - y_value) < precision_on_y
.delta_x (double) – \(\Delta x\) added/subtracted from
x_init
until the second bound is found.max_loops (integer, optional) – Maximum number of loops (default is 1000).
x_name (string, optional) – Name of variable x used for printing.
y_name (string, optional) – Name of variable y used for printing.
verbosity (integer, optional) – Verbosity level.
- Returns:
(x,y) – \(x\) and \(y=f(x)\). Returns (None, None) if dichotomy failed.
- Return type:
(double, double)