parameters: (xk, f, epsilon, args=(), f0=None)
return_statement: return grad
docstring: See ``approx_fprime``.  An optional initial function value arg is added.
docstring_summary: See ``approx_fprime``.  An optional initial function value arg is added.
docstring_tokens: See approx_fprime . An optional initial function value arg is added .
function: def _approx_fprime_helper(xk, f, epsilon, args=(), f0=None):
      """
      See ``approx_fprime``.  An optional initial function value arg is added.
  
      """
      if f0 is None:
          f0 = f(*((xk,) + args))
      grad = numpy.zeros((len(xk),), float)
      ei = numpy.zeros((len(xk),), float)
      for k in range(len(xk)):
          ei[k] = 1.0
          d = epsilon * ei
          grad[k] = (f(*((xk + d,) + args)) - f0) / d[k]
          ei[k] = 0.0
      return grad
function_tokens: def _approx_fprime_helper ( xk , f , epsilon , args = ( ) , f0 = None ) : if f0 is None : f0 = f ( * ( ( xk , ) + args ) ) grad = numpy . zeros ( ( len ( xk ) , ) , float ) ei = numpy . zeros ( ( len ( xk ) , ) , float ) for k in range ( len ( xk ) ) : ei [ k ] = 1.0 d = epsilon * ei grad [ k ] = ( f ( * ( ( xk + d , ) + args ) ) - f0 ) / d [ k ] ei [ k ] = 0.0 return grad