(index, **kwargs)
return C1Scheme("Newton-Cotes (closed)", degree, weights, points)
Closed Newton-Cotes formulae.
    <https://en.wikipedia.org/wiki/Newton%E2%80%93Cotes_formulas#Closed_Newton.E2.80.93Cotes_formulae>,
    <http://mathworld.wolfram.com/Newton-CotesFormulas.html>.
Closed Newton-Cotes formulae.
    <https://en.wikipedia.org/wiki/Newton%E2%80%93Cotes_formulas#Closed_Newton.E2.80.93Cotes_formulae>,
    <http://mathworld.wolfram.com/Newton-CotesFormulas.html>.
Closed Newton - Cotes formulae . <https : // en . wikipedia . org / wiki / Newton%E2%80%93Cotes_formulas#Closed_Newton . E2 . 80 . 93Cotes_formulae > <http : // mathworld . wolfram . com / Newton - CotesFormulas . html > .
def newton_cotes_closed(index, **kwargs):
    """
    Closed Newton-Cotes formulae.
    <https://en.wikipedia.org/wiki/Newton%E2%80%93Cotes_formulas#Closed_Newton.E2.80.93Cotes_formulae>,
    <http://mathworld.wolfram.com/Newton-CotesFormulas.html>.
    """
    points = np.linspace(-1.0, 1.0, index + 1)
    degree = index + 1 if index % 2 == 0 else index

    # Formula (26) from
    # <http://mathworld.wolfram.com/Newton-CotesFormulas.html>.
    # Note that Sympy carries out all operations in rationals, i.e.,
    # _exactly_. Only at the end, the rational is converted into a float.
    n = index
    weights = np.empty(n + 1)
    t = sympy.Symbol("t")
    for r in range(n + 1):
        # Compare with get_weights().
        f = sympy.prod([(t - i) for i in range(n + 1) if i != r])
        alpha = (
            2
            * (-1) ** (n - r)
            * sympy.integrate(f, (t, 0, n), **kwargs)
            / (math.factorial(r) * math.factorial(n - r))
            / index
        )
        weights[r] = alpha
    return C1Scheme("Newton-Cotes (closed)", degree, weights, points)
def newton_cotes_closed ( index , * * kwargs ) : points = np . linspace ( - 1.0 , 1.0 , index + 1 ) degree = index + 1 if index % 2 == 0 else index # Formula (26) from # <http://mathworld.wolfram.com/Newton-CotesFormulas.html>. # Note that Sympy carries out all operations in rationals, i.e., # _exactly_. Only at the end, the rational is converted into a float. n = index weights = np . empty ( n + 1 ) t = sympy . Symbol ( "t" ) for r in range ( n + 1 ) : # Compare with get_weights(). f = sympy . prod ( [ ( t - i ) for i in range ( n + 1 ) if i != r ] ) alpha = ( 2 * ( - 1 ) ** ( n - r ) * sympy . integrate ( f , ( t , 0 , n ) , * * kwargs ) / ( math . factorial ( r ) * math . factorial ( n - r ) ) / index ) weights [ r ] = alpha return C1Scheme ( "Newton-Cotes (closed)" , degree , weights , points )