def _difftrap(function, interval, numtraps):
 if (numtraps <= 0):
  raise ValueError('numtraps must be > 0 in difftrap().')
 elif (numtraps == 1):
  return (0.5 * (function(interval[0]) + function(interval[1])))
 else:
  numtosum = (numtraps / 2)
  h = (float((interval[1] - interval[0])) / numtosum)
  lox = (interval[0] + (0.5 * h))
  points = (lox + (h * np.arange(numtosum)))
  s = np.sum(function(points), axis=0)
  return s

def _difftrap ( function , interval , numtraps ) : if ( numtraps <= 0 ) : raise ValueError ( 'numtraps must be > 0 in difftrap().' ) elif ( numtraps == 1 ) : return ( 0.5 * ( function ( interval [ 0 ] ) + function ( interval [ 1 ] ) ) ) else : numtosum = ( numtraps / 2 ) h = ( float ( ( interval [ 1 ] - interval [ 0 ] ) ) / numtosum ) lox = ( interval [ 0 ] + ( 0.5 * h ) ) points = ( lox + ( h * np . arange ( numtosum ) ) ) s = np . sum ( function ( points ) , axis = 0 ) return s
perform part of the trapezoidal rule to integrate a function .