scipy.special.
jn_zeros#
- scipy.special.jn_zeros(n, nt)[原始碼]#
計算整數階貝索函數 Jn 的零點。
計算貝索函數 \(J_n(x)\) 在區間 \((0, \infty)\) 上的 nt 個零點。零點會以升序返回。請注意,此區間不包含當 \(n > 0\) 時存在的 \(x = 0\) 處的零點。
- 參數:
- nint
貝索函數的階數
- ntint
要返回的零點數量
- 返回:
- ndarray
貝索函數的前 nt 個零點。
參考文獻
[1]Zhang, Shanjie 和 Jin, Jianming。「Computation of Special Functions」,John Wiley and Sons,1996 年,第 5 章。 https://people.sc.fsu.edu/~jburkardt/f77_src/special_functions/special_functions.html
範例
計算 \(J_3\) 的前四個正根。
>>> from scipy.special import jn_zeros >>> jn_zeros(3, 4) array([ 6.3801619 , 9.76102313, 13.01520072, 16.22346616])
繪製 \(J_3\) 及其前四個正根。請注意,位於 0 的根不會由
jn_zeros
返回。>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from scipy.special import jn, jn_zeros >>> j3_roots = jn_zeros(3, 4) >>> xmax = 18 >>> xmin = -1 >>> x = np.linspace(xmin, xmax, 500) >>> fig, ax = plt.subplots() >>> ax.plot(x, jn(3, x), label=r'$J_3$') >>> ax.scatter(j3_roots, np.zeros((4, )), s=30, c='r', ... label=r"$J_3$_Zeros", zorder=5) >>> ax.scatter(0, 0, s=30, c='k', ... label=r"Root at 0", zorder=5) >>> ax.hlines(0, 0, xmax, color='k') >>> ax.set_xlim(xmin, xmax) >>> plt.legend() >>> plt.show()