scipy.special.
spherical_in#
- scipy.special.spherical_in(n, z, derivative=False)[source]#
第一類修正球貝索函數或其導數。
定義為 [1],
\[i_n(z) = \sqrt{\frac{\pi}{2z}} I_{n + 1/2}(z),\]其中 \(I_n\) 是第一類修正貝索函數。
- 參數:
- nint, 類似陣列
貝索函數的階數 (n >= 0)。
- z複數或浮點數,類似陣列
貝索函數的自變數。
- derivative布林值,選填
若為 True,則會回傳導數值 (而非函數本身)。
- 回傳值:
- inndarray
註解
此函數使用其與第一類修正柱貝索函數的定義關係計算。
導數使用關係式 [2] 計算,
\[ \begin{align}\begin{aligned}i_n' = i_{n-1} - \frac{n + 1}{z} i_n.\\i_1' = i_0\end{aligned}\end{align} \]在 0.18.0 版本中新增。
參考文獻
[AS]Milton Abramowitz 與 Irene A. Stegun (編輯)。數學函數手冊:包含公式、圖表及數學表格。紐約:Dover,1972。
範例
第一類修正球貝索函數 \(i_n\) 接受實數和複數作為第二個參數。它們可以回傳複數類型
>>> from scipy.special import spherical_in >>> spherical_in(0, 3+5j) (-1.1689867793369182-1.2697305267234222j) >>> type(spherical_in(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_in(3, x, True), ... spherical_in(2, x) - 4/x * spherical_in(3, x)) True
前幾個帶有實數自變數的 \(i_n\)
>>> import matplotlib.pyplot as plt >>> x = np.arange(0.0, 6.0, 0.01) >>> fig, ax = plt.subplots() >>> ax.set_ylim(-0.5, 5.0) >>> ax.set_title(r'Modified spherical Bessel functions $i_n$') >>> for n in np.arange(0, 4): ... ax.plot(x, spherical_in(n, x), label=rf'$i_{n}$') >>> plt.legend(loc='best') >>> plt.show()