verry.optimize.branchbound_scalar#
- verry.optimize.branchbound_scalar(fun, domain, fprime=True, xtol=inf, ytol=0.0, max_iter=16)#
Find the minimum of the univariate scalar-valued function by repeatedly dividing the interval.
- Parameters:
fun (Callable) – Function to be optimized.
domain (Interval) – Interval in which to search for the minimum value.
fprime (Callable | bool, optional) – Derivative of fun (the default is
deriv(fun)
). If fprime isFalse
, The differentiability of fun is not assumed.xtol (default=inf) – Absolute tolerance.
ytol (default=0.0) – Relative tolerance.
max_iter (int, default=16) – Maximum number of iterations.
- Returns:
r0 (Interval) – Interval containing the minimum value.
r1 (list[Interval]) – Intervals at which fun may take a minimum value.
Warning
fun must be a \(C^1\)-function on domain if fprime is not
False
. Futhermore, fun must neither be a constant nor contain conditional branches (cf. Common pitfalls).See also
Examples
>>> from verry import FloatInterval as FI >>> y, x = branchbound_scalar(lambda x: x**3 - 2 * x + 3, FI(0, 2)) >>> print(format(y, ".3f")) [1.911, 1.912] >>> print(format(x[0], ".3f")) [0.816, 0.817]