scipy.special.eval_legendre#
- scipy.special.eval_legendre(n, x, out=None) = <ufunc 'eval_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
评估勒让德多项式的点
- outndarray, optional
函数值的可选输出数组
- 返回值:
- P标量或 ndarray
勒让德多项式的值
另请参见
roots_legendre
勒让德多项式的根和正交权重
legendre
勒让德多项式对象
hyp2f1
高斯超几何函数
numpy.polynomial.legendre.Legendre
勒让德级数
参考文献
[AS]Milton Abramowitz 和 Irene A. Stegun 编辑,《具有公式、图表和数学表格的数学函数手册》。纽约:Dover,1972 年。
示例
>>> import numpy as np >>> from scipy.special import eval_legendre
在 x = 0 处评估零阶勒让德多项式
>>> eval_legendre(0, 0) 1.0
评估 -1 和 1 之间的一阶勒让德多项式
>>> 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()