scipy.special.
legendre#
- scipy.special.legendre(n, monic=False)[source]#
Legendre 多項式。
定義為以下方程式的解:
\[\frac{d}{dx}\left[(1 - x^2)\frac{d}{dx}P_n(x)\right] + n(n + 1)P_n(x) = 0;\]\(P_n(x)\) 是一個 \(n\) 次多項式。
- 參數:
- nint
多項式的次數。
- monicbool, 選擇性
如果 True,則將前導係數縮放為 1。預設值為 False。
- 回傳值:
- Porthopoly1d
Legendre 多項式。
註解
多項式 \(P_n\) 在區間 \([-1, 1]\) 上以權重函數 1 正交。
範例
產生 3 階 Legendre 多項式 1/2*(5x^3 + 0x^2 - 3x + 0)
>>> from scipy.special import legendre >>> legendre(3) poly1d([ 2.5, 0. , -1.5, 0. ])