(index, **kwargs)
return C1Scheme("Newton-Cotes (open)", degree, weights, points)
Open Newton-Cotes formulae.
    <https://math.stackexchange.com/a/1959071/36678>
Open Newton-Cotes formulae.
    <https://math.stackexchange.com/a/1959071/36678>
Open Newton - Cotes formulae . <https : // math . stackexchange . com / a / 1959071 / 36678 >
def newton_cotes_open(index, **kwargs):
    """
    Open Newton-Cotes formulae.
    <https://math.stackexchange.com/a/1959071/36678>
    """
    points = np.linspace(-1.0, 1.0, index + 2)[1:-1]
    degree = index if (index + 1) % 2 == 0 else index - 1
    #
    n = index + 1
    weights = np.empty(n - 1)
    t = sympy.Symbol("t")
    for r in range(1, n):
        # Compare with get_weights().
        f = sympy.prod([(t - i) for i in range(1, n) if i != r])
        alpha = (
            2
            * (-1) ** (n - r + 1)
            * sympy.integrate(f, (t, 0, n), **kwargs)
            / (math.factorial(r - 1) * math.factorial(n - 1 - r))
            / n
        )
        weights[r - 1] = alpha
    return C1Scheme("Newton-Cotes (open)", degree, weights, points)
def newton_cotes_open ( index , * * kwargs ) : points = np . linspace ( - 1.0 , 1.0 , index + 2 ) [ 1 : - 1 ] degree = index if ( index + 1 ) % 2 == 0 else index - 1 # n = index + 1 weights = np . empty ( n - 1 ) t = sympy . Symbol ( "t" ) for r in range ( 1 , n ) : # Compare with get_weights(). f = sympy . prod ( [ ( t - i ) for i in range ( 1 , n ) if i != r ] ) alpha = ( 2 * ( - 1 ) ** ( n - r + 1 ) * sympy . integrate ( f , ( t , 0 , n ) , * * kwargs ) / ( math . factorial ( r - 1 ) * math . factorial ( n - 1 - r ) ) / n ) weights [ r - 1 ] = alpha return C1Scheme ( "Newton-Cotes (open)" , degree , weights , points )