code: def _cubicmin(a, fa, fpa, b, fb, c, fc):
      """
      Finds the minimizer for a cubic polynomial that goes through the
      points (a,fa), (b,fb), and (c,fc) with derivative at a of fpa.
  
      If no minimizer can be found, return None.
  
      """
      # f(x) = A *(x-a)^3 + B*(x-a)^2 + C*(x-a) + D
  
      with np.errstate(divide="raise", over="raise", invalid="raise"):
          try:
              C = fpa
              db = b - a
              dc = c - a
              denom = (db * dc) ** 2 * (db - dc)
              d1 = np.empty((2, 2))
              d1[0, 0] = dc**2
              d1[0, 1] = -(db**2)
              d1[1, 0] = -(dc**3)
              d1[1, 1] = db**3
              [A, B] = np.dot(
                  d1,
                  np.asarray(
                      [fb - fa - C * db, fc - fa - C * dc]
                  ).flatten(),
              )
              A /= denom
              B /= denom
              radical = B * B - 3 * A * C
              xmin = a + (-B + np.sqrt(radical)) / (3 * A)
          except ArithmeticError:
              return None
      if not np.isfinite(xmin):
          return None
      return xmin
  
file_path: catboost/contrib/python/scipy/py3/scipy/optimize/linesearch.py
imports: from warnings import warn
  from scipy.optimize import minpack2
  import numpy
label_desc: Use image node_id 5 for calling a global function with example usage: _cubicmin(a, fa, fpa, b, fb, c, fc) and returns: xmin, None, None