scipy.special.
yn_zeros#
- scipy.special.yn_zeros(n, nt)[source]#
計算整數階貝索函數 Yn(x) 的零點。
計算在區間 \((0, \infty)\) 上函數 \(Y_n(x)\) 的 nt 個零點。零點會以遞增順序返回。
- 參數:
- nint
貝索函數的階數
- ntint
要返回的零點數量
- 返回:
- ndarray
貝索函數的前 nt 個零點。
參考文獻
[1]Zhang, Shanjie and Jin, Jianming. “Computation of Special Functions”, John Wiley and Sons, 1996, chapter 5. https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
範例
計算 \(Y_2\) 的前四個根。
>>> from scipy.special import yn_zeros >>> yn_zeros(2, 4) array([ 3.38424177, 6.79380751, 10.02347798, 13.20998671])
繪製 \(Y_2\) 及其前四個根。
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from scipy.special import yn, yn_zeros >>> xmin = 2 >>> xmax = 15 >>> x = np.linspace(xmin, xmax, 500) >>> fig, ax = plt.subplots() >>> ax.hlines(0, xmin, xmax, color='k') >>> ax.plot(x, yn(2, x), label=r'$Y_2$') >>> ax.scatter(yn_zeros(2, 4), np.zeros((4, )), s=30, c='r', ... label='Roots', zorder=5) >>> ax.set_ylim(-0.4, 0.4) >>> ax.set_xlim(xmin, xmax) >>> plt.legend() >>> plt.show()