numpy.polynomial.laguerre.lagfromroots#
- polynomial.laguerre.lagfromroots(roots)[原始碼]#
產生具有給定根的拉蓋爾級數。
此函數傳回多項式的係數
\[p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),\]以拉蓋爾形式,其中 \(r_n\) 是在
roots
中指定的根。如果零點具有重數 n,則它必須在roots
中出現 n 次。例如,如果 2 是重數為三的根,而 3 是重數為 2 的根,則roots
看起來會像 [2, 2, 2, 3, 3]。根可以以任何順序出現。如果傳回的係數為 c,則
\[p(x) = c_0 + c_1 * L_1(x) + ... + c_n * L_n(x)\]對於拉蓋爾形式的單項多項式,最後一項的係數通常不是 1。
- 參數:
- rootsarray_like
包含根的序列。
- 傳回:
- outndarray
係數的 1-D 陣列。如果所有根都是實數,則 out 是實數陣列;如果某些根是複數,則即使結果中的所有係數都是實數,out 也是複數(請參閱以下範例)。
另請參閱
範例
>>> from numpy.polynomial.laguerre import lagfromroots, lagval >>> coef = lagfromroots((-1, 0, 1)) >>> lagval((-1, 0, 1), coef) array([0., 0., 0.]) >>> coef = lagfromroots((-1j, 1j)) >>> lagval((-1j, 1j), coef) array([0.+0.j, 0.+0.j])