code: def toms748(
      f,
      a,
      b,
      args=(),
      k=1,
      xtol=_xtol,
      rtol=_rtol,
      maxiter=_iter,
      full_output=False,
      disp=True,
  ):
      """
      Find a zero using TOMS Algorithm 748 method.
  
      Implements the Algorithm 748 method of Alefeld, Potro and Shi to find a
      zero of the function `f` on the interval `[a , b]`, where `f(a)` and
      `f(b)` must have opposite signs.
  
      It uses a mixture of inverse cubic interpolation and
      "Newton-quadratic" steps. [APS1995].
  
      Parameters
      ----------
      f : function
          Python function returning a scalar. The function :math:`f`
          must be continuous, and :math:`f(a)` and :math:`f(b)`
          have opposite signs.
      a : scalar,
          lower boundary of the search interval
      b : scalar,
          upper boundary of the search interval
      args : tuple, optional
          containing extra arguments for the function `f`.
          `f` is called by ``f(x, *args)``.
      k : int, optional
          The number of Newton quadratic steps to perform each
          iteration. ``k>=1``.
      xtol : scalar, optional
          The computed root ``x0`` will satisfy ``np.allclose(x, x0,
          atol=xtol, rtol=rtol)``, where ``x`` is the exact root. The
          parameter must be nonnegative.
      rtol : scalar, optional
          The computed root ``x0`` will satisfy ``np.allclose(x, x0,
          atol=xtol, rtol=rtol)``, where ``x`` is the exact root.
      maxiter : int, optional
          If convergence is not achieved in `maxiter` iterations, an error is
          raised. Must be >= 0.
      full_output : bool, optional
          If `full_output` is False, the root is returned. If `full_output` is
          True, the return value is ``(x, r)``, where `x` is the root, and `r` is
          a `RootResults` object.
      disp : bool, optional
          If True, raise RuntimeError if the algorithm didn't converge.
          Otherwise, the convergence status is recorded in the `RootResults`
          return object.
  
      Returns
      -------
      x0 : float
          Approximate Zero of `f`
      r : `RootResults` (present if ``full_output = True``)
          Object containing information about the convergence. In particular,
          ``r.converged`` is True if the routine converged.
  
      See Also
      --------
      brentq, brenth, ridder, bisect, newton
      fsolve : find zeroes in N dimensions.
  
      Notes
      -----
      `f` must be continuous.
      Algorithm 748 with ``k=2`` is asymptotically the most efficient
      algorithm known for finding roots of a four times continuously
      differentiable function.
      In contrast with Brent's algorithm, which may only decrease the length of
      the enclosing bracket on the last step, Algorithm 748 decreases it each
      iteration with the same asymptotic efficiency as it finds the root.
  
      For easy statement of efficiency indices, assume that `f` has 4
      continuouous deriviatives.
      For ``k=1``, the convergence order is at least 2.7, and with about
      asymptotically 2 function evaluations per iteration, the efficiency
      index is approximately 1.65.
      For ``k=2``, the order is about 4.6 with asymptotically 3 function
      evaluations per iteration, and the efficiency index 1.66.
      For higher values of `k`, the efficiency index approaches
      the kth root of ``(3k-2)``, hence ``k=1`` or ``k=2`` are
      usually appropriate.
  
      References
      ----------
      .. [APS1995]
         Alefeld, G. E. and Potra, F. A. and Shi, Yixun,
         *Algorithm 748: Enclosing Zeros of Continuous Functions*,
         ACM Trans. Math. Softw. Volume 221(1995)
         doi = {10.1145/210089.210111}
  
      Examples
      --------
      >>> def f(x):
      ...     return (x**3 - 1)  # only one real root at x = 1
  
      >>> from scipy import optimize
      >>> root, results = optimize.toms748(f, 0, 2, full_output=True)
      >>> root
      1.0
      >>> results
            converged: True
                 flag: 'converged'
       function_calls: 11
           iterations: 5
                 root: 1.0
      """
      if xtol <= 0:
          raise ValueError("xtol too small (%g <= 0)" % xtol)
      if rtol < _rtol / 4:
          raise ValueError("rtol too small (%g < %g)" % (rtol, _rtol))
      maxiter = operator.index(maxiter)
      if maxiter < 1:
          raise ValueError("maxiter must be greater than 0")
      if not np.isfinite(a):
          raise ValueError("a is not finite %s" % a)
      if not np.isfinite(b):
          raise ValueError("b is not finite %s" % b)
      if a >= b:
          raise ValueError(
              "a and b are not an interval [{}, {}]".format(a, b)
          )
      if not k >= 1:
          raise ValueError("k too small (%s < 1)" % k)
  
      if not isinstance(args, tuple):
          args = (args,)
      solver = TOMS748Solver()
      result = solver.solve(
          f,
          a,
          b,
          args=args,
          k=k,
          xtol=xtol,
          rtol=rtol,
          maxiter=maxiter,
          disp=disp,
      )
      x, function_calls, iterations, flag = result
      return _results_select(
          full_output, (x, function_calls, iterations, flag)
      )
  
imports: import warnings
  from collections import namedtuple
  import operator
  from .None import _zeros
  import numpy
label_desc: Use image node_id 16 for calling a global function with example usage: toms748(f, a, b, args, k, xtol, rtol, maxiter, full_output, disp) and returns: _results_select