bisec_fast

paminco.utils.bisec.bisec_fast(func, tol=0.01, lo=0, up=1, exclude_lo=False, exclude_up=False, val_constr=None, debug=False)[source]

Use the bisection method to find a root of func between lo and up.

Parameters
funccallable

Objective function.

tolfloat, default=1e-02

The tolerance for a solution, i.e., x is a solution if |func(x)| < tol.

lofloat, default=0

The lower end of the interval.

upfloat, default=1

The upper end of the interval. if func(lo) and func(up) do NOT have different signs, the method tries to increase up until this holds. If this is not possible a RuntimeException is raised.

exclude_lobool, default=False

Flag to exclude the lower bound from the solution space.

exclude_upbool, default=False

Flag to exclude the upper bound from the solution space.

val_constrstr, optional
Constraints for the value of the solution. Possible values:
  • None : every solution x with | func(x) | < tol is a solution

  • 'npos' : only x with func(x) <= 0 are solutions

  • 'nneg' : only x with func(x) >= 0 are solutions

debugbool, default=False

If True, the function prints debug information to stdout.

Returns
type

TODO

Notes

Assumes that func is a continuous function. Throws an exception if no up can be found s.t. func(lo) and func(up) do not have different signs