(n, mode="numpy", decimal_places=None)
return C1Scheme("Chebyshev-Gauss 2", degree, weights, points)
Chebyshev-Gauss quadrature for \\int_{-1}^1 f(x) * sqrt(1+x^2) dx.
Chebyshev-Gauss quadrature for \\int_{-1}^1 f(x) * sqrt(1+x^2) dx.
Chebyshev - Gauss quadrature for \\ int_ { - 1 } ^1 f ( x ) * sqrt ( 1 + x^2 ) dx .
def chebyshev_gauss_2(n, mode="numpy", decimal_places=None):
    """Chebyshev-Gauss quadrature for \\int_{-1}^1 f(x) * sqrt(1+x^2) dx."""
    degree = n if n % 2 == 1 else n + 1

    # TODO make explicit for all modes
    if mode == "numpy":
        points = np.cos(np.pi * np.arange(1, n + 1) / (n + 1))
        weights = np.pi / (n + 1) * (np.sin(np.pi * np.arange(1, n + 1) / (n + 1))) ** 2
    elif mode == "sympy":
        points = np.array(
            [sympy.cos(sympy.Rational(k, n + 1) * sympy.pi) for k in range(1, n + 1)]
        )
        weights = np.array(
            [
                sympy.pi / (n + 1) * sympy.sin(sympy.pi * sympy.Rational(k, n + 1)) ** 2
                for k in range(1, n + 1)
            ]
        )
    else:
        assert mode == "mpmath"
        points = np.array(
            [mp.cos(mp.mpf(k) / (n + 1) * mp.pi) for k in range(1, n + 1)]
        )
        weights = np.array(
            [
                mp.pi / (n + 1) * mp.sin(mp.pi * mp.mpf(k) / (n + 1)) ** 2
                for k in range(1, n + 1)
            ]
        )
    return C1Scheme("Chebyshev-Gauss 2", degree, weights, points)
def chebyshev_gauss_2 ( n , mode = "numpy" , decimal_places = None ) : degree = n if n % 2 == 1 else n + 1 # TODO make explicit for all modes if mode == "numpy" : points = np . cos ( np . pi * np . arange ( 1 , n + 1 ) / ( n + 1 ) ) weights = np . pi / ( n + 1 ) * ( np . sin ( np . pi * np . arange ( 1 , n + 1 ) / ( n + 1 ) ) ) ** 2 elif mode == "sympy" : points = np . array ( [ sympy . cos ( sympy . Rational ( k , n + 1 ) * sympy . pi ) for k in range ( 1 , n + 1 ) ] ) weights = np . array ( [ sympy . pi / ( n + 1 ) * sympy . sin ( sympy . pi * sympy . Rational ( k , n + 1 ) ) ** 2 for k in range ( 1 , n + 1 ) ] ) else : assert mode == "mpmath" points = np . array ( [ mp . cos ( mp . mpf ( k ) / ( n + 1 ) * mp . pi ) for k in range ( 1 , n + 1 ) ] ) weights = np . array ( [ mp . pi / ( n + 1 ) * mp . sin ( mp . pi * mp . mpf ( k ) / ( n + 1 ) ) ** 2 for k in range ( 1 , n + 1 ) ] ) return C1Scheme ( "Chebyshev-Gauss 2" , degree , weights , points )