scipy.special.

spherical_yn#

scipy.special.spherical_yn(n, z, derivative=False)[source]#

第二類球貝索函數或其導數。

定義為 [1]

\[y_n(z) = \sqrt{\frac{\pi}{2z}} Y_{n + 1/2}(z),\]

其中 \(Y_n\) 是第二類貝索函數。

參數:
nint, 類陣列

貝索函數的階數 (n >= 0)。

z複數或浮點數,類陣列

貝索函數的參數。

derivativebool, 可選

若為 True,則返回導數的值(而非函數本身)。

返回:
ynndarray

註解

對於實數參數,此函數使用升序遞迴關係 [2] 計算。對於複數參數,則使用與第二類柱貝索函數的定義關係。

導數是使用關係式 [3] 計算:

\[ \begin{align}\begin{aligned}y_n' = y_{n-1} - \frac{n + 1}{z} y_n.\\y_0' = -y_1\end{aligned}\end{align} \]

在版本 0.18.0 中新增。

參考文獻

[AS]

Milton Abramowitz 和 Irene A. Stegun, eds. Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables. New York: Dover, 1972.

範例

第二類球貝索函數 \(y_n\) 接受實數和複數第二個參數。它們可以返回複數類型

>>> from scipy.special import spherical_yn
>>> spherical_yn(0, 3+5j)
(8.022343088587197-9.880052589376795j)
>>> type(spherical_yn(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_yn(3, x, True),
...             spherical_yn(2, x) - 4/x * spherical_yn(3, x))
True

前幾個帶有實數參數的 \(y_n\)

>>> import matplotlib.pyplot as plt
>>> x = np.arange(0.0, 10.0, 0.01)
>>> fig, ax = plt.subplots()
>>> ax.set_ylim(-2.0, 1.0)
>>> ax.set_title(r'Spherical Bessel functions $y_n$')
>>> for n in np.arange(0, 4):
...     ax.plot(x, spherical_yn(n, x), label=rf'$y_{n}$')
>>> plt.legend(loc='best')
>>> plt.show()
../../_images/scipy-special-spherical_yn-1.png