code: def minimize(f, start=None, smooth=False, log=None, array=False, **vargs):
      
      if start is None:
          assert not array, "Please pass starting values explicitly when array=True"
          arg_count = f.__code__.co_argcount
          assert arg_count > 0, "Please pass starting values explicitly for variadic functions"
          start = [0] * arg_count
      if not hasattr(start, '__len__'):
          start = [start]
  
      if array:
          objective = f
      else:
          @functools.wraps(f)
          def objective(args):
              return f(*args)
  
      if not smooth and 'method' not in vargs:
          vargs['method'] = 'Powell'
      result = optimize.minimize(objective, start, **vargs)
      if log is not None:
          log(result)
      if len(start) == 1:
          return result.x.item(0)
      else:
          return result.x
docs: Minimize a function f of one or more arguments.
  
      Args:
          f: A function that takes numbers and returns a number
  
          start: A starting value or list of starting values
  
          smooth: Whether to assume that f is smooth and use first-order info
  
          log: Logging function called on the result of optimization (e.g. print)
  
          vargs: Other named arguments passed to scipy.optimize.minimize
  
      Returns either:
          (a) the minimizing argument of a one-argument function
          (b) an array of minimizing arguments of a multi-argument function