def _qnwtrap1(n, a, b):
 if (n < 1):
  raise ValueError('n must be at least one')
 nodes = np.linspace(a, b, n)
 dx = (nodes[1] - nodes[0])
 weights = (dx * np.ones(n))
 weights[0] *= 0.5
 weights[(-1)] *= 0.5
 return (nodes, weights)

def _qnwtrap1 ( n , a , b ) : if ( n < 1 ) : raise ValueError ( 'n must be at least one' ) nodes = np . linspace ( a , b , n ) dx = ( nodes [ 1 ] - nodes [ 0 ] ) weights = ( dx * np . ones ( n ) ) weights [ 0 ] *= 0.5 weights [ ( - 1 ) ] *= 0.5 return ( nodes , weights )
compute univariate trapezoid rule quadrature nodes and weights parameters n : int the number of nodes a : int the lower endpoint b : int the upper endpoint returns nodes : np .