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
评论列表
文章目录