def test_xk(k):
n = 10
moments = orthopy.line.compute_moments(lambda x: x**k, -1, +1, 2*n)
alpha, beta = orthopy.line.chebyshev(moments)
assert (alpha == 0).all()
assert beta[0] == moments[0]
assert beta[1] == sympy.Rational(k+1, k+3)
assert beta[2] == sympy.Rational(4, (k+5) * (k+3))
orthopy.line.schemes.custom(
numpy.array([sympy.N(a) for a in alpha], dtype=float),
numpy.array([sympy.N(b) for b in beta], dtype=float),
mode='numpy'
)
# a, b = \
# orthopy.line.recurrence_coefficients.legendre(
# 2*n, mode='sympy'
# )
# moments = orthopy.line.compute_moments(
# lambda x: x**2, -1, +1, 2*n,
# polynomial_class=orthopy.line.legendre
# )
# alpha, beta = orthopy.line.chebyshev_modified(moments, a, b)
# points, weights = orthopy.line.schemes.custom(
# numpy.array([sympy.N(a) for a in alpha], dtype=float),
# numpy.array([sympy.N(b) for b in beta], dtype=float)
# )
return
评论列表
文章目录