如何输入numpy.polynomial.chebyshev.Chebyshev系数?

时间:2018-03-09 18:45:18

标签: python numpy

如何提供np.polynomial.Chebyshev系数?我发现API不直观。看起来它假设有一些系数值

> import numpy as np
> xf = 3
> P = np.polynomial.Chebyshev([0, xf]) # domain is [0, xf]
> P(np.linspace(0, 3, 5)) # evaluate at 5 x-points evenly spaced from 0 to 3
array([0.        , 2.35619449, 4.71238898, 7.06858347, 9.42477796])
P(np.linspace(0, 3, 5), [1,2,3]) # evaluate the points with prescribed coefficients, implicitly asking for polynomials of 4 degrees 
TypeError: __call__() takes exactly 2 arguments (3 given)

1 个答案:

答案 0 :(得分:1)

如果查看Chebyshev docs,您会发现第一个参数是系数,而不是域。域是可选的第二个参数。例如,

np.polynomial.Chebyshev([0, 3])

0*T_0 + 3*T_1