test_line_orthopy.py 文件源码

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

项目:orthopy 作者: nschloe 项目源码 文件源码
def test_chebyshev_modified(tol=1.0e-14):
    alpha = 2.0

    # Get the moments corresponding to the Legendre polynomials and the weight
    # function omega(x) = |x^alpha|:
    #
    #                                        / 2/3   if k == 0,
    #    int_{-1}^{+1} |x^alpha| P_k(x) dx ={  8/45  if k == 2,
    #                                        \ 0     otherwise.
    #
    n = 5
    moments = numpy.zeros(2*n)
    moments[0] = 2.0/3.0
    moments[2] = 8.0/45.0
    _, _, b, c = \
        orthopy.line.recurrence_coefficients.legendre(2*n, 'monic')

    alpha, beta = orthopy.line.chebyshev_modified(moments, b, c)

    assert numpy.all(abs(alpha) < tol)
    assert numpy.all(
        abs(beta - [2.0/3.0, 3.0/5.0, 4.0/35.0, 25.0/63.0, 16.0/99.0])
        < tol
        )
    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号