parameters: (fun, bracket=None, bounds=None, args=(),
                      method='brent', tol=None, options=None)
docstring: Minimization of scalar function of one variable.
  
      Parameters
      ----------
      fun : callable
          Objective function.
          Scalar function, must return a scalar.
      bracket : sequence, optional
          For methods 'brent' and 'golden', `bracket` defines the bracketing
          interval and can either have three items ``(a, b, c)`` so that
          ``a < b < c`` and ``fun(b) < fun(a), fun(c)`` or two items ``a`` and
          ``c`` which are assumed to be a starting interval for a downhill
          bracket search (see `bracket`); it doesn't always mean that the
          obtained solution will satisfy ``a <= x <= c``.
      bounds : sequence, optional
          For method 'bounded', `bounds` is mandatory and must have two items
          corresponding to the optimization bounds.
      args : tuple, optional
          Extra arguments passed to the objective function.
      method : str or callable, optional
          Type of solver.  Should be one of:
  
              - 'Brent'     :ref:`(see here) <optimize.minimize_scalar-brent>`
              - 'Bounded'   :ref:`(see here) <optimize.minimize_scalar-bounded>`
              - 'Golden'    :ref:`(see here) <optimize.minimize_scalar-golden>`
              - custom - a callable object (added in version 0.14.0), see below
  
      tol : float, optional
          Tolerance for termination. For detailed control, use solver-specific
          options.
      options : dict, optional
          A dictionary of solver options.
  
              maxiter : int
                  Maximum number of iterations to perform.
              disp : bool
                  Set to True to print convergence messages.
  
          See :func:`show_options()` for solver-specific options.
  
      Returns
      -------
      res : OptimizeResult
          The optimization result represented as a ``OptimizeResult`` object.
          Important attributes are: ``x`` the solution array, ``success`` a
          Boolean flag indicating if the optimizer exited successfully and
          ``message`` which describes the cause of the termination. See
          `OptimizeResult` for a description of other attributes.
  
      See also
      --------
      minimize : Interface to minimization algorithms for scalar multivariate
          functions
      show_options : Additional options accepted by the solvers
  
      Notes
      -----
      This section describes the available solvers that can be selected by the
      'method' parameter. The default method is *Brent*.
  
      Method :ref:`Brent <optimize.minimize_scalar-brent>` uses Brent's
      algorithm to find a local minimum.  The algorithm uses inverse
      parabolic interpolation when possible to speed up convergence of
      the golden section method.
  
      Method :ref:`Golden <optimize.minimize_scalar-golden>` uses the
      golden section search technique. It uses analog of the bisection
      method to decrease the bracketed interval. It is usually
      preferable to use the *Brent* method.
  
      Method :ref:`Bounded <optimize.minimize_scalar-bounded>` can
      perform bounded minimization. It uses the Brent method to find a
      local minimum in the interval x1 < xopt < x2.
  
      **Custom minimizers**
  
      It may be useful to pass a custom minimization method, for example
      when using some library frontend to minimize_scalar.  You can simply
      pass a callable as the ``method`` parameter.
  
      The callable is called as ``method(fun, args, **kwargs, **options)``
      where ``kwargs`` corresponds to any other parameters passed to `minimize`
      (such as `bracket`, `tol`, etc.), except the `options` dict, which has
      its contents also passed as `method` parameters pair by pair.  The method
      shall return an ``OptimizeResult`` object.
  
      The provided `method` callable must be able to accept (and possibly ignore)
      arbitrary parameters; the set of parameters accepted by `minimize` may
      expand in future versions and then these parameters will be passed to
      the method.  You can find an example in the scipy.optimize tutorial.
  
      .. versionadded:: 0.11.0
  
      Examples
      --------
      Consider the problem of minimizing the following function.
  
      >>> def f(x):
      ...     return (x - 2) * x * (x + 2)**2
  
      Using the *Brent* method, we find the local minimum as:
  
      >>> from scipy.optimize import minimize_scalar
      >>> res = minimize_scalar(f)
      >>> res.x
      1.28077640403
  
      Using the *Bounded* method, we find a local minimum with specified
      bounds as:
  
      >>> res = minimize_scalar(f, bounds=(-3, -1), method='bounded')
      >>> res.x
      -2.0000002026
docstring_summary: Minimization of scalar function of one variable.
docstring_tokens: Minimization of scalar function of one variable .
function: def minimize_scalar(fun, bracket=None, bounds=None, args=(),
                      method='brent', tol=None, options=None):
      """Minimization of scalar function of one variable.
  
      Parameters
      ----------
      fun : callable
          Objective function.
          Scalar function, must return a scalar.
      bracket : sequence, optional
          For methods 'brent' and 'golden', `bracket` defines the bracketing
          interval and can either have three items ``(a, b, c)`` so that
          ``a < b < c`` and ``fun(b) < fun(a), fun(c)`` or two items ``a`` and
          ``c`` which are assumed to be a starting interval for a downhill
          bracket search (see `bracket`); it doesn't always mean that the
          obtained solution will satisfy ``a <= x <= c``.
      bounds : sequence, optional
          For method 'bounded', `bounds` is mandatory and must have two items
          corresponding to the optimization bounds.
      args : tuple, optional
          Extra arguments passed to the objective function.
      method : str or callable, optional
          Type of solver.  Should be one of:
  
              - 'Brent'     :ref:`(see here) <optimize.minimize_scalar-brent>`
              - 'Bounded'   :ref:`(see here) <optimize.minimize_scalar-bounded>`
              - 'Golden'    :ref:`(see here) <optimize.minimize_scalar-golden>`
              - custom - a callable object (added in version 0.14.0), see below
  
      tol : float, optional
          Tolerance for termination. For detailed control, use solver-specific
          options.
      options : dict, optional
          A dictionary of solver options.
  
              maxiter : int
                  Maximum number of iterations to perform.
              disp : bool
                  Set to True to print convergence messages.
  
          See :func:`show_options()` for solver-specific options.
  
      Returns
      -------
      res : OptimizeResult
          The optimization result represented as a ``OptimizeResult`` object.
          Important attributes are: ``x`` the solution array, ``success`` a
          Boolean flag indicating if the optimizer exited successfully and
          ``message`` which describes the cause of the termination. See
          `OptimizeResult` for a description of other attributes.
  
      See also
      --------
      minimize : Interface to minimization algorithms for scalar multivariate
          functions
      show_options : Additional options accepted by the solvers
  
      Notes
      -----
      This section describes the available solvers that can be selected by the
      'method' parameter. The default method is *Brent*.
  
      Method :ref:`Brent <optimize.minimize_scalar-brent>` uses Brent's
      algorithm to find a local minimum.  The algorithm uses inverse
      parabolic interpolation when possible to speed up convergence of
      the golden section method.
  
      Method :ref:`Golden <optimize.minimize_scalar-golden>` uses the
      golden section search technique. It uses analog of the bisection
      method to decrease the bracketed interval. It is usually
      preferable to use the *Brent* method.
  
      Method :ref:`Bounded <optimize.minimize_scalar-bounded>` can
      perform bounded minimization. It uses the Brent method to find a
      local minimum in the interval x1 < xopt < x2.
  
      **Custom minimizers**
  
      It may be useful to pass a custom minimization method, for example
      when using some library frontend to minimize_scalar.  You can simply
      pass a callable as the ``method`` parameter.
  
      The callable is called as ``method(fun, args, **kwargs, **options)``
      where ``kwargs`` corresponds to any other parameters passed to `minimize`
      (such as `bracket`, `tol`, etc.), except the `options` dict, which has
      its contents also passed as `method` parameters pair by pair.  The method
      shall return an ``OptimizeResult`` object.
  
      The provided `method` callable must be able to accept (and possibly ignore)
      arbitrary parameters; the set of parameters accepted by `minimize` may
      expand in future versions and then these parameters will be passed to
      the method.  You can find an example in the scipy.optimize tutorial.
  
      .. versionadded:: 0.11.0
  
      Examples
      --------
      Consider the problem of minimizing the following function.
  
      >>> def f(x):
      ...     return (x - 2) * x * (x + 2)**2
  
      Using the *Brent* method, we find the local minimum as:
  
      >>> from scipy.optimize import minimize_scalar
      >>> res = minimize_scalar(f)
      >>> res.x
      1.28077640403
  
      Using the *Bounded* method, we find a local minimum with specified
      bounds as:
  
      >>> res = minimize_scalar(f, bounds=(-3, -1), method='bounded')
      >>> res.x
      -2.0000002026
  
      """
      if not isinstance(args, tuple):
          args = (args,)
  
      if callable(method):
          meth = "_custom"
      else:
          meth = method.lower()
      if options is None:
          options = {}
  
      if tol is not None:
          options = dict(options)
          if meth == 'bounded' and 'xatol' not in options:
              warn("Method 'bounded' does not support relative tolerance in x; "
                   "defaulting to absolute tolerance.", RuntimeWarning)
              options['xatol'] = tol
          elif meth == '_custom':
              options.setdefault('tol', tol)
          else:
              options.setdefault('xtol', tol)
  
      if meth == '_custom':
          return method(fun, args=args, bracket=bracket, bounds=bounds, **options)
      elif meth == 'brent':
          return _minimize_scalar_brent(fun, bracket, args, **options)
      elif meth == 'bounded':
          if bounds is None:
              raise ValueError('The `bounds` parameter is mandatory for '
                               'method `bounded`.')
          # replace boolean "disp" option, if specified, by an integer value, as
          # expected by _minimize_scalar_bounded()
          disp = options.get('disp')
          if isinstance(disp, bool):
              options['disp'] = 2 * int(disp)
          return _minimize_scalar_bounded(fun, bounds, args, **options)
      elif meth == 'golden':
          return _minimize_scalar_golden(fun, bracket, args, **options)
      else:
          raise ValueError('Unknown solver %s' % method)
function_tokens: def minimize_scalar ( fun , bracket = None , bounds = None , args = ( ) , method = 'brent' , tol = None , options = None ) : if not isinstance ( args , tuple ) : args = ( args , ) if callable ( method ) : meth = "_custom" else : meth = method . lower ( ) if options is None : options = { } if tol is not None : options = dict ( options ) if meth == 'bounded' and 'xatol' not in options : warn ( "Method 'bounded' does not support relative tolerance in x; " "defaulting to absolute tolerance." , RuntimeWarning ) options [ 'xatol' ] = tol elif meth == '_custom' : options . setdefault ( 'tol' , tol ) else : options . setdefault ( 'xtol' , tol ) if meth == '_custom' : return method ( fun , args = args , bracket = bracket , bounds = bounds , * * options ) elif meth == 'brent' : return _minimize_scalar_brent ( fun , bracket , args , * * options ) elif meth == 'bounded' : if bounds is None : raise ValueError ( 'The `bounds` parameter is mandatory for ' 'method `bounded`.' ) # replace boolean "disp" option, if specified, by an integer value, as # expected by _minimize_scalar_bounded() disp = options . get ( 'disp' ) if isinstance ( disp , bool ) : options [ 'disp' ] = 2 * int ( disp ) return _minimize_scalar_bounded ( fun , bounds , args , * * options ) elif meth == 'golden' : return _minimize_scalar_golden ( fun , bracket , args , * * options ) else : raise ValueError ( 'Unknown solver %s' % method )