code: def bracket(
      func, xa=0.0, xb=1.0, args=(), grow_limit=110.0, maxiter=1000
  ):
      """Given a function and distinct initial points, search in the downhill
      direction (as defined by the initital points) and return new points
      xa, xb, xc that bracket the minimum of the function:
      f(xa) > f(xb) < f(xc). It doesn't always mean that obtained solution will satisfy xa<=x<=xb
  
      :Parameters:
  
      func -- objective func
      xa, xb : number
          bracketing interval
      args -- additional arguments (if present)
      grow_limit : number
          max grow limit
      maxiter : number
          max iterations number
  
      :Returns: xa, xb, xc, fa, fb, fc, funcalls
  
      xa, xb, xc : number
          bracket
      fa, fb, fc : number
          objective function values in bracket
      funcalls : number
          number of function evaluations
      """
      _gold = 1.618034
      _verysmall_num = 1e-21
      fa = func(*(xa,) + args)
      fb = func(*(xb,) + args)
      if fa < fb:  # Switch so fa > fb
          dum = xa
          xa = xb
          xb = dum
          dum = fa
          fa = fb
          fb = dum
      xc = xb + _gold * (xb - xa)
      fc = func(*((xc,) + args))
      funcalls = 3
      iter = 0
      while fc < fb:
          tmp1 = (xb - xa) * (fb - fc)
          tmp2 = (xb - xc) * (fb - fa)
          val = tmp2 - tmp1
          if abs(val) < _verysmall_num:
              denom = 2.0 * _verysmall_num
          else:
              denom = 2.0 * val
          w = xb - ((xb - xc) * tmp2 - (xb - xa) * tmp1) / denom
          wlim = xb + grow_limit * (xc - xb)
          if iter > maxiter:
              raise RuntimeError("Too many iterations.")
          iter += 1
          if (w - xc) * (xb - w) > 0.0:
              fw = func(*((w,) + args))
              funcalls += 1
              if fw < fc:
                  xa = xb
                  xb = w
                  fa = fb
                  fb = fw
                  return xa, xb, xc, fa, fb, fc, funcalls
              elif fw > fb:
                  xc = w
                  fc = fw
                  return xa, xb, xc, fa, fb, fc, funcalls
              w = xc + _gold * (xc - xb)
              fw = func(*((w,) + args))
              funcalls += 1
          elif (w - wlim) * (wlim - xc) >= 0.0:
              w = wlim
              fw = func(*((w,) + args))
              funcalls += 1
          elif (w - wlim) * (xc - w) > 0.0:
              fw = func(*((w,) + args))
              funcalls += 1
              if fw < fc:
                  xb = xc
                  xc = w
                  w = xc + _gold * (xc - xb)
                  fb = fc
                  fc = fw
                  fw = func(*((w,) + args))
                  funcalls += 1
          else:
              w = xc + _gold * (xc - xb)
              fw = func(*((w,) + args))
              funcalls += 1
          xa = xb
          xb = xc
          xc = w
          fa = fb
          fb = fc
          fc = fw
      return xa, xb, xc, fa, fb, fc, funcalls
  
imports: import numpy
  from numpy import atleast_1d, eye, mgrid, argmin, zeros, shape, empty, squeeze, isscalar, vectorize, asarray, absolute, sqrt, Inf, asfarray, isinf
  from mystic import linesearch
  from collections.abc import Callable
  import builtins
label_desc: Use image node_id 24 for calling a global function with example usage: bracket(func, xa, xb, args, grow_limit, maxiter) and returns: xa,  xb,  xc,  fa,  fb,  fc,  funcalls, xa,  xb,  xc,  fa,  fb,  fc,  funcalls, xa,  xb,  xc,  fa,  fb,  fc,  funcalls