code: def _difftrap(function, interval, numtraps):
      """
      Perform part of the trapezoidal rule to integrate a function.
      Assume that we had called difftrap with all lower powers-of-2
      starting with 1. Calling difftrap only returns the summation
      of the new ordinates. It does _not_ multiply by the width
      of the trapezoids. This must be performed by the caller.
          'function' is the function to evaluate (must accept vector arguments).
          'interval' is a sequence with lower and upper limits
                     of integration.
          'numtraps' is the number of trapezoids to use (must be a
                     power-of-2).
      """
      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
  
imports: from __future__ import annotations
  from typing import TYPE_CHECKING, Callable, Dict, Tuple, Any, cast
  import functools
  import numpy
  import math
  import types
  import warnings
  from numpy import trapz
  from scipy.special import roots_legendre
  from scipy.special import gammaln
label_desc: Use image node_id 15 for calling a global function with example usage: _difftrap(function, interval, numtraps) and returns: unknown, s