scipy.special.
spherical_kn#
- scipy.special.spherical_kn(n, z, derivative=False)[源]#
第二类修正球贝塞尔函数或其导数。
定义为 [1],
\[k_n(z) = \sqrt{\frac{\pi}{2z}} K_{n + 1/2}(z),\]其中 \(K_n\) 是第二类修正贝塞尔函数。
- 参数:
- nint,类数组
贝塞尔函数的阶数 (n >= 0)。
- z复数或浮点数,类数组
贝塞尔函数的自变量。
- derivative布尔值,可选
如果为 True,则返回导数的值(而不是函数本身)。
- 返回:
- knndarray
说明
该函数是使用其与第二类修正圆柱贝塞尔函数的定义关系来计算的。
导数使用以下关系 [2] 计算,
\[ \begin{align}\begin{aligned}k_n' = -k_{n-1} - \frac{n + 1}{z} k_n.\\k_0' = -k_1\end{aligned}\end{align} \]在 0.18.0 版本中添加。
参考文献
[AS]Milton Abramowitz and Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972.
示例
第二类修正球贝塞尔函数 \(k_n\) 接受实数和复数两种第二个参数。它们可以返回复数类型。
>>> from scipy.special import spherical_kn >>> spherical_kn(0, 3+5j) (0.012985785614001561+0.003354691603137546j) >>> type(spherical_kn(0, 3+5j)) <class 'numpy.complex128'>
我们可以验证说明中关于 \(n=3\) 在区间 \([1, 2]\) 内导数的关系。
>>> import numpy as np >>> x = np.arange(1.0, 2.0, 0.01) >>> np.allclose(spherical_kn(3, x, True), ... - 4/x * spherical_kn(3, x) - spherical_kn(2, x)) True
前几个实数自变量的 \(k_n\)
>>> import matplotlib.pyplot as plt >>> x = np.arange(0.0, 4.0, 0.01) >>> fig, ax = plt.subplots() >>> ax.set_ylim(0.0, 5.0) >>> ax.set_title(r'Modified spherical Bessel functions $k_n$') >>> for n in np.arange(0, 4): ... ax.plot(x, spherical_kn(n, x), label=rf'$k_{n}$') >>> plt.legend(loc='best') >>> plt.show()