numpy.polynomial.legendre.Legendre.degree#

方法

polynomial.legendre.Legendre.degree()[source]#

序列的次数。

返回:
degreeint

序列的次数,比系数的数量少一。

示例

1 + 7*x + 4*x**2 创建一个多项式对象

>>> np.polynomial.set_default_printstyle("unicode")
>>> poly = np.polynomial.Polynomial([1, 7, 4])
>>> print(poly)
1.0 + 7.0·x + 4.0·x²
>>> poly.degree()
2

请注意,此方法不检查非零系数。您必须修剪多项式以去除任何尾随的零。

>>> poly = np.polynomial.Polynomial([1, 7, 0])
>>> print(poly)
1.0 + 7.0·x + 0.0·x²
>>> poly.degree()
2
>>> poly.trim().degree()
1