numpy.polynomial.chebyshev.chebfromroots#

polynomial.chebyshev.chebfromroots(roots)[source]#

生成具有给定根的切比雪夫级数。

该函数返回多项式的系数

\[p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),\]

以切比雪夫形式表示,其中 \(r_n\)roots 中指定的根。如果一个零点有 n 重数,那么它必须在 roots 中出现 n 次。例如,如果 2 是三重根,3 是二重根,那么 roots 看起来像 [2, 2, 2, 3, 3]。根可以以任何顺序出现。

如果返回的系数是 c,那么

\[p(x) = c_0 + c_1 * T_1(x) + ... + c_n * T_n(x)\]

在切比雪夫形式的单项多项式中,最后一项的系数通常不为 1。

参数:
roots类数组

包含根的序列。

返回:
outndarray

系数的一维数组。如果所有根都是实数,则 out 是实数数组;如果某些根是复数,则即使结果中的所有系数都是实数,out 也是复数(参见下面的示例)。

示例

>>> import numpy.polynomial.chebyshev as C
>>> C.chebfromroots((-1,0,1)) # x^3 - x relative to the standard basis
array([ 0.  , -0.25,  0.  ,  0.25])
>>> j = complex(0,1)
>>> C.chebfromroots((-j,j)) # x^2 + 1 relative to the standard basis
array([1.5+0.j, 0. +0.j, 0.5+0.j])