numpy.polynomial.legendre.legfromroots#
- polynomial.legendre.legfromroots(roots)[原始碼]#
產生具有給定根的勒壤得多項式級數。
此函數傳回多項式的係數
\[p(x) = (x - r_0) * (x - r_1) * ... * (x - r_n),\]以勒壤得形式表示,其中 \(r_n\) 是在
roots
中指定的根。如果一個零點具有重數 n,則它必須在roots
中出現 n 次。例如,如果 2 是重數為 3 的根,而 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 也是複數(請參閱以下範例)。
另請參閱
範例
>>> import numpy.polynomial.legendre as L >>> L.legfromroots((-1,0,1)) # x^3 - x relative to the standard basis array([ 0. , -0.4, 0. , 0.4]) >>> j = complex(0,1) >>> L.legfromroots((-j,j)) # x^2 + 1 relative to the standard basis array([ 1.33333333+0.j, 0.00000000+0.j, 0.66666667+0.j]) # may vary