本文簡要介紹 python 語言中 scipy.special.eval_legendre
的用法。
用法:
scipy.special.eval_legendre(n, x, out=None) = <ufunc 'eval_legendre'>#
在某一點計算勒讓德多項式。
Legendre多項式可以通過高斯超幾何函數 定義為
當 是整數時,結果是度數的多項式 。有關詳細信息,請參閱 [AS] 中的 22.5.49。
- n: array_like
多項式的次數。如果不是整數,則通過與高斯超幾何函數的關係確定結果。
- x: array_like
計算勒讓德多項式的點
- out: ndarray,可選
函數值的可選輸出數組
- P: 標量或 ndarray
勒讓德多項式的值
參數 ::
返回 ::
參考:
[AS]Milton Abramowitz 和 Irene A. Stegun 合編。帶有公式、圖表和數學表格的數學函數手冊。紐約:多佛,1972 年。
例子:
>>> import numpy as np >>> from scipy.special import eval_legendre
在 x = 0 處計算 zero-order Legendre 多項式
>>> eval_legendre(0, 0) 1.0
計算 -1 和 1 之間的 first-order Legendre 多項式
>>> X = np.linspace(-1, 1, 5) # Domain of Legendre polynomials >>> eval_legendre(1, X) array([-1. , -0.5, 0. , 0.5, 1. ])
在 x = 0 處計算 0 到 4 階的勒讓德多項式
>>> N = range(0, 5) >>> eval_legendre(N, 0) array([ 1. , 0. , -0.5 , 0. , 0.375])
繪製 0 到 4 階的勒讓德多項式
>>> X = np.linspace(-1, 1)
>>> import matplotlib.pyplot as plt >>> for n in range(0, 5): ... y = eval_legendre(n, X) ... plt.plot(X, y, label=r'$P_{}(x)$'.format(n))
>>> plt.title("Legendre Polynomials") >>> plt.xlabel("x") >>> plt.ylabel(r'$P_n(x)$') >>> plt.legend(loc='lower right') >>> plt.show()
相關用法
- Python SciPy special.eval_chebyc用法及代碼示例
- Python SciPy special.eval_chebys用法及代碼示例
- Python SciPy special.exp1用法及代碼示例
- Python SciPy special.expn用法及代碼示例
- Python SciPy special.ellip_harm_2用法及代碼示例
- Python SciPy special.expit用法及代碼示例
- Python SciPy special.expm1用法及代碼示例
- Python SciPy special.ellip_normal用法及代碼示例
- Python SciPy special.erfinv用法及代碼示例
- Python SciPy special.erf用法及代碼示例
- Python SciPy special.ellipj用法及代碼示例
- Python SciPy special.erf_zeros用法及代碼示例
- Python SciPy special.erfi用法及代碼示例
- Python SciPy special.erfc用法及代碼示例
- Python SciPy special.erfcx用法及代碼示例
- Python SciPy special.expi用法及代碼示例
- Python SciPy special.ellipe用法及代碼示例
- Python SciPy special.exp10用法及代碼示例
- Python SciPy special.exp2用法及代碼示例
- Python SciPy special.erfcinv用法及代碼示例
- Python SciPy special.elliprd用法及代碼示例
- Python SciPy special.exprel用法及代碼示例
- Python SciPy special.euler用法及代碼示例
- Python SciPy special.errstate用法及代碼示例
- Python SciPy special.ellip_harm用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.special.eval_legendre。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。