This is a pre-release version (latest).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy latest / scipy / optimize / _optimize / fminbound

function

scipy.optimize._optimize:fminbound

source: build-install/usr/lib/python3.14/site-packages/scipy/optimize/_optimize.py:2197

Signature

def fminbound(func, x1, x2, args = (), xtol = 1e-05, maxfun = 500, full_output = 0, disp = 1)

Summary

Bounded minimization for scalar functions.

Parameters

func : callable f(x,*args)

Objective function to be minimized (must accept and return scalars).

x1, x2 : float or array scalar

Finite optimization bounds.

args : tuple, optional

Extra arguments passed to function.

xtol : float, optional

The convergence tolerance.

maxfun : int, optional

Maximum number of function evaluations allowed.

full_output : bool, optional

If True, return optional outputs.

disp : int, optional

If non-zero, print messages.

0no message printing.

1non-convergence notification messages only.

2print a message on convergence too.

3print iteration results.

Returns

xopt : ndarray

Parameters (over given interval) which minimize the objective function.

fval : number

(Optional output) The function value evaluated at the minimizer.

ierr : int

(Optional output) An error flag (0 if converged, 1 if maximum number of function calls reached).

numfunc : int

(Optional output) The number of function calls made.

Notes

Finds a local minimizer of the scalar function func in the interval x1 < xopt < x2 using Brent's method. (See brent for auto-bracketing.)

Examples

`fminbound` finds the minimizer of the function in the given range. The following examples illustrate this.
from scipy import optimize
def f(x):
    return (x-1)**2
minimizer = optimize.fminbound(f, -4, 4)
✓
minimizer
✗
np.float64(1.0)
minimum = f(minimizer)
✓
minimum
✗
np.float64(0.0)
res = optimize.fminbound(f, 3, 4, full_output=True)
minimizer, fval, ierr, numfunc = res
✓
minimizer
✗
np.float64(3.000005960860986)
minimum = f(minimizer)
✓
minimum, fval
✗
(np.float64(4.000023843479476), np.float64(4.000023843479476))

See also

minimize_scalar

Interface to minimization algorithms for scalar univariate functions. See the 'Bounded' method in particular.

Aliases

  • scipy.optimize.fminbound

Referenced by