test_line_orthopy.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:orthopy 作者: nschloe 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号