scipy.special.eval_legendre#
- scipy.special.eval_legendre(n, x, out=None) = <ufunc 'eval_legendre'>#
在指定點評估 Legendre 多項式。
Legendre 多項式可以透過高斯超幾何函數 \({}_2F_1\) 定義為
\[P_n(x) = {}_2F_1(-n, n + 1; 1; (1 - x)/2).\]當 \(n\) 為整數時,結果為 \(n\) 次多項式。詳情請參閱 [AS] 中的 22.5.49 節。
- 參數:
- narray_like
多項式的次數。如果不是整數,結果會透過與高斯超幾何函數的關係來決定。
- xarray_like
評估 Legendre 多項式的點
- outndarray,選用
用於函數值的選用輸出陣列
- 回傳值:
- P純量或 ndarray
Legendre 多項式的值
另請參閱
roots_legendre
Legendre 多項式的根和正交權重
legendre
Legendre 多項式物件
hyp2f1
高斯超幾何函數
numpy.polynomial.legendre.Legendre
Legendre 級數
參考文獻
[AS]Milton Abramowitz 與 Irene A. Stegun (編輯)。數學函數手冊:包含公式、圖表和數學表格。紐約:Dover,1972 年。
範例
>>> import numpy as np >>> from scipy.special import eval_legendre
在 x = 0 評估零階 Legendre 多項式
>>> eval_legendre(0, 0) 1.0
在 -1 和 1 之間評估一階 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 階的 Legendre 多項式
>>> N = range(0, 5) >>> eval_legendre(N, 0) array([ 1. , 0. , -0.5 , 0. , 0.375])
繪製 0 到 4 階的 Legendre 多項式
>>> 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()